logo elektroda
logo elektroda
X
logo elektroda

Wemos2mini and AHT20+BMP280 module - Tasmota only reads BMP280, no reading from AHT20

Nargo 6729 19
Best answers

How can I get Tasmota to detect the AHT20 on a combined AHT20+BMP280 I2C module when the BMP280 works but the AHT20 is not read?

Tasmota was using the wrong AHT20 initialization command; the fix was to change `#define AHTX_CMD 0xB1` to `#define AHTX_CMD 0xBE` in the AHT2x driver and then rebuild Tasmota, which made all AHT sensors detect correctly [#20782979][#20783670] The poster compiled the modified firmware with PlatformIO and confirmed that after this change the AHT20 on the combined module worked as expected [#20782979][#20783670]
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 20780746
    Nargo
    Level 23  
    Posts: 495
    Help: 45
    Rate: 206
    Hello
    I bought AHT20+BMP280 sensor module on I2C, connected to Wemos2mini, uploaded tasmot-sensors and BMP280 reads and AHT20 no longer, displays VEML6070.
    I do I2CScan = {"I2CScan": "Device(s) found at 0x38 0x77"}.
    Response correct.
    I2CDriver = {"I2CDriver":"7,8,9,10,11,12,13,14,15,17,18,20,24,29,31,36,41,42,44,46,48,69,76"}.
    I2CDriver12 0 = {"I2CDriver": "7,8,9,10,11,!12,13,14,15,17,18,20,24,29,31,36,41,42,44,46,48,69,76"}.
    I VEML6070 disappeared and still no AHT20.
    I make my own compilation
    #ifdef USE_BMP
      #undef USE_BMP
    #endif
    #define USE_BMP
    
    #ifdef USE_AHT2x
      #undef USE_AHT2x
    #endif
    #define USE_AHT2x
    

    I still only BMP.
    I unplug AHT+BMP module and plug separate BMP and AHT modules and everything works as it should.
    Not discouraged I fire up the Arduino and upload the AHT demo compilation and BMP plugs in the AHT+BMP module
    #include <Wire.h>
    #include <SPI.h>
    #include <Adafruit_BMP280.h>
    #include <AHT20.h>
    AHT20 aht20;
    
    Adafruit_BMP280 bmp; // I2C
    
    void setup() {
      Serial.begin(9600);
      while ( !Serial ) delay(100);   // wait for native usb
      Serial.println(F("BMP280 test"));
      unsigned status;
      //status = bmp.begin(BMP280_ADDRESS_ALT, BMP280_CHIPID);
      status = bmp.begin();
      if (!status) {
        Serial.println(F("Could not find a valid BMP280 sensor, check wiring or "
                          "try a different address!"));
        Serial.print("SensorID was: 0x"); Serial.println(bmp.sensorID(),16);
        Serial.print("        ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
        Serial.print("   ID of 0x56-0x58 represents a BMP 280,\n");
        Serial.print("        ID of 0x60 represents a BME 280.\n");
        Serial.print("        ID of 0x61 represents a BME 680.\n");
        while (1) delay(10);
      }
    
      /* Default settings from datasheet. */
      bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,     /* Operating Mode. */
                      Adafruit_BMP280::SAMPLING_X2,     /* Temp. oversampling */
                      Adafruit_BMP280::SAMPLING_X16,    /* Pressure oversampling */
                      Adafruit_BMP280::FILTER_X16,      /* Filtering. */
                      Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
      Serial.println("Humidity AHT20 examples");
    
      Wire.begin(); //Join I2C bus
      //Check if the AHT20 will acknowledge
      if (aht20.begin() == false)
      {
        Serial.println("AHT20 not detected. Please check wiring. Freezing.");
        while (1);
      }
      Serial.println("AHT20 acknowledged.");
    }
    
    void loop() {
        Serial.print(F("Temperature = "));
        Serial.print(bmp.readTemperature());
        Serial.println(" *C");
    
        Serial.print(F("Pressure = "));
        Serial.print(bmp.readPressure());
        Serial.println(" Pa");
    
        //Get the new temperature and humidity value
        float temperature = aht20.getTemperature();
        float humidity = aht20.getHumidity();
    
        //Print the results
        Serial.print("Temperature: ");
        Serial.print(temperature, 2);
        Serial.println(" C\t");
        Serial.print("Humidity: ");
        Serial.print(humidity, 2);
        Serial.println("% RH");
    
        Serial.println();
      
        delay(2000);
    }
    

    Result:
    Temperature = 27.20 *C
    Pressure = 98470.20 Pa
    Temperature: 26.80 C	
    Humidity: 51.00% RH


    I search and search and I can't find a solution.
    The module works but not under Tasmot.
  • ADVERTISEMENT
  • Helpful post
    #2 20780858
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #3 20780999
    Nargo
    Level 23  
    Posts: 495
    Help: 45
    Rate: 206
    khoam wrote:
    In the standard Tasmota binaries there seems to be no support for AHT20.


    As I wrote I added in my own compilation, the single AHT sensor is read, while the AHT+BMP module is no longer.
  • ADVERTISEMENT
  • #4 20781032
    Anonymous
    Level 1  
  • #6 20781078
    Anonymous
    Level 1  
  • #7 20781108
    Nargo
    Level 23  
    Posts: 495
    Help: 45
    Rate: 206
    The whole thing is powered from 3.3V connected on a pin,
    In this connection it works, when I switch to the other module it is only BME.
    When I upload the program via the arduino I get a reading in both cases.
    Breadboard with connected modules and wires. .
  • #8 20781311
    Anonymous
    Level 1  
  • #9 20781495
    Nargo
    Level 23  
    Posts: 495
    Help: 45
    Rate: 206
    khoam wrote:

    1. Using the Arduino program (from post one), are the sensors read correctly on all the modules in the above post?


    All are read by the program in Arduino.
    khoam wrote:

    2. On which modules after loading tasmot-sensors firmware the AHT20 cannot be read?
    On none. Only BMP reads correctly.
    khoam wrote:

    3. Has the tasmot-sensors firmware been compiled by you with the AHT20 option checked?

    I compiled with the option checked
    
    #ifdef USE_AHT2x
      #undef USE_AHT2x
    #endif
    #define USE_AHT2x


    I read BMPs from both, but only AHT20 single.
  • ADVERTISEMENT
  • #12 20781976
    Anonymous
    Level 1  
  • #13 20781991
    Nargo
    Level 23  
    Posts: 495
    Help: 45
    Rate: 206
    Only BMP, AHT20 and AM2301 from sensors and HA and MQTT communication
  • #14 20782545
    Anonymous
    Level 1  
  • #15 20782730
    Nargo
    Level 23  
    Posts: 495
    Help: 45
    Rate: 206
    I have fitted 10 kΩ resistors.
    Still no AHT20 from the AHT+BMP module.
    I have checked in ESP Home and it is the same as in Tasmota, the single is visible, from the double only the BMP.
  • #16 20782753
    Anonymous
    Level 1  
  • #17 20782979
    Nargo
    Level 23  
    Posts: 495
    Help: 45
    Rate: 206
    Probably the best I can do.
    Electronic module with labels SCL, GND, SDA, VDD on a breadboard

    Added after 7 [hours] 26 [minutes]:


    I figured out what, I didn't figure out how.

    For AHT10/15 the initiation command is binary 1110'0001 hexadecimal E1
    For AHT20 binary 1011'1110 hexadecimal BE

    In the AHT20 library for Arduino there is a definition
    sfe_aht20_reg_initialize = 0xBE,
    .
    And in Tasmota
    #ifdef USE_AHT2x
      #define AHTX_CMD     0xB1 // Cmd for AHT2x
      const char ahtTypes[] PROGMEM = "AHT2X|AHT2X";
    #else
      #define AHTX_CMD     0xE1 // Cmd for AHT1x
      const char ahtTypes[] PROGMEM = "AHT1X|AHT1X";
    #endif


    Now I only have the problem how to compile Tasmota with the changed file from AHT20 support Tasmota-.13.2.0



    EDIT
    I managed to compile the distribution with the change and it WORKS!!!!
    I used PlatformIO .
  • #18 20783619
    Anonymous
    Level 1  
  • #19 20783670
    Nargo
    Level 23  
    Posts: 495
    Help: 45
    Rate: 206
    It's from the brothers from the east that maybe they have "improved" something.
    In any case, after changing only

    #define AHTX_CMD 0xB1 // Cmd for AHT2x


    to

    #define AHTX_CMD 0xBE // Cmd for AHT2x

    All my AHT sensors are detected correctly.

    Thanks for your help.
  • #20 21145553
    grzegorzpilu
    Level 2  
    Posts: 2
    Hi
    maybe someone will find it useful
    in order for the module to be recognised correctly, all you have to do is add the following
    sensor:
    - platform: aht10
    variant: AHT20
    temperature:

Topic summary

✨ The discussion revolves around issues with reading data from an AHT20+BMP280 sensor module connected to a Wemos2mini using Tasmota firmware. The user reports that while the BMP280 sensor is recognized, the AHT20 sensor is not, despite attempts to modify the firmware to include AHT20 support. Various troubleshooting steps are suggested, including checking I2C addresses, pull-up resistor values, and ensuring proper voltage supply. Ultimately, the user discovers that the initialization command for the AHT20 in Tasmota was incorrect and successfully compiles a modified version of Tasmota that correctly recognizes both sensors.
Generated by the language model.

FAQ

TL;DR: Changing a single init byte (0xB1→0xBE) fixes AHT20 detection on 2‑in‑1 AHT20+BMP/BME boards; "it WORKS!!!!" after editing AHTX_CMD and recompiling. [Elektroda, Nargo, post #20782979]

Why it matters: If Tasmota or ESPHome reads only BMP/BME but not AHT20, this shows exactly how to fix it for hobbyists and integrators.

Quick Facts

How do I fix Tasmota reading only BMP/BME but not AHT20 on a combo board?

Rebuild Tasmota with the AHT20 init byte set to 0xBE. Edit the AHT driver where AHTX_CMD is defined, change 0xB1 to 0xBE, compile, and flash. The author confirms, “after changing only … it WORKS!!!!”. This resolves AHT20 detection on affected 2‑in‑1 boards. [Elektroda, Nargo, post #20782979]

Why does Tasmota misidentify my AHT20 as VEML6070?

Both can appear at 0x38, so the VEML6070 driver may claim the address first. Disabling that driver removes the misreport, but AHT20 still won’t work if the init byte is wrong. The OP showed VEML6070 disappearing after driver changes, yet AHT20 still failed. [Elektroda, Nargo, post #20780746]

How do I recompile Tasmota with the correct AHT20 command?

  1. Get Tasmota source and open in PlatformIO.
  2. Locate the AHT driver, set AHTX_CMD to 0xBE.
  3. Build tasmota-sensors and flash your Wemos D1 mini. After flashing, AHT20 is detected alongside BMP/BME. [Elektroda, Nargo, post #20782979]

What I2C addresses should I see on AHT20 + BMP/BME280 boards?

Expect two devices in I2C scan: 0x38 for AHT20 and 0x76 or 0x77 for the pressure sensor. The OP’s scan showed two devices at 0x38 and 0x77, confirming the bus and wiring were fine. [Elektroda, Nargo, post #20780746]

Does an Arduino test prove my hardware is fine?

Yes. The OP’s Arduino sketch read both sensors successfully, printing valid temperature, pressure, humidity. That confirmed wiring, power, and the combo module were good. The issue was the firmware driver, not the sensors. [Elektroda, Nargo, post #20780746]

How can I make ESPHome recognize AHT20 on the combo module?

Declare the AHT sensor as platform: aht10 and set variant: AHT20 in YAML. This forces ESPHome to initialize it as AHT20 and resolves non‑detection on combo boards. [Elektroda, grzegorzpilu, post #21145553]

Do I need extra I2C pull‑ups on ESP8266 boards?

It can help. A single combo board often has ~4.7 kΩ. Two separate boards in parallel can yield ~3.2 kΩ. If the bus is flaky, add 4.7–10 kΩ to 3V3 on SDA and SCL. ESP8266 uses software I2C, so pull‑ups matter. [Elektroda, khoam, post #20782545]

What supply voltage should I use for these modules?

Power AHT20+BME280 combo boards with 3.3 V. Some separate AHT20 and BMP280 breakouts are designed for 5 V on VCC. Mixing a 5 V board directly on a 3.3 V bus can cause issues. Check module markings. [Elektroda, khoam, post #20781311]

Why did a single AHT20 module work, but the combo board failed?

The thread confirms the combo failed until the init byte was fixed, yet a single AHT20 sometimes worked. The exact reason remains open, but updating AHTX_CMD to 0xBE solved combo detection. [Elektroda, khoam, post #20783619]

Will changing to 0xBE break AHT25 or other AHT variants?

AHT25 uses 0xB1, while AHT20 needs 0xBE. Quote: “For AHT25 the initialisation code is just 0xB1 – AHT20 and AHT25 have different ones.” Adjust per variant or implement detection logic. [Elektroda, khoam, post #20783619]

Do standard Tasmota binaries include AHT20 support?

Not always. The thread notes standard builds may lack AHT20, requiring a custom tasmota-sensors build with AHT2x support enabled. The OP still needed the 0xBE fix for AHT20. [Elektroda, khoam, post #20780858]

How do I verify the fix worked after flashing?

Run I2C scan and Sensor output in Tasmota. You should see AHT20 and BMP/BME280 readings together. The OP reported, “All my AHT sensors are detected correctly” after the AHTX_CMD change. [Elektroda, Nargo, post #20783670]
Generated by the language model.
ADVERTISEMENT