Closed
Description
Basic Infos
Hardware
Hardware: ESP8266 - all boards
Core Version: 2.1.0
Description
The analog pin parameter for analogRead() is currently not zero based but absolute (A0 = 17) in contrast to the standard Arduino library implementation (see https://www.arduino.cc/en/Reference/AnalogRead). This makes ports of existing projects (e.g. https://github.com/firmata/arduino) harder.
Possible Solution
- change in all variants/.../pins_arduino.h:
...
static const uint8_t A0 = 0;
...
- change in core_esp8266_wiring_analog.c:
...
extern int __analogRead(uint8_t pin) {
if(pin == 0){
return system_adc_read();
}
return digitalRead(pin) * 1023;
}
...