- [INDEX]
- Introduction and project description
- Sensor Node and Gateway Design
- How I use OpenHAB - audio notification and dashboards
- Design detail for wireless sensor nodes and gateway
- Uber Sensor - wireless sensor for fire, smoke, gas, barking, light, movement
- Diaper Box Sensor
- Laundry Room Sensor
Wireless Sensor Node and Gateway Design Details
This is part of a series of blog posts related to the Forget Me Not Design Challenge. Click here to go to my introduction and index.
I'm looking forward to trying out the EnOcean sensors. While still waiting for my sensor kit to arrive, I thought I'd share more details regarding the design for my Arduino wireless sensor nodes and gateway.
First, my design goals for these wireless Arduino sensor nodes.
- Must be cheap and scalable. Since you could potentially have many many sensor nodes, the per unit cost of each node becomes important. I've been able to keep the sensor node costs to under $20.
- Must be energy efficient. The required components for the sensor node need to be able to be able to sleep. This includes the Arduino as well as the wireless transceivers.
- Have good wireless range. I ruled out a lot of wireless transceivers. Wifi was too power hungry and expensive. Bluetooth was too expensive and did not have enough range. Xbee and z-wave were also expensive and the range was only mediocre for the cheaper units. The best possibilities for wireless transceiver were either the very popular $6 nRF24L01+ or a newer wireless transceiver RFM69HW that's $4.
Wireless Transceiver Selection
The nRF24L01+ is pretty well known, and from testing, the range will work for most of the house. So my first task was to test out the RFM units to see what its range looks like. Using an Arduino with a $10 GPS module and the $4 RFM69HW transceiver, I took a walk outside. Inside the house is another Arduino with a RFM69HW transceiver connected through the serial monitor on the computer. The portable GPS Arduino transmits the GPS coordinate to the home Arduino using the RFM69HW, and the data is saved by the computer. This is the map that I generated from the data. The color coding indicates signal strength.
As you can see, the RFM69HW can go through a couple of houses and about 700 feet. That's pretty good range, better than the nRF24L01+. This is partly due to the difference in frequency. The RFM69HW uses 915MHz, while the nRF24L01+ uses 2.4GHz. I think the 2.4GHz wavelength is also much more congested than 915MHz, so the RFM69HW seems like a good pick.
Battery Power Design
Next, I used a few resources on the web to come up with a strip board design for a battery powered Arduino. Powering the Arduino using wall power is pretty easy, but I wanted my system to be flexible enough to incorporate battery powered sensor nodes. Using a few resources online and following the JeeLab and Low Power Lab circuits, I started testing a hardware and software design that incorporated the RFM69HW.
Using this sketch, I was able to get a sleeping current consumption of about 100uA. Not as low as the datasheet indicate, but it's a low enough for practical use right now. I should be able to get over 2 years of sleep time out of 4xAA batteries using this design, if sleeping was the only thing it did. I think there are some things I can do to further improve the sleep current (disable BOD, disconnect pull up resistors), but I really needed to move forward with the rest of the design.
I wanted my design to be as easy to replicate for others as possible. So I used a strip board for my battery power nodes. Other makers won't have to get PCB's printed out. This strip board shows a reed switch used in my Mailbox Notifier device.
Gateway Design
While the field node design was going on, I was also working on the gateway design to connect sensor node data to OpenHAB. The sensor node data coming over the RF link had to be translated into something that OpenHAB can understand. After some experimenting, I came up with this setup. A RFM gateway Arduino translates the RF data. Then an ethernet Arduino posts the data to a MQTT broker, Mosquitto.
This is what the data looks like when being passed from sensor node to RFM gateway to Ethernet Gateway to OpenHAB.
And this is what the gateway looks like in real life. Pretty prototype board-ish . You see the RFM gateway top left, ethernet gateway top right, and the Raspberry Pi sitting below them.
I wanted to make the gateway fairly hands off – so once you set it up, you won't have to reprogram it when adding sensor nodes or adding sensors to existing field nodes. This spreadsheet helps in understanding the scheme used to build MQTT topic names for any future node. The Ethernet Gateway simply forms the topic name based on the field node properties (node address, device ID, data fields). It doesn't have to actually know what those sensors are. When I configure the MQTT topic to Items in OpenHAB, I do this definition.
Extensibility and Replication
I didn't want to just make something for myself. I wanted to make a design that could be used by others, and document it well enough that they could easily use it. The code for the gateways and sensor nodes are freely available on my github. There are some variations in this design for others who want to use different components. If you want to use nRF24L01 instead of the RFM69HW, you only need to change the wireless library and maintain a similar data struct. Future wireless transceivers could be incorporated simply by changing the RFM gateway – the rest of the scheme could stay the same.