ESP32 says I haven't wired the AHT20 sensor
Posted: 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. This is the Adafruit AHT20 sensor:
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:
When I run the code, I always get this message on the Serial Monitor:
This is the pinout of the board. This is the Adafruit AHT20 sensor:
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");