The advantage of setting warnings in preference.txt and why sleep is max 1 minute

My EmonTH arrived. And I started downloading the arduino material and sketches, took a while to get things up and running.

While testing I happened to set compiler.show_all_warnings=true in preference.txt.

And got an error message from the sleep routine -- integer overflow. The reason is that the sleep routine takes a number of milliseconds in a word. I believe a word is definied as unsigned 16 bits, meaning that it can take a maximum value of 65535.

As one minute is 60000, it is not possible to set up it as 2 or more minutes between readings.

Lesson learned: never disregard compiler warnings.

Once I learn how, I am going to post (or push or whatever it is called) a version of the EmonTH software that can have more than one minute between readings.

// Gunnar

Robert Wall's picture

Re: The advantage of setting warnings in preference.txt and why sleep is max 1 minute

Hi Gunnar, welcome.

The usual way is to put a call like

Sleepy::loseSomeTime(seconds*1000);

inside a loop. As you say, the realistic and convenient maximum for seconds is 60, as the parameter into Sleepy::loseSomeTime is a Word (an unsigned 16 bit integer).

ghellquist's picture

Re: The advantage of setting warnings in preference.txt and why sleep is max 1 minute

Hi Robert.

Thank your for the welcome. Like the stuff I see, and immediatly want to modify it... (a disease I guess).

Now, there is a constant in the sketch saying something like "minutes between readings". It has default value 1, and can only be set to 1. Try 2 and you get faster readings.

 

// Gunnar

Comment viewing options

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