-->
Page 1 of 1

Regular sensor reading in "background" while wifi sending

PostPosted: Thu Jun 02, 2016 11:17 pm
by Grant Young
Hi there.

Apologies if this has been covered previously/elsewhere (my searching didn't pick anything up).

I've created a AC current sensor that uses an Arduino Nano and ESP8266 in combination. The Nano reads the sensor for approx. 100ms (in a tight loop) every second, then averages the result and sends via the ESP8266 (a message sent via serial) every minute.

I'm considering consolidating this to run purely on the ESP8266 (e.g. on a nodeMCU board), but realise that both the sensor reading and the wifi send operations are currently implemented using a tight loop (e.g. a while loop).

The wifi send routine can take up to 10 seconds (the timeout period I have set), which would mean that, in it's current implementation, I may lose up to 10 readings across the minute.

I wondered if there is a way I could ensure that the sensor reading occurs every second, regardless of the send progress/status? I have a sense that interrupts might be useful/suitable, but a) don't have a lot of experience with these and b) am concerned that taking such an approach might interfere with the wifi process.

Thanks in advance for any pointers/assistance.