diff --git a/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino b/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino index 8ad0de246..88928ab19 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_02_analog.ino @@ -35,6 +35,7 @@ #define ANALOG_RANGE 1023 // 4095 = 12, 2047 = 11, 1023 = 10 #define ANALOG_PERCENT 10 // backward compatible div10 range #endif // ESP8266 + #ifdef ESP32 #undef ANALOG_RESOLUTION #define ANALOG_RESOLUTION 12 // 12 = 4095, 11 = 2047, 10 = 1023 @@ -305,10 +306,8 @@ void AdcInit(void) { if (Adcs.present) { #ifdef ESP32 -#if CONFIG_IDF_TARGET_ESP32 - analogSetWidth(ANALOG_RESOLUTION); // Default 12 bits (0 - 4095) -#endif // CONFIG_IDF_TARGET_ESP32 - analogSetAttenuation(ADC_11db); // Default 11db + analogReadResolution(ANALOG_RESOLUTION); // Default 12 bits (0 - 4095) + analogSetAttenuation(ADC_11db); // Default 11db #endif for (uint32_t idx = 0; idx < Adcs.present; idx++) { AdcGetSettings(idx);