Tag Archives: rfm12b

Raspberry Pi – getting the RFM12b to work

Now that I know how to blink a LED, it is time to move to slightly more interesting applications of the GPIO interface on the Raspberry Pi. I have a few Arduino modules in and around the house monitoring the climate and various other measures. They are all battery operated and send their information to a relay that forwards all data to Thingsspeak.

My current relay module consists of an Arduino Uno with an Ethershield, connected over i2c to another Arduino pro mini. The second Arduino is connected to a RFM12b module and uses JeeLib to receive data from the sensing modules. Would it not be nice to receive that data on a slightly more powerful platform and be able to do more with it than just forwarding it elsewhere…

Raspberry Pi with RFM12b

Raspberry Pi with RFM12b

I decided to give the rfm12b-linux kernel driver a try, as it explicitly supports the JeeLib format. I followed the instructions from rbi-source without problems. After changing the board type (RFM12B_BOARD) and group (RFM12B_DEFAULT_GROUP_ID) in rfm12b_config.h, the module compiled without problems. However, it would initially not load, showing errors in the dmesg output.

Following some suggestions here and here, I used rasps-config to disable the SPI, I2C and the Device Tree. After that, it did load and dmesg showed

[ 478.278166] rfm12b: added RFM12(B) transceiver rfm12b.0.1
[ 478.278391] rfm12b : driver loaded.

I compiled the example applications and used this

pi@hackpi:~/rfm12b-linux/examples/bin $ sudo ./rfm12b_read 

successfully opened /dev/rfm12b.0.1 as fd 3, entering read loop...

Fri Apr 29 20:07:50 2016
	32 bytes read
		4 0 0 0 115 24 0 0 87 14 109 64 102 230 11 65 41 44 124 68 
		0 0 192 127 0 0 192 127 115 162 189 253 
Fri Apr 29 20:08:14 2016
	32 bytes read
		2 0 0 0 59 77 2 0 122 233 110 64 210 225 148 65 0 0 192 127
		0 0 192 127 0 0 192 127 93 112 175 32 

showing two messages from two modules. I recognise the pattern as

typedef struct payload_t {
  unsigned long id;
  unsigned long counter;
  float value1;
  float value2;
  float value3;
  float value4;
  float value5;
  unsigned long crc;
};

belonging to the lm35 and bpm085 modules that are sending their data approximately every minute.

lm35

bmp085

Arduino with CNY70 reflective sensor as KWh meter

This post is part of a series on Arduino-based energy and climate monitoring.

P1130998

Logging electricity use from the KWh meter was the first Arduino project I started. I made various attempts at measuring the KWh electricity usage from our Ferraris KWh meter. Detecting the small black section on the rotating disk turns out not to be easy due to a lot of other reflective surfaces in the meter.

I started off with an Arduino nano combined with a TCRT5000 Infrared Reflectance 2-Channel that I purchased at DealExtreme. The TCRT5000 module combines The TCRT5000 module had two (related) problems: (1) I could not get the calibration to the appropriate sensitivity to detect the rotations of the KWh meter disk, which was probably due to (2) the focus distance of the sensor was not appropriate for the approximately 10 mm distance to the disk.

P1130989P1130990

After trying an OPB740 sensor, I settled for a CNY70 infrared reflectance sensor. I combined it with a 5V Arduino Pro mini and a RFM12b module.

P1130994

The electronics are mounted on a 4×6 cm perfboard, which can nicely be boxed in a repurposed 3xAA battery holder. Power is provided by a USB phone charger. Since the CNY70 is constantly illuminating the rotating disk and the Arduino constantly detecting whether fluctuations in the reflectance, it is not possible to run this from a battery.

P1130993

I recently switched from Nuon to Qurrent and now have a Qbox energy monitor. My attempts of implementing my own energy monitor use have therefore been overtaken by the availability of commercial meters. Nevertheless, I learned a lot and still see the advantages of having my own meter. Right now the Qbox is not yet installed due to the lack of a free Ethernet port in my basement. But as soon as my WRT703N becomes available again, I’ll try to combine the Qbox with my own meter. For this purpose I added a LED, which blinks at every rotation of the disk. I hope that I can have the QBox sensor detect the flashes of this LED, allowing me to use both monitors.

At the time of writing, gas monitoring by detecting the reflective surface in the last digit of the gas meter has not been implemented yet.

You can find the sketch for the Arduino here.

Arduino with BMP085 barometric pressure and temperature sensor

This post is part of a series on Arduino-based energy and climate monitoring.

P1130988

The BMP085 is a barometric pressure and temperature sensor that connects over i2c to a Arduino pro mini (3.3V) with a RFM12b transceiver. The barometric pressure will be the same everywhere in and around the house, but the -40 to +85°C operational range makes this sensor specifically suited for outdoor use.

P1130986

Power is provided by connecting a rechargeable 18650 LiPo battery to VCC on the programming header of the Arduino. This battery provides nominally 3.7V, which in my experience is close enough for the board to work fine.

P1130985

The Arduino, battery and sensor are packaged in a zip-lock bag to keep moisture out and are lying in a shady spot on the balcony. It performs a temperature and pressure reading every 64 seconds and transmits it to the central relay module. Between recordings it falls asleep to save power.

You can find the sketch for the Arduino here.

Module 3 – Arduino with AM2301 sensor

This post is part of a series on Arduino-based energy and climate monitoring.

The AM2301 is a humidity and temperature sensor. It is the packaged version of the DHT21 sensor. I connected it to a Arduino pro mini (3.3V) with a RFM12b tranceiver to record the ambient temperature and humidity in our bathroom.

P1130984

Power is provided by connecting a rechargeable 18650 LiPo battery to VCC on the programming header of the Arduino. This battery provides nominally 3.7V, which in my experience is close enough for the board to work fine.

The AM2301 sensor occasionally returns extreme values outside of the normal range. To prevent these spikes from polluting my ThingSpeak channel, I repeat the measurement. If the voltage is stable within 0.1V, the temperature stable within 1 degree and the humidity stable within 5%, the values are transmitted by the RFM12b.

P1130983                  P1140004

The AM2301 is glued together with the Arduino and battery onto a piece of plastic, which allows for mounting it behind the wall mirror.

It performs a temperature reading every 63 seconds and transmits it to the central relay module. Between recordings it falls asleep to save power.

You can find the sketch for the Arduino here.

Module 2 – Arduino with LM35 temperature sensor

This post is part of a series on Arduino-based energy and climate monitoring.

P1130979

The Texas Instruments LM35 is a temperature sensor with an analog output voltage that is linearly proportional to the temperature. I combined it with an Arduino Pro mini and a RFM12b module. Since I am using a 3.3V Arduino, the RFM12b module can be connected without any voltage level converters.

Using some pin headers I soldered the Pro mini to a small piece of 0.1″ perfboard. The RFM12b has a 2mm pitch and does not fit the perfboard, hence I hot-glued it to the perfboard, making sure it does not touch. On the other side of the board I mounted the LM35 sensor. The whole assembly nicely fits within a case for two 18650 batteries.

P1130981

Power is provided by connecting a rechargeable 18650 LiPo battery to VCC on the programming header of the Arduino. This battery provides nominally 3.7V, which in my experience is close enough for the board to work fine. Since the LM35 provides a temperature output reading that is proportional to the input voltage, it is important that the battery voltage is actually measured. The AVR chips ability to measure the internal 1.1 volt reference can be used to determine VCC.

P1130980

It performs a temperature reading every 62 seconds and transmits it to the central relay module.

You can find the sketch for the Arduino here.

Module 1 – Relay between RFM12b and ThingSpeak

This post is part of a series on Arduino-based energy and climate monitoring.

This is the core of the network of Arduino’s that monitors various sensors in and around my house. It consists of an Arduino Uno with an Ethershield, connected over i2c to an Arduino pro mini. The pro mini is connected to an RFM12b board and receives data packets from each of the sensor modules.

P1140006

The reason for splitting this over two Arduino’s is that both the Ethershield and RFM12b use SPI. The Ethershield (version 1) does not play nicely with another SPI module.

P1140007

All other modules send their sensor data to this one using RFM12b. Since I don’t have wired ethernet available near the location of this central module, I resorted to a TP-Link WRT703N wifi router.

P1140008

The TP-Link WRT703N is running OpenWRT and is configured as bridge between the wifi network and the wired network connection on the WRT703N. The Arduino Ethershield is wired to the WRT703N, and receives an IP address through DHCP.

Power is provided from a micro-USB phone charger to the WRT703N, which subsequently powers the Arduino Uno through USB, which subsequently powers the pro mini through two breadboard wires.

The sketch for the Arduino pro mini can be found here, the corresponding sketch for the Arduino Uno is here.

Arduino based energy and climate monitor – version 2

Some time ago I embarked on a project to build an Arduino-based energy monitor. Many of these have been described on the internet, but I wanted to do it slightly differently. However, after many struggles, trying to get a lot of functionality in a single box (computing running averages, LCD screen with fancy menu system, SD card data logging with RTC time-stamps, record temperature from other sensors connected through RFM12b), I realised that it was getting too complex. Added to that, I short-circuited the VCC and GND, causing the Arduino nano to toast. I managed to remove the nano from the perfboard with a Dremel. After connecting a new Arduino nano I realised it was not the only part that was broke… time to move on!

I decided to take a completely new approach, starting from all things that I had leafed in the process. The RFM12b modules are especially useful, as they allow me to measure and broadcast climate measurements for almost a full year on a single 18650 3.7V LiPo battery. My new design is therefore modular, using RFM12b modules to communicate, and utilises 3.3V where possible. Furthermore, I discovered http://thingspeak.com as a much easier and more user friendly way of data logging and user-interface. I don’t have to walk to the cellar closet to look at the LCD, instead I simply check the current usage on my smartphone.

The new design therefore consists of a single relay station, which receives sensor data on a RFM12b module and forwards it every minute to http://thingspeak.com. Multiple sensor modules are scattered across our house, each recording from a sensor and transmitting a few parameters every minute to the relay station.

Here is a short description of the modules I currently have. In the near future I will post more details, including some photo’s and the source code.

Module 1: Arduino Uno with an Ethershield, connected over i2c to an Arduino pro mini. The pro mini is connected to an RFM12b board and receives data packets from each of the sensor modules. The reason for splitting this over two Arduino’s is that both the Ethershield and RFM12b use SPI. The Ethershield (version 1) does not play nicely with another SPI module. More details are posted here.

P1140007

Module 2: Arduino pro mini (3.3V) with a RFM12b and a LM35 temperature sensor. More details are posted here.

P1130981

Module 3: Arduino pro mini (3.3V) with a RFM12b and a AM2302 humidity and temperature sensor. More details are posted here.

P1130984

Module 4: Arduino pro mini (3.3V) with a RFM12b and a BMP085 barometric pressure and temperature sensor. More details are posted here.

P1130988

Module 5: Arduino pro mini (5V) with a RFM12b and a pair of CNY70 reflective sensors to measure the rotation of the disk of our Ferraris kWh meter and of the last digits of our gas meter. More details are posted here.

P1130989

Module 6: Arduino pro mini (3.3V) with a RFM12b and a pair of DS18B20 temperature sensors to measure the temperature of the outgoing and returning water of our central heating system. More details are posted here.

P1130995

I am planning to reimplement the relay module 1 in the near future. I discovered the ESP 8266 wifi module, which is available for around $3.50 on Ebay. Since it has a serial interface, it should not pose any problem combining with an RFM12b.

Arduino based energy and climate monitor

Last year I started with an Arduino project to monitor the energy in our house. I made considerable progress but also encountered some problems, the main one being that the CRT5000 modules are not sufficiently sensitive to pick up the reflectance of the rotating disk of our KWh meter. ALthough it is not yet finished, let me report on the present status.

All components have been wired up and soldered on a perfboard.

For my work earlier this year I completed the real-time interface between an openEEG-compatible fake-EEG amplifier and Arduino for the BrainGain science fair. In that project I combined the Arduino with RFM12b modules and ethernet. Since it would be fun to also do that on my energy monitor, I upgraded my toy project to an energy and climate monitor. Furthermore, I want to extend it to monitor not only electricity and gas, but also water. And finally I realized that. with all the information to be displayed, I need a button to scroll through the different screens.

The core components are

  • Arduino Nano
  • RTC
  • CRT5000 Infrared reflectance module 2x
  • LC Studio SD card module
  • 1602 LCD
  • CNY70 Infrared reflectance sensor (3x)
  • RFM12b on a RFM12b Board
  • push button

front

inside

Not shown here are the modules I made for the climate measurement and the three CNY70 sensors.

The problem I am presently running into is that the sketch is too large to fit in Arduino memory. Especially the SD card support seems to take a lot of space. I have tried compressing it down, removing all unused and debugging code from the sketch, but it still fails to run robustly. With all parts of the code enabled, the Arduino randomly resets. As a solution I am now considering adding a second Arduino to interface with the SD module.