Paul King chronic tinkererer

OpenHAB and Wireless Temperature Sensors

The cheap wireless modules I bought are finally working nicely so I've hooked up a temperature sensor to OpenHAB using an Arduino coupled with a cheap ethernet module.

Overview

Sensor nodes talk to the master node over-the-air via the NRF24L01+ wireless modules. The master node in turn keeps track of state and responds to HTTP requests on the LAN.

OpenHAB talks to the master node over HTTP, sending commands such as office light on and enquiring about the state of sensors, etc.

OpenHAB

OpenHAB is a highly configurable home-automation platform that can talk to an large number of HA products. It's java-based but I guess nothing is perfect ;-)

The companion iOS app is pretty nice too, here's our current interface:

The configuration is pretty simple. By way of example here are the items entries for the lights and sensor:

Switch Light_GF_Living_Lamp "Lamp" (GF_Living, Lights) { http=">[ON:POST:http://master.node/rf/light/0/on] >[OFF:POST:http://master.node/rf/light/0/off] <[http://master.node/rf/light/0:60000:REGEX((.*))]" }

Switch Light_FF_Office_Lamp "Lamp" (FF_Office, Lights) { http=">[ON:POST:http://master.node/rf/light/2/on] >[OFF:POST:http://master.node/rf/light/2/off] <[http://master.node/rf/light/2:60000:REGEX((.*))]" }

Number Temperature_FF_Office "Office [%.2f °C]" <temperature> (FF_Office) { http="<[http://master.node/temperature:60000:REGEX((.*))]" }

The poll interval is 60,000ms while the REGEX parameter tells OpenHAB how to parse the HTTP response.

The master node returns raw values so the entire output is captured. (.*)

The Master Node

This is an Arduino coupled with an ENC28J60 ethernet module, NRF24L01+ radio module and the 433MHz RF module that I talked about in an earlier post.

I'm using TMRh20s version of the RF24Network library for wireless networking and the EtherCard library to provide the HTTP endpoint for OpenHAB to talk to.

The Ethernet and Radio share the SPI interface which gave rise to cross-talk. Chucking a 10K pull-up resistor on the MISO line seemed to fix it.

The Sensor Node

This is just another Arduino with a second NRF24L01+ module and DS1820 digital temperature sensor that I had lying in my spare parts box.

It reads the temperature sensor on a loop and transmits it to the master node wirelessly.

Gotchas

NRF24L01+ Power

The NRF modules are very cheap and work really well but seem super picky about their power supply. The most stable configuration I've found so far is to use an external 3.3V supply rather than the 3.3V pin on the Arduino.

Alternatively, use an exernal PSU to power your Arduino (not USB) and run the Vin output pin through a 3.3V regulator. You've seen already that I used this method on the sensor node.

NRF24L01+ Pinout

The headers on the modules I bought are 4x2 pins which makes them impossible to use in a breadboard. I knocked up a couple of homebrew PCB adapter boards to give me an 8x1 pin header for prototyping.

Next Steps

For the sensor nodes to be useful they'll need to be battery powered and small.

I'd like a solution that'll run from a pair of AAs for at least a year, so I'll be experimenting with the ATMEGA low-power sleep modes and lower clock speeds.

Additionally it'd be cool to capture other environmental factors like brightness, humidity, and so forth.