ThingPulse / esp8266-weather-station-color

ESP8266 Weather Station in Color using ILI9341 TFT 240x320 display
https://thingpulse.com/product/esp8266-wifi-color-display-kit-2-4/
MIT License
574 stars 222 forks source link

Will not read A0 analog input for screen dimmer #142

Closed civicbynature closed 3 years ago

civicbynature commented 3 years ago

Use one of the two templates below and delete the rest.

8<------------------------ BUG REPORT -----------------------------------------

Expected behavior

ability to a light sensor to dimmer screen brightness. "read A0 analog input"

Actual behavior

always reads 65535 no matter how it's added. Something in this code only maxes out the analog read.

define analogPin A0

int total = 0; total = analogRead(analogPin); SerialPrintln(total);

// this always prints 65535 no matte where or how you place it the code.

If I just use any other code it works just fine but not with this weather station code. What is going on?

This works fine.

define analogPin A0 / ESP8266 Analog Pin ADC0 = A0 /

int adcValue = 0; / Variable to store Output of ADC /

void setup() { Serial.begin(115200); / Initialize serial communication at 115200 / }

void loop() { adcValue = analogRead(analogPin); / Read the Analog Input value /

/ Print the output in the Serial Monitor / Serial.print("ADC Value = "); Serial.println(adcValue);

delay(1000); }

8<------------------------ END BUG REPORT -------------------------------------

civicbynature commented 3 years ago

Closing this issue. Figured it out. On the about screen your measuring the internal VCC voltage which disables the use of analogRead on A0.

Anyone else who wants to disable VCC Measurment and use A0 for analogRead needs to coment out 2 lines of code.

//ADC_mode(ADC_VCC) ~line 79 //drawLabelValue(11, "VCC: ", String(ESP.getVcc() / 1024.0) + "V"); ~line 627