DHT22 doesn't work w/ Lilypad?

I loaded a demo sketch for the DHT22 on my Lilypad w/ AtMega328; result is Humidity = 0, Temperature = 0 deg C at 75 deg F and 25% RH. Next ran same sketch with same sensor on Uno, Nano and Mega ADK, temp and humidity both displayed normally. Plugged back into Lilypad, re-ran, temp & humidity = 0. Modified sketch to use DHT11, same results; OK on Uno, Nano, etc. yet zero values on Lilypad. I have another DHT22 w/ a Nano on my desk sending data to Xively. Lilypad produces zeros from working DHT sensor.

What am I missing here?

The LP runs at 8 Mhz and the Uno at 16 Mhz. How does your code setup the communication rate for the 1 wire interface ? Sounds like it might need some tweaking to run at the correct speed when on the LP (or any other 8 Mhz Arduino).

set up the comm rate

That’s over my head. I’m using a demo example sketch for the DHT sensors, in the Arduino library, written by Limor Fried of Adafruit, out of the box.

tweaking for 8MHZ

Point me in a direction where I can learn about such a thing because at around 5K code size I’m tempted to set up the project on an ATTiny85.

milesfromnowhere:
I’m using a demo example sketch for the DHT sensors, in the Arduino library, written by Limor Fried of Adafruit, out of the box.

Got a link to that library ? I can take a quick look to see if there's an easy change.

https://github.com/adafruit/DHT-sensor-library

The library looks to have been updated to allow use on non-16 MHz Arduinos. They added a “_count” parameter to the constructor. This gets used in a timing loop and seems that a “6” was the normal 16 MHz value. My guess is that for the LP it should be a 3.

Furthermore the example code, [DHTtester.pde, hasn’t been updated to use the new parameter. You have (my guess) code that looks like this snippet;

#include "DHT.h"

#define DHTPIN 2 // what pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);

…which I think should be …

#include "DHT.h"

#define DHTPIN 2 // what pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE, 3);

If that doesn’t work, perhaps an Adafruit support person will answer this question.

http://forums.adafruit.com/viewtopic.ph … 22#p202093](https://github.com/adafruit/DHT-sensor-library/blob/master/examples/DHTtester/DHTtester.pde)

added a count parameter to the constructor

Please show me what file you are referring to. The latest version of DHT.cpp from 8-26-12 only takes two parameters.

milesfromnowhere:

added a count parameter to the constructor

Please show me what file you are referring to. The latest version of DHT.cpp from 8-26-12 only takes two parameters.

The latest version is 1/2/2013.

https://github.com/adafruit/DHT-sensor-library

https://github.com/adafruit/DHT-sensor- … er/DHT.cpp

DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) {
  _pin = pin;
  _type = type;
  _count = count;
  firstreading = true;
}

latest code

Problem solved. It’s just amazing what using the latest code can do!! I’m an idiot.