Created
November 28, 2015 21:53
-
-
Save chaeplin/ca1cf67f25135ee7075f to your computer and use it in GitHub Desktop.
esp8266 analogRead
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int sampleI; | |
int Number_of_Samples; | |
int sumI; | |
void setup() | |
{ | |
Serial.begin(115200); | |
sampleI = 0; | |
sumI = 0; | |
Number_of_Samples = 1000; | |
} | |
void loop() | |
{ | |
long start_adc_now = micros(); | |
for (unsigned int n = 0; n < Number_of_Samples; n++) | |
{ | |
sampleI = analogRead(A0); | |
sumI += sampleI; | |
} | |
long stop_adc_now = micros(); | |
Serial.print("total delay in adc : "); | |
Serial.print((stop_adc_now - start_adc_now) / 1000); | |
Serial.print(" ms ---> each analogRead : "); | |
Serial.print((stop_adc_now - start_adc_now) / Number_of_Samples ); | |
Serial.print(" micros ---> analogRead : "); | |
Serial.println(sumI / Number_of_Samples); | |
sumI = 0; | |
//delayMicroseconds(10); | |
delay (1000); | |
} |
from espressif.com
In station-only mode, ESP8266 will enter light sleep automatically. In light sleep mode, the TX is still running, it will be faster the meature ADC, and because of the low-current in light sleep, it will affect the result of meaturing ADC, but we have tested it, it will be less than 0.05V.
In other mode, ESP8266 will not enter any sleep mode automatically, so the system_adc_read will not be affected by sleep mode.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
total delay in adc : 384 ms ---> each analogRead : 384 micros ---> analogRead : 299
total delay in adc : 40 ms ---> each analogRead : 40 micros ---> analogRead : 305
total delay in adc : 384 ms ---> each analogRead : 384 micros ---> analogRead : 299
total delay in adc : 384 ms ---> each analogRead : 384 micros ---> analogRead : 299
total delay in adc : 40 ms ---> each analogRead : 40 micros ---> analogRead : 305
total delay in adc : 40 ms ---> each analogRead : 40 micros ---> analogRead : 305
total delay in adc : 40 ms ---> each analogRead : 40 micros ---> analogRead : 305
total delay in adc : 384 ms ---> each analogRead : 384 micros ---> analogRead : 299
total delay in adc : 384 ms ---> each analogRead : 384 micros ---> analogRead : 299
total delay in adc : 384 ms ---> each analogRead : 384 micros ---> analogRead : 299
total delay in adc : 384 ms ---> each analogRead : 384 micros ---> analogRead : 299
total delay in adc : 384 ms ---> each analogRead : 384 micros ---> analogRead : 299
total delay in adc : 40 ms ---> each analogRead : 40 micros ---> analogRead : 305
total delay in adc : 40 ms ---> each analogRead : 40 micros ---> analogRead : 305
total delay in adc : 384 ms ---> each analogRead : 384 micros ---> analogRead : 299
total delay in adc : 40 ms ---> each analogRead : 40 micros ---> analogRead : 305
�