Leonardo, DataLogger Shield and DHT22 not compatible ?


I try to record temperature and humidity on a sd card.

For that, I bought a Leonardo, an adafruit datalogger shield and a DHT22 to record ambient temperature. The DHT is plugged (with the resistor) on digital port 2.

If I use the “software clock” based on millis() & timer it works well (attached file ieroHDT_RTC_DataLogger.ino) :

File 20150122/220659.csv created
2015/01/22 22:07:01,20.20,40.50
2015/01/22 22:07:06,21.00,40.50
2015/01/22 22:07:11,20.90,40.00
2015/01/22 22:07:16,20.90,40.90
2015/01/22 22:07:21,20.90,40.40

But when I unplug the arduino to plug it on a battery, the time is setup again to the compilation time and it is normal because it is written like this in setup() part.

So, I would like to use the RTC DS1307 clock and I changed just a little bit the file to incorporate the library as shown in the exemple (attached file ieroHDT_RTC_Hard_DataLogger.ino)

But the date is now 15 minutes too early, sometimes jump to 2165 and temperature/humidty are now “0” :

File 20150122/220112.csv created
2015/01/22 22:01:16,0.00,0.00
2015/01/22 22:01:21,0.00,0.00
2015/01/22 22:01:26,0.00,0.00
2165/165/165 165:165:85,0.00,0.00
2015/01/22 22:01:31,0.00,0.00

Do you have an idea of what can be wrong here ?

Thank you

ieroDHT_RTC_DataLogger.ino (3.76 KB)

ieroDHT_RTC_Hard_DataLogger.ino (3.85 KB)

I tried several alternatives libraries, and no clue. It seems that the problem appends when executing wire.begin() or rct.begin().

But I don't understand why.

I tested DHT22 alternative library, but same comportment.

Note : The DHT22 is this one : DHT22 Temperature and Humidity Sensor-DFRobot

The Leonardo doesn't have the I2C interface on A4 and A5 like the UNO. It's on Pin 2 and Pin 3. That is going to conflict with using Pin 2 for the DHT-22. Move the DHT-22 to another pin.

Thanks John !

I just moved the pin to 8, and it works well !

Have a nice day