Home Energy Meter

Example of home energy measurement

Example of home energy measurement

A few weeks ago I found an arduino micro controller board lying around doing nothing.
It happened to be around the time that I was wondering how to be able to automatically measure the energy usage.
We still have an old fashioned disc energy meter  which is not compatible with any external read out.
some people tried with varying success to interface the disc with diodes and such.
I decided to introduce an extra energy meter which does have a S interface.

So after the read further you can read the “how it’s made”

 Introduction

So I decided to create my own home energy measurement system.

Install of the ENTES power meter

Install of the ENTES power meter

I had to think about the setup, this was reasonably straight forward.
The extra energy meter was installed between the main power switch and the circuit-breakers.
This means that all the power used in out house hold flows through it.
The S interface is then connected to the arduino which in turn is connected by USB cable to our server which is located in the same place.

The hardware used is:

Software challenges

As for the software I chose to use the following:

  • python 2.7 for programming the server sided software.
  • The Arduino Development Enviroment for the firmware on the arduino.
  • RRDTool for the data storage and graphing.

The  problem here is that I have not used any of them seriously before.

Arduino

The main challenge was to write a program that counts the pulses, does not miss one.I found it being as simple as setting up an interrupt on a digital pin.
For the serial communication I also attached an interrupt.

The calculations done are simpel the elapsed number of pulses . is communicated though the serial.A simple calculation is done to calculate the latest power between two pulses. which is also communicated though the serial.

Because the values are stored in volatile memory, I have also devised a system to set the number of pulses though the serial port.

python and RRDTool

For python there is the pyrrd tool of which I used version 0.1.0 but I found the documentation lacking. Currently I’m learning it by actually disecting the .py files.
Also for communication I was having trouble with the autoreset function of the diecimila.

To circumvent this I tried setting the serial ports DTS signal, this actually worked on my laptop but not on the server.
It is actually quite easy when you open the serialport to set the dsrdtr. If anybody feels the need, here is a little example:

import serial

ser=serial.Serial('/dev/ttyUSB0',9600, timeout=5, dsrdtr=1)

I even switched from normal serial to arduinoserial. It did not change anything but I left it in anyway.

For RRDTool there is a python interface called pyrrd.
The main problem there is that it is not very well documented. You have the examples but they do not explain all the functionality.
So I have reverted to digging though the .py files and sometimes guessing variables and

 

Hardware challenges

In the end there were only three challenges, to get stable counting I needed to introduce a pull up or pull down.The second one was the auto-reset function of the Diecimila.
Thirdly there was the possibility that the ENTES ES-32L was not compatible with just 5V.
The data sheet actually only state 24 Volts. This last one was easy, since it is a optcoupler it does work at 5 Volts.

Stabelizing counting.

Although it was useful during development that there were spontanious pulses, I wanted to have stable counting.
To do this I needed to activate the internal pull-ups.
The problem with this is that first I had set it op for high active pulsing. This means that I routed the 5V from the to the S+ and then from the S- to pin 3.When the internal pull ups are activated It has to go the other way around: from GND to S- and then from S+ to pin 3
.

Disabling auto-reset

To disable the autoreset I first tried the software solution described above, but alas this does not work on all setups.On the arduino website I found a page (not widely advertised) on how to disable the auto reset.
I did not opt for the 120 Ohm resistor because I did not have one. A ten micro farad capacitor I did have, so I installed that one bewtween ground and reset.
Now the Arduino only resets after the power is cut.

Conclusion

I now have a working setup where I get graphs of the power and energy usage.

Code

The code is available on github. And free to use and change, the only thing I ask is to keep me in the loop.

TODO

  • get functions and objects going in python
  • get a nice webpage around the images
  • design and build an external display