- Category: Microcontroller projects
- Last Updated on Saturday, 29 December 2012 02:32
One of first goals for many people wanting to get into the "Internet Of Things" is to be able to log simple data and save it somewhere. This example reads a temperature and publishes it to a website that can save and display your data, it's called Pachube.com. The equipment detailed is connected to the internet using a bog standard WiFi network, like the one's many of us have at home or work.
Here is a step by step guide to acheiving this for under £40.00
You will need;
- Ciseco Xino Basic for Atmel
- Atmel 328, crystal & capacitors
- Ciseco Active XBBO
- Roving Networks RV-XV
- Dallas DS18B20 Temperature Sensor
- 4.7k Resistor
- Wireless router with permanent internet connection
- Pachube.com account
Step 1 Build your hardware
Both the Xino and XBBO are supplied in kit form. They use through-hole components, making them suitable for anyone with even moderate soldering skills. For instructions on either part, see the following articles;
Next you will need to connect the Dallas DS18B20 temperature sensor. The easiest way is to mount it on the prototyping area at the top of the Xino board as show in Andrew Lindsays XINO Basic for Atmel example 1 - Measuring Temperature article. You may also want to consider using a length of 3 core wire to the sensor so that it can be mounted remotely from the Xino.
- Pin 1 of the DS18B20 connects to ground
- Pin 2 of the DS18B20 connects to Digital Input 06 on the Xino (Note that the example listed above shows 03, but we will be using 03 as a software serial port for monitoring)
- Pin 3 of the DS18B20 connects to 5V
- A 4.7K resistor connects Digital Input 06 and 5V
Step 2 Set up your Pachube account
If you don't alreayd have a Pachube account you will need to sign up for one. Pachube accounts are free, and you now get unlimited datastreams, datapoints and history. Go to https://pachube.com/signup to sign up, and then click the link in the confirmation email.
Whilst the master API key you are assigned will allow you to upload data, it is advisable to create an access key with only the PUT permission. To do this, go to the 'My Keys' link, and click the 'create a new API key' link. You will need to give it PUT permissions, but you may also want to restrict what IP addresses can use the key, restrict it to private feeds or set up an expirary date. Once you've created the key, click on 'show key' to reveal a 43 digit key. Copy this to notepad or somewhere, you'll need it later.
Next, create a feed. Give it a title, description and any other info you wish. Here you can also select if the feed is to be public or private. Add two data streams. One with an ID of 0, which will be the uptime count, and one with an ID of 1 which will be temperature in degrees C. This will now appear in your feeds section. Note that is creates a unique 5 digit feed ID that you will need to copy for use later.
Step 3 Program your Xino
I will make the assumption here that you already have the Arduino IDE installed, and you are reasonably familiar with programming Arduinos. If not, take a look at http://www.arduino.cc/ in particular the Download and the Getting Started section.
If you haven't got tem already, you will need the following libraries installed;
Create a script called Pachube_Temperature_Logger with the following code;
Create another script called credentials.h with the following code. You will need to supply your Feed ID and API key (as noted earlier), and your wifi credentials.
Compile Pachube_Temperature_Logger and upload it to the Xino.
Unplug the Xino, put the XV in to the XBBO, plug the XBBO in to the Xino and apply power
Step 4 Sit back and relax
Have a look at your feed on Pachube. The view initially defaults to 24 hours, so if you have only just turned it on, you might only see a single dot for the uptime and temperature data streams. Change this to 1 hour to zoom in. You should see stream 0 continually rise from zero. (It will fall back to zero every time the Xino is restarted). Feed 1 should display your temperature. To see that this is working, place it somewhere warm, or somewhere cold, or breath heavily on it and you will see the graph change accordingly.