-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using analogRead(A0); in loop causes failure #5
Comments
Please, send a link to your code. Are you using delay() to control sampling? |
No. I discovered delay is not compatible with the async library. Here I slow down sampling and it works if interval is 2ms or more. I also moved ESPHTTPServer.handle(); |
Yes, it works as you've noticed. Think that ESP8266 is a limited device. Its IP stack runs on software and there is one unique core. So, if you ask for intensive work IP will be unstable. I've tested that you can do sampling as fast as 250Hz, but anyway sampling is unstable; if processor attends HTTP requests then it cannot do sampling. You can increase sampling to around 350 Hz if processor clock is set to 160 MHz. For real-time operations, you can look for a different platform as, for instance, ESP32. Moreover, you will have to play with timer interrupts to be able to get stable sampling frequency. You can check Color Chrod by CNLohr where high-frequency sampling (around 600Hz) is done but that project does not use Arduino environment and has needed a great optimization using assembler code. More details here: http://spectrum.ieee.org/geek-life/hands-on/how-to-turn-music-into-colors-with-a-wifi-bridge. Another option is to use an external I2S ADC. |
Hi German,
Thanks for spending time on this. I was afraid that might be the case. I have looked at colorchord and an embedded version for ESP8266 may work for me.
Cheers, Bill
|
Hi Germán,
FSBrowserNG is working for me on a nodemcu v1.0 using the libraries you have specified and the most recent arduino IDE. However when I added some code in the loop it failed. The error seems related to using analogRead(A0) in my code, as it vanishes if I don't use it and generate random data. I can recreate the problem simply with just this code at the start of the main loop:
int n = analogRead(A0);
I found that if I slow down the analogRead to once every 2ms, the problem goes away. However I would
like to sample faster than 500 Hz.
WifiLEDerror.txt
Thanks
Regards, Bill
The text was updated successfully, but these errors were encountered: