The second part of this week’s 2-Bullet Tuesday! See the first part here.
You can subscribe to the newsletter on the 2-Bullet Tuesday page!
Omega Tip of the Week:
Send Data to the Ubidots IoT Platform
This week we’ll show you how to push datapoints of how much free memory your Omega currently has to the Ubidots IoT Platform and then visualize and track the data online.
First, head over to the Ubidots website and sign up for an account, then create a device for your Omega and a variable, Free Memory for the memory data you’ll be collecting. After that, you need to create an authentication token so your Omega can identify itself with Ubidots when sending data.
To find the Omega’s current free memory, we’ll use the following command on the Omega’s command line:
cat /proc/meminfo | grep MemFree | sed -e 's/MemFree:[[:space:]]*//' -e 's/ kB//'
(If you’re curious as to how this works, try running just the first part and you’ll see the rest of the command is just to isolate the current amount of free memory.)
Ok, now onto sending the data, first install the ubidots-client on your Omega:
opkg update opkg install ubidots-client
We can use the ubidots program to freely send data to Ubidots. Let’s use a script to make the endeavor a little easier, just make sure to replace the token and device values with your real Ubidots token and Ubidots device name:
#!/bin/sh TOKEN="YOUR-UBIDOTS-TOKEN-HERE" DEVICE="YOUR-UBIDOTS-DEVICE- NAME-HERE" while [ 1 ] do freeMem=$(cat /proc/meminfo | grep MemFree | sed -e 's/MemFree:[[:space:]]*//' -e 's/ kB//') ubidots -t $TOKEN -d $DEVICE set "{"free-memory":"$freeMem"}" sleep 5s done
Now bask in the online dashboard that shows the data being sent from your Omega:
From here, it’s really quick to modify the code to report data from sensors or other measurements. Happy hacking!