home build e-meter and e-thermostat


edsard boelen, 24 nov 2012


As the days are getting colder, it is time to fire up the heating. At this moment we use an easy thermostat in the most basic way. As it should be. But it would be nice to have it logged and to be able to control it remotely. What also would be nice is to have some more info on the display besides the current room temperature.

As a second idea, The power companies are now selling so called e-meters for 200,- a piece. They monitor the power usage constantly and present it then in an overview. After a little search I found out that measuring technique is nothing more than a light sensor counting the KWh meter. I can easily include that in my project.



Current power usage: 265 W   week: 58.4 KWh   view graph

the idea

At first I thougt a raspberry pi would be nice to have as a central unit. But the wiring and the power consumption made me consider 3 arduino's in the end. One in the room, one in the hall and one in the computer room. They will communicate with eachother with RS485 interface.

RS485

RS485 uses a differential balanced line to transfer data, it has a very low distorsion. where rs232 has a maximum cable length of 12 meter, rs485 can handle 1200 meters. Another advantage is that it can be used as a bus network.
The 75lbc176 is an affordable rs485 driver IC, It can just be connected to the uart outputs of the arduino. I will connect it as shown below.

The arduino connecting to the computer will have a second uart, one for the rs485 network, and one to connect to the computer.
The softSerial library allows the arduino to have multiple serial ports.

Communication test

The first thing is to make the arduinos talk to eachother and one to pass some info to the computer.
I wrote 2 test applications, one for a master and one for a slave. The master will send a message, the slave will respond. The response is then transfered to the copmuter via the USB serial.
the appliactions can be downloaded as: rs485_test_master and rs485_test_slave
The circuit layout is as follows:



Network

the 75lbc176 can be configured as a bus network. But has no collision detection as with the ethernet protocol. This is solved as follows: The master will call each slave every minute and gives each slave some time to respond. This way no collisions can occur.
Network messages:
  name     to node     response value
statushall1
temp1hall11.11
temp2hall11.11
esenshall1111
waterhall1
cvhall1
statusliving1
temp1living11.11
temp2living11.11
cvsetliving11.11

The master node

Will have 3 temp sensors, usb serial interface to pass all data to the server. and a small lcd screen.
The lcd is driven by a I2C expander the PCF8574. I use this in some of my other projects.





The hall node

will have 2 temp sensors, energy counter, water level meter, actuator for central heating.






The code can be found here and here

The living room node

This node uses all its pins.
The biggest part of this node is a 256x256 dot display, it will be a KS0108 compatible lcd screen. I have used the glcd library to drive it and let is show bitmaps.
The contrast uses a negative voltage which comes from pin 18 in my case.