Battery-efficient pulse measurement

Hi, 

I have setup a system with two emonTx's, one that measures power consumption for heating and incoming power from the solar panels, both with CT's. The other emonTx is measuring pulses from the main unit for all incoming power. Unfortunately I have no other way of measuring total incoming power.

My problem is that I don't know how to setup a pulse measuring sketch that is battery efficient. The one I have now sends results every 15 seconds, but it chewed through 2 AA batteries in 4 days. I have read that you should put the RF module to sleep, which I do, but still it is not good enough. I can live with not being able to see current power level so often, but I will need to measure the total consumption on a daily level. How can this be done? Can I calculate kWh, i.e. collect total pulses, and then do the calculation in emonCMS?

Is their any other ways of conserving battery power for pulse counting?

thanks

o_cee's picture

Re: Battery-efficient pulse measurement

AFAIK, as soon as you put the cpu to sleep, you loose track of time. So it is not possible to calculate momentary power. Only counting pulses should be possible to make efficient, since you can put the cpu to sleep and wake it up on interrupt from the sensor.

I don't know if it's possible to calculate momentary power in emoncms, but I have a feeling that it will be hard to get good enough accuracy.

 

mickiii's picture

Re: Battery-efficient pulse measurement

Would it be possible to simply calculate pulse count, and then once every 5-10 minutes send it to the base, and then subsequently divide the count by the no. of counts per. kWh on then emonCMS side? It would be nice to know momentary power, but not for the cost of new batteries every other week.

MartinR's picture

Re: Battery-efficient pulse measurement

Are you sure the CPU is actually going to sleep between transmissions?

The version of emontx_lib that I looked at just has..

void emontx_sleep(int seconds) {
    for (int i=0; i<seconds; i++) {
      delay(1000);
      if (UNO) wdt_reset();
    }
}

I can't see anything in the Arduino documentation that says delay() puts the CPU in sleep mode (but that doesn't mean that it doesn't!).

StuntMonkeh's picture

Re: Battery-efficient pulse measurement

I concur with Martin the MCU is not being put to sleep only the RFM12.

I think if you add this in at the end of your loop in the main sketch it will put the MCU to sleep for the time period defined in ms.

Sleepy::loseSomeTime(time_between_readings);

So for 5 mins it would be

Sleepy::loseSomeTime(300000);

For 10 mins it would be

Sleepy::loseSomeTime(600000);

Its tied into this part of code at the beginning of the sketch I believe.

ISR(WDT_vect) { Sleepy::watchdogEvent(); }                              // Attached JeeLib sleep function to Atmega328 watchdog - enables MCU to be put into sleep mode inbetween readings to reduce power consumption

 

*EDIT: Ignore that, it will miss the pulses if its asleep...

MartinR's picture

Re: Battery-efficient pulse measurement

It will wake up on the pulse interrupt though won't it?

o_cee's picture

Re: Battery-efficient pulse measurement

Interrupt will wake it up, yes.

Have you read this?
http://openenergymonitor.org/emon/buildingblocks/pulse-counting-sleep

stuart's picture

Re: Battery-efficient pulse measurement

Do it differently, does the meter have an infrared port?  Use that to read the values every few minutes, you can sleep inbetween reads then.

mickiii's picture

Re: Battery-efficient pulse measurement

Yes, the meter has an infrared port. How would that work, is there a sketch I can refer to? Also, I assume the same sensor can be used as the one for pulses right?

 

StuntMonkeh's picture

Re: Battery-efficient pulse measurement

Mickiii,

I modified the low power sketch yesterday for my own battery powered wireless pulse node for my gas meter outside.  I am only using it to count the pulses and not the power calculation stuff.

I'm putting the MCU into low power mode using the function in jeelib in between pulses and then sending the data to the emonbase roughly every 15mins (its not accurate).  Note that there is some code in there requesting an ACK from the emonbase so data doesn't go missing.

If you wanted to measure on a daily basis you could in theory stretch the 15mins to a whole day.

The node is powered by a 9v battery because as it happens it was the only connector I had laying around so the voltage regulator is still being used.

I have put the sketch on Github.  Its the first time I have really used it so I have no idea if I have done it correctly.

https://github.com/StuntMonkeh/emonTxFirmware/tree/master/emonTx_Pulse_LowPower

Hope its of some help.

mickiii's picture

Re: Battery-efficient pulse measurement

Thank you, I really appreciate it. I will have a look at it, and try to modify it to my needs.

o_cee's picture

Re: Battery-efficient pulse measurement

StuntMonkeh:  Take a look at this: http://arduino.cc/forum/index.php/topic,45239.0.html  You should handle reading of shared data properly, switching off interrupts to avoid possible corruption. The original code should be updated for this as well, haven't had time to submit a patch yet.

StuntMonkeh's picture

Re: Battery-efficient pulse measurement

I read the link last night and again this morning.  I'm thoroughly confused.

Am I right in thinking I need to turn off the ability for the input to trigger an interrupt after it has been triggered.

So I assume it needs to go a little something like this;

1. Pulse from meter.

2. Interrupt occurs.

3. Turn off interrupt functionality for the input pin.

4. Count the pulse.

5. Turn the interrupt functionality for the input pin back on.

o_cee's picture

Re: Battery-efficient pulse measurement

No, you need to turn it off when reading the pulse count (or any other multi byte global variables which is written to in the interrupt handler) from loop().

Here is also some good information: http://www.gammon.com.au/forum/?id=11488  especially in the section called "Critical sections ... accessing volatile variables"

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.