Back to the basics with my learning project, a temperature, humidity and light level sensor with the Arduino Yun.
While text printouts to the Serial Monitor, viewing text files via SSH and login the data to a Google Spreadsheet are fine, wouldn’t it be cool to be able to see your project’s data visualized in near real time? Sure it would.
Enter Ubidots, and IoT (Internet of Things) visualization service that can receive data from your Arduino projects and graph it in a number of ways.
I was first made aware of Ubidots via this YouTube video from Acrobatic - Visualize Sensor Data Using ESP8266 (ESP-12E)
While I haven’t yet made the jump to using the ESP8266 myself, it was introduction to Ubidots as a service. They have a variety of libraries and code examples for connecting your Arduino projects and, in my case, there was a specific library for the Arduino Yun. While this library worked fine for sending 1 variable of data to the service, I ran into significant problems when I tried to send the 3 variable from this project (Temperature, Humidity and Light Level). If I added a second variable, the sketch would seem to hang when it connected to the Ubidots API.
Thankfully, a quick message to the Ubidots forums resulted in an updated library only a day later, and now — as you can see from the screen shot below — all 3 variables are being received and graphed.
Using the Arduino Yun Library made it exceedingly easy to send my project data. I only needed to include the library...
#include <UbidotsYUN.h>
Define some constants for my API key and the key for each variable I was sending.
#define TOKEN “API Token Here"
#define TEMP “Variable Token Here"
#define HUMID "Variable Token Here"
#define LIGHT "Variable Token Here"
Start the Ubidots library
Ubidots client(TOKEN);
Initialize the Ubidot client
client.init();
Then send the current data along to Ubidot each time through my loop
// Update Ubidots
client.add(TEMP, temperature);
client.add(HUMID, humidity);
client.add(LIGHT, lightlevel);
client.sendAll();
Complete Sketch Available Here as Ubidots.txt
Once I had a working Arduino library from Ubidots, it was easy to add these statements to the project and start feeding data.
On the Ubidots side, before you make your first call to the Ubidots API, you set up a “Data Source”. A Data Source is a collection of variables from a specific project. This creates the necessary variable tokens you need to include in your sketch that connect each piece of data in your sketch to a specific luggable and graphable piece of data in the Ubidots Dashboard.
Once the Data Source is set up, you can set up your dashboard with various widgets to present the data however you wish.
Here I have set up 2 widgets for each of my variable — one showing a current gauge of the data values and then a bar chart of recent data. You can change the scales on either access to show more or less data or set your own min/max data levels to get exactly the graph you want. Other widgets include Metrics — showing Min/Max, Averages and more — Maps, if you are using GPS or measurement data — Tables — and Control buttons.
Give Ubidots a try as a front end for your next Arduino IoT project and I think you will be pleasantly surprised with its features.
Please send along your questions and comments.
- Greenhouse Temperature, Humidity and Light Level Arduino Project Overview
- Powered by USB power bank
- Arduino Yun connected to breadboard for power and sensor data
- Local WiFi connection via Arduino Yun for data reporting
- Read Temperature and Humidity using blue sensor at top
- Read current light level using photo-resistor and converting to 100 point scale (0-100, with 0 being total darkness)
- Date and Time pulled from Linux side of Arduino Yun
- Sketch responds to web REST requests and provide sensor data via web browser
- DOWNLOAD CODE for this project
Comments