ESP32 says I haven't wired the AHT20 sensor

george_i
Posts: 1
Joined: Fri Jun 11, 2021 8:52 am

ESP32 says I haven't wired the AHT20 sensor

Postby george_i » Fri Jun 11, 2021 9:17 am

I have a ESP32 WROVER B board and I try to connect a sensor to it, but although I think I followed the instructions, something is not right.

This is the pinout of the board.
esp32 pinout.jpg
esp32 pinout.jpg (329.18 KiB) Viewed 2373 times
This is the Adafruit AHT20 sensor:
temperature___humidity_AHT20_-_prod_P4566FrontHeader.jpg
temperature___humidity_AHT20_-_prod_P4566FrontHeader.jpg (958.72 KiB) Viewed 2373 times

How I wired:
- AHT20 pin SCL -> ESP32 pin 21
- AHT20 pin SDA -> ESP32 pin 22
- AHT20 pin VIN-> ESP32 pin 5V
- AHT20 pin GND-> ESP32 pin GND


This is the code I tried:

Code: Select all

#include <Adafruit_AHTX0.h>

Adafruit_AHTX0 aht;

void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit AHT10/AHT20 demo!");

  if (! aht.begin()) {
    Serial.println("Could not find AHT? Check wiring");
    while (1) delay(10);
  }
  Serial.println("AHT10 or AHT20 found");
}

void loop() {
  sensors_event_t humidity, temp;
  aht.getEvent(&humidity, &temp);// populate temp and humidity objects with fresh data
  Serial.print("Temperature: "); Serial.print(temp.temperature); Serial.println(" degrees C");
  Serial.print("Humidity: "); Serial.print(humidity.relative_humidity); Serial.println("% rH");

  delay(500);
}

When I run the code, I always get this message on the Serial Monitor:

Code: Select all

Serial.println("Could not find AHT? Check wiring");

Who is online

Users browsing this forum: Bing [Bot] and 67 guests