I am creating a project that will monitor humidity and 1 to 10 temperature sensors and have a simple ethernet interface.
I have the project working but I am not happy with the way I have implemeted it.
Basically I poll for DS18B20 devices in setup() and then in the loop
loop()
{
Check Humidity();
Check Temperature();
Check Ethernet()
}
In the Humidity and Temperature function I only do a check if it has been at least 10 seconds since the last check.
The humidity is fine as it is quick. The problem is with the DS18B20 devices as the library I am using and generally most must issue a 1Wire command and then wait 750ms before looking for the answer.
Not too bad if you have 1 device, but if you have 10 then that alone is 7.5 seconds
If you make an ethernet lookup you my be waiting 7.5+ seconds for an answer due to the temperature lookups.
Is there a way that the temperature lookup can be done in the background? is there such a thing as real background processes?
Is using the Timer() and Timer2() really background processes? or does the loop() just stop while the code in the timer interrupt runs?
Should I be updating only 1 temperature probe every time through the loop if the right amount of time has passed?
Cheers
Chris