From 0bd3201ef74c3cefb1c7ea74ae0caf0fd115ec4b Mon Sep 17 00:00:00 2001 From: "Ricardo Guzman (Richonguzman)" Date: Mon, 1 Dec 2025 09:37:02 -0300 Subject: [PATCH] AHT20 add --- common_settings.ini | 1 + include/wx_utils.h | 1 + src/LoRa_APRS_iGate.cpp | 2 +- src/wx_utils.cpp | 25 +++++++++++++++++++------ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/common_settings.ini b/common_settings.ini index 34ceac2..4047650 100644 --- a/common_settings.ini +++ b/common_settings.ini @@ -25,6 +25,7 @@ build_flags = -I variants/${PIOENV} lib_deps = adafruit/Adafruit Unified Sensor @ 1.1.14 + adafruit/Adafruit AHTX0 @ 2.0.5 adafruit/Adafruit BME280 Library @ 2.2.4 adafruit/Adafruit BMP280 Library @ 2.6.8 adafruit/Adafruit BME680 Library @ 2.0.4 diff --git a/include/wx_utils.h b/include/wx_utils.h index b188fa1..7bdced7 100644 --- a/include/wx_utils.h +++ b/include/wx_utils.h @@ -20,6 +20,7 @@ #define WX_UTILS_H_ #include +#include #include #include #include diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index bc685a4..91f84fd 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -67,7 +67,7 @@ ___________________________________________________________________*/ #endif -String versionDate = "2025-11-30"; +String versionDate = "2025-12-01"; String versionNumber = "3.1.5"; Configuration Config; WiFiClient aprsIsClient; diff --git a/src/wx_utils.cpp b/src/wx_utils.cpp index c73d1e7..0446e4b 100644 --- a/src/wx_utils.cpp +++ b/src/wx_utils.cpp @@ -42,6 +42,7 @@ float newHum, newTemp, newPress, newGas; Adafruit_BME280 bme280; +Adafruit_AHTX0 aht20; #if defined(HELTEC_V3) || defined(HELTEC_V3_2) Adafruit_BMP280 bmp280(&Wire1); Adafruit_Si7021 si7021 = Adafruit_Si7021(); @@ -119,6 +120,10 @@ namespace WX_Utils { Serial.println("BMP280 sensor found"); wxModuleType = 2; wxModuleFound = true; + if (aht20.begin()) { + Serial.println("AHT20 sensor found"); + if (wxModuleType == 2) wxModuleType = 6; + } } } } else if (wxModuleAddress == 0x40) { @@ -127,7 +132,7 @@ namespace WX_Utils { wxModuleType = 4; wxModuleFound = true; } - } + } #ifdef LIGHTGATEWAY_PLUS_1_0 else if (wxModuleAddress == 0x70) { if (shtc3.begin()) { @@ -273,7 +278,15 @@ namespace WX_Utils { newPress = 0; #endif break; - } + case 6: // BMP280 + AHT20 + bmp280.takeForcedMeasurement(); + newTemp = bmp280.readTemperature(); + newPress = (bmp280.readPressure() / 100.0F); + sensors_event_t humidity, temp; + aht20.getEvent(&humidity, &temp); + newHum = humidity.relative_humidity; + break; + } if (isnan(newTemp) || isnan(newHum) || isnan(newPress)) { Serial.println("BME/BMP/Si7021 Module data failed"); @@ -281,16 +294,16 @@ namespace WX_Utils { return ".../...g...t..."; } else { String tempStr = generateTempString(((newTemp + Config.wxsensor.temperatureCorrection) * 1.8) + 32); - + String humStr; - if (wxModuleType == 1 || wxModuleType == 3 || wxModuleType == 4 || wxModuleType == 5) { + if (wxModuleType == 1 || wxModuleType == 3 || wxModuleType == 4 || wxModuleType == 5 || wxModuleType == 6) { humStr = generateHumString(newHum); } else if (wxModuleType == 2) { humStr = ".."; } - + String presStr = (wxModuleType == 4 || wxModuleType == 5) - ? "....." + ? "....." : generatePresString(newPress + getAltitudeCorrection() / CORRECTION_FACTOR); fifthLine = "BME-> ";