The Sensor Box is a central node which receives data from several (up to 29) wireless sensor nodes using RFM12b transceivers. This data is uploaded once a minute (or less) to an Internet of Things service. In my current version I upload data to open.sen.se and wunderground.com. Read my blog post about why I’ve made a Sensor Box.
The sensorbox components are:
- Arduino Mega 2560
- Ethernet Shield
- RFM12b 868Mhz
- RGB Status led
The Sensorbox uses the RFM12b tranceiver to receive sensor data wireless and is connected to the SPI bus. In my case I choose to use 868 Mhz, but 434 Mhz and 915 Mhz modules are available too. The Sensorbox is continiously listening on the frequency for incomming data. It collects the received data and once per minute it uploads the data to open.sen.se. The sensor box has an ethernet shield attached.
The sensors are based upon the TinyTx code from Nathan Chantrell. I’ve made some minor modifications to the source code, actually only related to the data structure being send. You should read the TinyTX information and be able to build them yourself. The TinyTX modules are based upon a small microcontroller, the Attiny84. Read this page to understand how to program them and use Google too ;-).
The sensors could be anything. Currently I use some DHT22 temperature and humidity sensors which I’ve running on two AA batteries and have them laying around in the house.
Also I’ve build an outdoor ‘stevenson screen’ to protect one outdoor sensor from direct sunlight and rain. The data of this specific sensor is not only uploaded to open.sen.se but also to wunderground.com as personal weather station data. I have to paint it white someday. To make it even more exciting, the wunderground data can be imported into the pvoutput.org website which I use for monitoring my solar panel power generation. I used one of the standard weather stations before, but now I have my own 😉
I have several ideas for sensors like:
– Mailbox opened
– Monitor if somebody passes a line (in our garden)
– Central Heating watertemperature
– Temperature inside the fridge
Just building sensors one by one 😉
You can download the source code for the SensorBox. You do have to register yourself on open.sen.se (and wunderground.com) if you want to upload data to it.
Latest version is v0.16 and uses a new datastructure.h (included in download).
I’ve also attached one example of the TinyTX code I use for a DHT22 sensor. Check out the site of TinyTX for the most recent updates. Remember to copy ‘datastructure.h’ to a folder in you Arduino library folder. This makes it consistent between all sources.
Latest version is v0.2 which works with sensorbox v0.16. You can modify it to suit your needs.
My specific changes to the code:
Within the TinyTX code a ‘struct’ is defined. That struct is send using the RFM12b modules from the sensornode to the SensorBox. Actually, the RFM12b does not know what you send, but if you send a bunch of bits and bytes in a struct format and put them in the same structure when you receive them, it’s like you transfer the struct.
I use several structs. I have a struct for parameters from my solar power monitor, a struct from my Raspberry Pi which sends sun- & Moonrise and set times, a struct for the temperature sensors and more. All those structs are defined in ‘DataStructure.h’ which you should copy into a folder ‘DataStructure’ in your /libraries folder of the Arduino IDE.
Within the code of the TinyTX or SensorBox, I only instantiate the struct that I need for that device. Because I use the ‘DataStructure.h’ file in the library folder, I’m always certain that all my code uses the same structs. Within the struct there is a field indicating which struct it is. So the SensorBox checks this field first, and then decides where to copy the data.
I had some RGB leds left and I connected one to the SensorBox on pins:
Red = Pin 13 with resistor
Green = Pin 12 with resistor
Blue = Pin 11 with resistor
The RGB led acts as a status led:
- White – Device boot
- Magenta – NTP Time request
- Yellow – Idle, waiting for data
- Blue – Incomming Sensor data
- Green – Uploading data to Open.Sen.Se
- Cyan – Uploading data to Wunderground.com
- Red – cannot connect to Wunderground.com
The RFM12b is connected to pins 50, 51, 52 and 53 of the Arduino Mega. The IRQ line is attached to pin 2.
Starting from version 0.16 I’ve implemented the use of the Arduino EEPROM to store the FeedID’s (or channelID’s) used to upload data to Open.sen.se. Using telnet commands you can set the FeedID’s of each value received from the sensors. The sensorbox does not need to know what the value received means. It might be temperature, humidity, waterlevel, etc. It will just upload the value to open.sen.se where you will give it a name and unit and it becomes real information. I will write a small manual soon, for now check the source code and know this:
This adds a sensor config for NodeID 3, value 1 to 5 and upload the value every 5 minutes. Close the line with a comma!
Sensorcount tells the sensorbox that you have 4 sensors.
sensorshow shows info of NodeID 3
sensorlist shows contents of (a part of) the EEPROM.