Wednesday 16 September 2015

Android data to Thinkspeak with Tasker HTTP Post

I wanted to study how to exchange data between Android and Internet-of-Things cloud storage. If you have used Tasker, then you know that it is very powerful tool and that was number one choice to the Android end. I have connected my Arduino system to Xively Internet-of-Things cloud storage, but I find out that Mathworks has similar (and maybe better) service called Thingspeak.

As proof of consept I created a Thingspeak data channel for Android battery level (https://thingspeak.com/channels/55432). 
Thingspeak channel settings. 
From Thingspeak 'Data Import / Export' tab you will find an example how data channels are updated. That information will be needed for Tasker task. 

In Tasker create new Task that we can call "Thingspeak Batt Mon". 


Tasker task for Thingspeak data update. 
On this task I use %LOCATION variable that is updated in other task. That variable is same as %LOC, so it contains the latitude and longitude information separated by comma. If you want to include the location to the data then lat and long need to be stored to separate variables that I have done in first action 'Variable Split'. That will split the "lat, long" coordinates to two separate variables %LOCATION1 and %LOCATION2. 

Second action on this task is IF loop where I compare battery level to the battery level that is stored to %BATT_old variable. This way we do not update the data if value has not been changed. 

Then we get to the main part of the task, the HTTP Post action. 
HTTP Post action. 
In this action we define the Thingspeak server address and update path. This information you can find from the Thingspeak channel help. Then on the Data / File field we define the data that we send to the server. Key is your own API-key and then we define the data that we send to the server, each parameter on separate row. First parameter I have field1 where I want to store the %BATT Tasker variable. Then I have two coordinate parameters where I store the %LOCATION1 and %LOCATION2 variables that were created by the first split action. Rest of the fields can be left untouched. 

If you look the task next I have the variable set action that store the current battery level to variable #BATT_old that was used in IF statement.

Next is 15 seconds delay that is there to make sure that update interval to Thingspeak server s minimum 15 seconds. Thinkspeak has the update rate limitation of 15 seconds. 

Below IF loop I have the ELSE brach. That is needed for #BATT_old variable update in case IF branch is not executed.

Tasker task need to run by the profile. For profile I created simple Time profile that will run the task every 15 minutes.


Then data should start to appear on Thingspeak server. 

Thingspeak channel.

The location will not be visible on channel page, but can be seen on channel feed (Data Export). Note that you need to add "location=true" parameter like this: http://api.thingspeak.com/channels/55432/field/1.json?location=true (I have removed location from my public feed).



Tasker - Thingspeak combo will allow all kind of data transfer between Android and Internet, but also allows easy data transfer between Android and Arduinio or RaspberryPI. With Tasker it is possible to create all kind of user interfaces (example with speech) or location based events that can be used to trigger your controller. Data can be also read with Tasker from the feed and any kind of alarms and notifications can be created.

Following article was great help with Tasker: Controlling Your Home Automation Controller with Tasker

Monday 13 April 2015

Ikea hack - Gulliver baby crib meets an engineer



We boughta a Ikea Gulliver baby crib and some improvements needed to be made. We wanted to have the baby on same level as our own bed and without one side. This gave easy access towards the baby during the night. However there was a warning label that prevented that configuration.


Warning label.
Reason why this configuration was not allowed was the fact that ends of the bed were not secured well enough to hold the base in place. That was easy task to solve with couple of zip ties and one nylock nut.





Securing bottom of the bed to the ends.
The bolt for the pin was long enough to fit additional nyloc nut to the end and this way it was possible to create good place for the zip tie. Instead of nyloc nut, a butterfly nut could be used. If you do not trust to zip ties and you are willing to make additional holes then a L-bracket could be used to secure the ends



Crib on the same level as our bed and without one side.
This is the outcome and this is how the bed was used couple of months before the baby learned how to roll. Then there was a risk that the baby would roll between the beds and fall to the floor. For an engineer that was just one more challange.




















The solution for this problem was to secure the beds together. I did not want to fix the beds together, but also allow an access between the beds if one want to sit on the bed next to the baby.

This was possible with a cabin hooks and extended bolts to the crib. The cabin hooks were screwed under the bed so that you could just fit the hook to the baby crib bolt.
Cabin hooks were screwed under the bed.
Replaced bolt.

Tip of the hook was slightly bend inwards.














The original bolt was replaced with a threaded rod, a washer plate, a normal nut and an allen head sleeve nut. The normal nut is not really needed, but I found pre-cut threaded rods that were bit too long. I did not want to cut those shorter so I just added one nut.
The replacement bolt and the original bolt.













With this setup the crib was easy to secure to our bed, but it also gave an easy access between the beds. The other cabin hook was secured to the bolt with the rubber band, so it stayed in place when the crib was pivoted. It was just enough to open the hook from the one side.
Easy access between the bed and crib.

This is how we used the crib for first 6 months and when the baby started to crawl the bed base was lowered, but one side was still off for one month. When the baby was able to climb to our bed then we needed to attach the side and use the crib "normally".