Created
April 21, 2025 10:59
-
-
Save deadlyjigsaw/a570b67f8b9fd1ebab78b19efedf610c to your computer and use it in GitHub Desktop.
aht20+bmp280 is not working without wire.h on esp32s3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Wire.h> | |
| #include <Adafruit_AHTX0.h> | |
| #include <Adafruit_BMP280.h> | |
| #define SDA_PIN 4 | |
| #define SCL_PIN 5 | |
| Adafruit_AHTX0 aht; | |
| Adafruit_BMP280 bmp; | |
| void setup() { | |
| Serial.begin(115200); | |
| delay(500); | |
| Wire.begin(SDA_PIN, SCL_PIN); | |
| aht.begin(); | |
| bmp.begin(0x77); | |
| } | |
| void loop() { | |
| sensors_event_t humidity, temperature; | |
| aht.getEvent(&humidity, &temperature); | |
| float bmpTemp = bmp.readTemperature(); | |
| float pressure = bmp.readPressure() / 100.0; | |
| Serial.printf("AHT20 - Temp: %.2fC Humidity: %.2f%%\n", temperature.temperature, humidity.relative_humidity); | |
| Serial.printf("BMP280 - Temp: %.2fC Pressure: %.2f hPa\n\n", bmpTemp, pressure); | |
| delay(3000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment