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.

Arduino kWh and M^3/h energy meter – gathering the components

I am working on an energy meter that is to show the instantaneous electrical power (kWh ) and natural gas usage (M^3/h) in our house. A bit like <a href=”http://juerd.nl/site.plp/kwh”>http://juerd.nl/site.plp/kwh</a>, but with two recordings, data logging to an SD card and with some buttons to switch the display from the instantaneous recording to usage per-minute, per-hour, etc.

I just managed to get all components hooked up to the Arduino nano. See the photo for an impression.

The project includes

  • Arduino Nano
  • RTC
  • CRT5000 Infrared Reflectance 2x
  • SD card module
  • 1602 LCD

I am still waiting for the two pushbuttons. Once those arrive I’ll finalize the electronics and software and transfer it to a perfboard.

      

First steps to realtime EEG and BCI on Raspberry Pi

I just compiled the FieldTrip realtime EEG interface on the Raspberry Pi. The code compiled out of the box, not a single line of code needed to be changed thanks to the existing cross-platform support for the old Apple PPC-G4 and the Neuromag HPUX-RISC MEG system. Streaming data to and from the FieldTrip buffer over TCP/IP works like a charm.

I’ll add my binaries for the Raspberry Pi to the regular FieldTrip release.

The next step will be to compile some of the EEG acquisition drivers, e.g. for OpenEEG and BrainVision.

Eventually it would be nice to also get BCI2000 to work on the Pi. According to Juergen large parts of BCI2000v3 should compile on the ARM… I look forward to gving it a try.