EmonTH - trying to set less frequent reads and radio transmissions. need help.

Hi all,

I just bought 5 pieces of EmonTH and 2 sets of the RaspberryPi-B+ with radio boards, (all 433 MHz). I have given each EmonTH a different Node ID, (17 through 21), and the only other change I made through Arduino IDE is the time_between_readings.

Am I correct that the the following constant at line 45 of emonTH_DHT22_DS18B20.ino is the correct place to choose the read+transmit interval?

const int time_between_readings= 5;    // in minutes

From my emoncms.org account, I can see that the node ID changes have taken effect as expected, but all the emonTH's are still providing fresh values to the inputs page approx once per minute. Instead of once per 5 minutes. i.e. Making the change at line 45 appears to have no effect.

I understand that setting "emoncms.org - Log to Feed" to a 5 minute interval would give the same desired data too, but I would like to prolong the battery life of the emonTH as much as possible. 

Thank you very much.

Paul Reed's picture

Re: EmonTH - trying to set less frequent reads and radio transmissions. need help.

I would have thought that the period between readings is determined by the sleep time, ie line 301.

Sleepy::loseSomeTime(time_between_readings*60*1000);

by default, 60 x 1000ms = 1 minute.

Paul

PS - you may wish to read this post before altering it though! 

gluino's picture

Re: EmonTH - trying to set less frequent reads and radio transmissions. need help.

Thank you, I see that the cause is that Sleepy::loseSomeTime only works up to 60 seconds = 60000 ms. Also clarified on this page .

It recommends calling loseSomeTime repeatedly to achieve more than 1 minute of sleep.

It seems to me that this is a bug to be improved on, or at least clarified in the comments.

The way line 45 is written at the moment (especially the comment: plural minutes),

const int time_between_readings= 1;    // in minutes

seems intended for users to increase the interval in whole minutes, but actually does not work at the moment.

One way to make it work as intended is to replace line 301 with something like:

for (int i = 0; i < time_between_readings; i++) { Sleepy::loseSomeTime(60000); }

(not tested)

Paul Reed's picture

Re: EmonTH - trying to set less frequent reads and radio transmissions. need help.

Isn't that pretty much the same as the link I pointed you to above?

Paul

Robert Wall's picture

Re: EmonTH - trying to set less frequent reads and radio transmissions. need help.

I think he's feeling peeved because he didn't understand the limitations of  Sleepy::loseSomeTime(  ).

gluino's picture

Re: EmonTH - trying to set less frequent reads and radio transmissions. need help.

The forum link given by Paul Reed is fine, but I saw that it deals with a few other issues, that's why I posted another page about getting around the 1minute maximum.

The crux of the problem, in my case, is that the authors of Line 45 and Line 301 of the .ino were also unaware that loseSomeTime() maxes out at 1 minute.  This can be deduced by the way "time_between_readings" was described and used in line 45 and 301 respectively. 

Paul Reed's picture

Re: EmonTH - trying to set less frequent reads and radio transmissions. need help.

Well it's certainly worth setting the interval to a longer update period (by doubling, trebling etc on loseSomeTime) if it doesn't undermine data accuracy. I have a garden temperature sensor which I update every 5 minutes, and the batteries are now over a year old, and still showing over 3V. Paul

Comment viewing options

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