Hi! I’m having trouble reading my AHT25 sensor over I2C.
The sensor itself works as I have connected it to my ESP8266 NodeMCU with SDA on D2 and SCL on D1 and I get temperature and humidity readings using this library: https://github.com/dvarrel/AHT20
All I did was change it to Wire.begin(5, 4) and that then works on my ESP8266. So this validates my sensor works.
As for the Heltec board, I have been reading everywhere about I2C on these devices and how there are two buses on the ESP32. I tried all sorts. I tried soldering to the two test pins on the back (17, 18), I tried using SDA 41 and SCL 42, I tried 21, 22, 20, 21… I tried every library I could find for the AHT25.
This I2C scanner code finds the device:
/* Originally published by Heltec-Aaron-Lee on github.
* https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/issues/62
* Wire - I2C Scanner
*
* for example the WeMos D1 Mini I2C bus uses pins:
* D1 = SCL
* D2 = SDA
*/
#include <Wire.h>
const int SCLpin = 42;
const int SDApin = 41;
void setup()
{
Serial.begin(115200);
Serial.println(“I2C Scanner”);
Serial.println("SDA Pin = "+String(SDA));
Serial.println("SCL Pin = "+String(SCL));
Wire.begin(SDApin, SCLpin);
}
void loop()
{
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for (address = 1; address < 127; address++)
{
// The i2c scanner uses the return value of Write.endTransmisstion to see if a device did
acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print("I2C device found at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.print(address, HEX);
Serial.println(" !");
nDevices++;
}
else if (error == 4)
{
Serial.print("Unknown error at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.println(address, HEX);
}
}
if (nDevices == 0) {
Serial.println("No I2C devices found\n");
}
else {
Serial.println("Done.\n");
}
delay(2000);
}
I don’t understand. I’m fairly inexperienced with electrics and I2C is new to me but why is the I2C scanner finding it but when I then try to use Wire.begin(41, 42) in the AHT25 library, it fails to ACK with my sensor on the Heltec board but the same library with Wire.begin(5, 4) works on my ESP8266 with the same sensor.
Any help would be appreciated… I spent many many hours now to get this to work. All I want is to read these readings ands end them over Lora. Lora works well but I can’t get this sensor to work!
PS: Wiring wise, it’s just a 5cm lead direct to the pins. Some pics attached (excuse my crap soldering)!
!