Wireless Sensors Via IoBridge + ThingSpeak
by outlet in Circuits > Microcontrollers
10755 Views, 13 Favorites, 0 Comments
Wireless Sensors Via IoBridge + ThingSpeak
I have had my ioBridge for a few years now, and recently wanted to expand the sensors to other parts of the house. After looking around at several different options, I picked up 2 netduinos (sparkfun ) and 2 xbees (sparkfun ). To go along with the netduinos, I picked up the following from ioBridge:
- 2 Temperature probes (http://store.iobridge.com/product_p/a0013.htm )
- 1 Light sensor (http://store.iobridge.com/product_p/a0011.htm )
-1 Serial smart board (http://store.iobridge.com/product_p/a0018.htm )
The netduinos have 2 UART serial connections per board. The netduinos also have 3.3V and 5V power, but the analog inputs can only handle 3.3V inputs. Luckily the ioBridge sensors can work with 3.3V. The XBEEs require 3.3V for power. I used series 1 XBEES, by default they act as a wireless serial cable. Basically, what ever goes in one XBEE comes out all of the others (and vice-versa).
For detailed information on programming the netduinos, check out the getting started guide on the netduino download page.
The Transmitter
I only needed 1 serial connection for the XBEE (to send data to the receiver). Connect the XBEE to the 3.3V, Ground and Digital Pin 1 (UART 1 TX). Digital Pin 0 is RX, if you would like to receive data. You can find the pinout for the XBEE here .
Program the netduino: follow the instructions from their website (http://www.netduino.com/downloads/ ). The netdinos use the .NET Micro Framework (which uses a compact version of C# or VB). They have some code samples on their site, but I will attach the receiver and transmitter code on this instructable.
The main function of the transmitter polls the sensors every minute or so then broadcasts the data over the XBEE. I send each sensor as a seperate string and the receiver parses all incoming sensor data
The Receiver
Program the netduino: The main function in the receiver listens for serial data from the XBEE and once data is received, stores the data. Roughly once a minute the data is transmitted to the ioBridge (which then stores the data on ThingSpeak). Using ThingSpeak I can publish graphs/charts with the data from the sensors.
IoBridge Configuration
ThingSpeak
If you don't have a ThingSpeak account, please sign up for one here. Once logged in, choose Channels from the navigation and create a new channel. Enter some information about the channel and click Update Channel. On the right, you will find a URL for updating your channel. Copy this and then click Apps from the navigation and select ThingHTTP. Create a new request, enter the following information:
- URL: https://api.thingspeak.com/update
- Method: POST
- Content Type: application/x-www-form-urlencoded
- Host: api.thingspeak.com
- Body: key=CHANNEL_WRITE_API_KEY_HERE&field1=%%field1%%&field2=%%field2%%&field3=%%field3%%
Repeat the field entries for how many sensors you want to track. Choose Update Request when you are done. On the right you will see the URL to access your ThingHTTP channel. In the netduino code, I send [[[get|ttp://api.thingspeak.com/apps/thinghttp/send_request?api_key=THING_HTTP_KEY&field1=[SENSOR_DATA]&field2=[SENSOR_DATA]&field3=[SENSOR_DATA]]]]. Again, I used GET because the ThingHTTP channel was having issues.
Wrapup (Source Code)
This was my first project with a netdunio and I am pretty satisifed with the results. It seems to be pretty reliable. ThingSpeak allows me to take the raw sensor data and get it up on the internet quickly.
Thanks for reading!