I'm trying to connect with a AHT10 with my MEGA2560. As far as I know I connected everything correct i.e. Vcc to 5Vdc, Gnd to Gnd, SCL (pin21) to SCL, SDC(pin20) to SDC. When I use the Adafruit Lib I keep getting the message that the AHT10 could not be found.
#include <Adafruit_AHT10.h>
#include "Wire.h"
Adafruit_AHT10 aht;
void setup() {
Serial.begin(9600);
Serial.println("Adafruit AHT10 demo!");
if (! aht.begin()) {
Serial.println("Could not find AHT10? Check wiring");
while (1) delay(10);
}
Serial.println("AHT10 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);
}
As you can see I used the example code, I would expect this would work, I bought the sensor from Aliexpress so maybe I need a different lib but in the library manager I can't find any other lib also on other places I know.
Does anybody has these experiences as well and know how to solve it?
Haven't trid that because I did not know it excisted. I see it in the Lib manager so I will try to make use of it and see if it detects the sensor....thanks for the tip!
The library probably assumes the default address (0x38 I think).
Some AHT10 modules have a resistor you can move to change the address to 0x39. But some web pages say that it can't be changed. Maybe the module's PCB can also be used with other sensors where the address can be changed. Does your module have that resistor? Did you move it?
Some web pages also say that you can't connect other devices to the i2c bus at the same time as AHT10, which sounds crazy, but apparently the data sheet seems to confirm it. Do you have any other i2c devices connected? For example to the "other" SCL & SDA pins? (Hint: these are not a second i2c bus, they are directly connected on the Mega PCB.)
Check those Dupont cables for continuity. They are notoriously unreliable, in my experience.
Ok first of all I have NOT connected any other I2C device on the bus, I would like to but I read on some documents this is not possible with this device so this is just a test. Nevertheless it should work.
Please see the pics below there are 2 adresses written in the pcb.
Ot was not to get defensive just to clarify i did not connect any other device. Im happy to get help here. I will test it with a spare sensor and see what happens.
If not I will search for another I2C temp/hum sensor.
I have the sensor working and its a bit weird what the solution was. I use a breakout board which has pin 20 and 21 but also on the top SCL and SDA. When I connect to pin 20 and 21 it doesn't work als not when I use the headers on the MEGA2560. But when I connect to SCL and SDA it works perfect. Maybe this is because it is a clone instead of a original, I don't know.
You are talking about the AHT10 breakout board? No, I think you may be talking about the screw terminal shield for the Mega. Strange that the pin 20/21 connectors do not work but SCL/SDA connectors do work. If you connect the sensor direct to the 20/21 pins on the Mega itself, does that work?
Pins 21 & 22 are connected to the SCL & SDA pins on the Mega itself.
Yes I'm talking about the screw temrinal board for the Mega. And it doesn't work when I plug the wires directly into the headers on the Mega as well. So only when I use the terminals where is written SL and SDA. Weird isn't???
Yes, although if it does not work on pins 20/21 on the Mega itself, that easily explains why it does not work on the corresponding screw terminal connectors.
I used a similar kind of diagram and I agree that it should work. The only reason I can guess that it doesnt work on those pins is that it is maybe due to the faact I have a clone....but a clone should be identical else it isn't a clone
@PaulRB I continued with testing and added a 0.91" OLED to the setup. I used the SSD1306 Lib from Adafruit. I was able to measure the temperature and display it on the OLED screen.
So... other devices can be on the i²c bus at the same time as AHT10. I thought so. How could they claim it was i²c compatible if it had to be the only device in the bus, defeating the point of a bus?
I think the "only device in the bus" thing must have been an error in translation. Maybe they meant you can't have another AHT10 device on the bus because of the fixed address.
Yes you have there a good point AliExpress doesn't translate everything always correct. I fully agree if something is I2C compatible one should be able to connect more devices on the bus.
Well I'm happy it works like this now continue with the next challanges of my project. Thank for your time and help