-->
Page 1 of 1

"Simultaneous" sensor reading and WiFi TX

PostPosted: Wed Aug 30, 2017 5:05 pm
by bcosta
Hi all,

I am working on something where I want to continually sample data from some sensors attached to the ESP8266 and periodically upload that data using a HTTP POST.

All examples I have seen (Arduino samples so far) basically stop sampling the data while they connect WiFi and upload the data, which is not suitable for my use case as I will lose important information.

Is it possible to have the data continually sampled from sensors, and upload happen "simulataneously" and do you have any links to examples doing this?

I was considering using ISR to do the sensor data sampling while the main routine basically has a loop of sleep, gather data, connect wifi, do POST.

I was wondering if this is possible with arduino, if not I am also considering using the Espressif RTOS SDK instead which is probably much more suitable anyway as my sensor sampling realistically should have time limits to be accurate.

What issues might I face?

For example I read that using the ADC during WiFi TX will give erroneous results. Would this also happen if using an external ADC like ADS1115 or with other GPIO inputs?

Thanks,
Brendon.

Re: "Simultaneous" sensor reading and WiFi TX

PostPosted: Sun Sep 03, 2017 9:03 pm
by bcosta
philbowles wrote:ESP runs WiFi code in the background and if your code delays or takes to long, it will cause a Watchdog timer (WDT) reset.

...

Are you saying that you are worried about losing sensor data during the actual transmission of the HTTP POST? If so, you need the Async versions of the libraries, e.g. ESPAsyncTCP or other libraries based on them.


Yes that is what I was worried about. Thanks for the pointer. So it sounds like I can use ESPAsyncTCP to do async POST in the background while my main loop is continually reading the sensors producing data ready for the next POST.

Thanks.