This page (Input modules) has been merged with output modules and replaced by Building Blocks

See Documentation reorganisation proposal



Edro's picture

Re: Input modules

Do you have a complete list of materials for both the input and output and all other caveats?  We'd like to build our own, but want to make sure we get all of the appropriate materials.  Thanks!

voodoo's picture

Re: Input modules

Can you recommend me which Hardware I require to develop a small project to measure Energy saved not too dissimliar to yours.

Having read your forum I'm already thinking you will save me a lot of work since the system you have is not too dissimar but I have not purchase any hardware yet and it looks like the arduino route is the way to go but which one ?

I have a system which currently switches off AC and lighting circuits for rental homes when the client is out of the premisses using a simple keyfob Timer and Relay circuit. I would like to develop a monitoring systems to show me energy saved using the efergy sensors which I already own.

I wish to Measure 2 analogue sources of Current (like 2x 110v on each line) using a small loop sensor which give me a small voltage change. Then I need to record the values and compare them to values obtained prior to them removing the keyfob which generates another signal to tell me to start counting time and multiplying that by time elapsed and the energy used thus giving me the amount of KWH saved between Client out and Client In.

I wish to store the results to show me how much energy has been saved since the last reset say and display this on a LCD (Louis project with 16 x2 chars LCD should do) which could also show me lapsed energy saved until the key is returned on the keyfob.

I have looked at the Arduino Uno option with Makershield but there are other options which seems more attractive given that I will want a more permanent solution once developped.

1) Ardweeny + Protoshield
2) Prototino
3) Boardwino

I Have yet to purchase any of these but would like guidance as to which combination I should use to develop then build my boards--- given that I might want to make about 20 of these to hand out to my clients. The Programming side looks fairly comprehensible as I was a C programmer.

I will start with building a dual Current sensor module using your code as guidance and see how I do before I need help.

Background : I'm Responsible for switching over 100KW of energy (Client cannot leave without taking key and AC and lights switch off automatically once they are gone) in 25 rental homes in a tourist town in Costa Rica and live here during the UK winters - this project is to pay for my beers and to give something back to the environment !


Stelios's picture

Re: Input modules

Hello Trystan.
I would like to try and replicate your project but using a different uC.
I haven't figured out how fast you need to sample the ADC for the CT clamp. I would like to know this number since it will help me select a proper uC.


TrystanLea's picture

Re: Input modules

Hello Stelios

In the sketch the part 

for (int n=0; n<numberOfSamples; n++) { ... }

takes 1121ms for 3000 readings = 2674Hz

But this included all the analog reading, summing, multiplying, digital high pass etc

The ADC sample rate of the ATmega 328 is set at its default rate which corresponds to about 9600Hz.



Dave's picture

Re: Input modules

I just started working on this, I have it breadboarded for a single CT (100A) and managed to calibrate it for current. I can't find the sketch for version 3. I am having a ton of trouble calibrating it under version 2. I'm in the US and where I live we have peak demand metering. This means that during peak periods they take the highest hour's KWH usage and charge you a ton for that single hour. Needless to say a meter that tells me the instantaneous usage would save me a ton of money. My plan is to use contactors to shed load as the load increases. I already shed the water heater during peak periods but I need to be able to tell what is being used NOW, not an hour ago like the meter reading tells me. When I can get the device calibrated somewhat I'll add a second CT and move it to the meter location.

Help me find the version 3 sketch please.


TrystanLea's picture

Re: Input modules

Hello Dave

Its on the how to build it page. But here is the link to save time: basicmonitor.tar.gz

All the best with your project!


Dave's picture

Re: Input modules

Thanks, got the files and completed the breadboard for a single CT. Works great. Power factor is an annoying item. I went through the same iterations as you in integrating voltage and current and getting a good figure for real power. Similarly, I integrated power and then averaged it and tried to calculate the power factor. What a royal pain in the butt. I agree with you that the CT sensor and the power transformer both add inductance to the circuit that affect the power factor measurement. Interestingly, I did some checking on the killawatt and found that it has trouble with power factor, especially when the power levels are low.

Now a question. In your opinion should I just tie the two CTs in series and adjust the burden resistor for the split phase power in the US, or should I integrate the two of them separately? There's trade offs to both methods, but the big one seems to be processing time since we have to use float in the various calculations.

Also, the low pass filter you discovered and implemented is fantastic. That thing adjusts itself and removes the harmonics from the digital sampling really well. I implemented a complete measurement program without it and worked through the calibration and had exactly the same problems you did with various noise sources making the readings erratic. That filter eliminated that problem completely.

Really good job on this, thanks again.

Michael's picture

Re: Input modules

Hi Tristan,

Excellent website - have build a PDU (PowerDistributionUnit) for 19" Racks based on your code with 10
Current Transformers.
Data is polled by a Perl script and stored in a RRD Database. Graphs are generated by rrd.cgi on a Webserver...

Sorry but it's in german


TrystanLea's picture

Re: Input modules

Hey Micheal, that's really cool, excellent work! Google translate works really well so I can follow what your doing. Like I said to Ben below, and I know you have your own site, but if you ever want to use the openenergymonitor blog to tell people about your work, even just a link through to your site you would be welcome, just email me.


Guest's picture

Re: Input modules

Fantastic project. I have built it up and started logging data to mySQL using an ethernet shield. I've also brought your "scope" code into the main monitoring code, so I can see the waveform while monitoring.

I think I may try a display unit next - I've been looking at how you built yours.

Thanks for the writeup,