DHT22 lib working on 1Mhz?
-
I tested a DHT22 clone with a ProMini (3.3V) using basically the Sensebender sketch which reduces clock frequency to 1Mhz.
Without clock frequency reduction I get consistent readings from the DHT22 on 3.3V.
When going down to 1MHz only the first couple of readings are ok then I get NaNs.
Right now I am using the library from Mark Ruys.What library is known to work 1Mhz?
Cheers,
Thomas
-
I'm working with the library that is provided with the mysensors download.
Works with an internal clock set to 1 MHz for me.
-
Actually, I am using the same lib.
I found a thread in the Arduino forum which explains that it can not work in principle: http://forum.arduino.cc/index.php?topic=291695.0Hmmm, quite interesting that it seems to work at least in certain cases.
-
how about 2 or 4MHz if 8 is too high?
-
-
I tried it. Even on 4Mhz only the first 4 transmits show readings. Then it only returns errors.
So it only work on 8Mhz for me.
-
So after 2 weeks fiddling around with the different libraries at different clock frequencies, I have some conclusions I would like to share with you.
I tested with a ProMini and two DHT22 sensors, one from Adafruits and one from China.
As I already reported, I had problems with clock frequencies below 8MHz with all different libraries. After switching to 8MHz, I realized another problem. Temperature readings did not change. They stayed the same value, only when I reset the ProMini I had a correct reading.
I had this behaviour with the Adafruit and the library included in the MySensors project.Since yesterday evening I am testing the library from Rob Tillaart (http://arduino.cc/playground/Main/DHTLib) which is working correctly giving me correct readings.
I am presuming that this is related to sleeping the ProMini and may be the low power mode the DHT22 is going into, I don't know...(at least in Rob's lib there is a wakeup delay which seems to address that point)Anyway, it seems I have at least now a working solution. I will re-try to lower the clock frequency with that library.
Apart from that I also realized that the DHT library included in MySensor will perform a sensor read for a call to readTemperature and readHumidity which means that you would need to put a delay of 2s between a readTemperature and readHumidity. Since the sensor delivers the values in a "single" read this is rather unfortunate for battery powered sensor.
-
If it verifies ok you could perhaps create a pull request with the new library and update the DHT example sketch accordingly?
-
Ok. I'll do that. Might however take a couple of days.
-
I retried again with Rob Tillaart's DHT22 library whether I can reduce clock frequency.
The results:- 1 MHz -> wrong readings, like -100 C
- 2 MHz -> "
- 4 MHz -> from time to time wrong reading
Overall, I would state that you need to run the DHT22 with the libraries I tested on 8 Mhz.
-
Ok, thanks for the update.
-
Are you compiling for the different clock frequencies in arduino? Or is it compiled for 8/16Mhz target, and then you switch frequency in the sketch?
-
I used the Sensebender sketch which switches in the sketch.
-
Sorry for a stupid question, but how do you run at 1 Mhz?
See http://www.mysensors.org/hardware/micro#comment-2196823229
Are you able to switch to 1 Mhz at runtime?
-
Have a look at the sensebender sketch http://www.mysensors.org/hardware/micro#example-sketch
if ((measureCount == 5) && highfreq) { clock_prescale_set(clock_div_8); // Switch to 1Mhz for the reminder of the sketch, save power. highfreq = false; }
The clock frequency is scaled down by software.
Suggested Topics
-
Arduino Celebrates 10 years (Malmö/Sweden)
Announcements • 29 Mar 2014, 17:08 • hek 29 Mar 2014, 17:08 -
[mysensors] Not a valid message: invalid literal for int() with base 10: '\x00\x000'
Development • 18 Sept 2024, 20:34 • kiesel 20 Sept 2024, 08:28 -
Saving last known good state, but not in EEPROM
Development • 30 Jan 2024, 18:46 • OldSurferDude 1 Feb 2024, 14:28 -
Serial Gateway woes
Development • 3 Feb 2024, 20:31 • OldSurferDude 3 Feb 2024, 20:31 -
MYSController with MQTT Gateway (via Node Red)
Development • 11 Aug 2024, 22:35 • slt1 11 Aug 2024, 22:35 -
Sensebender Gateway (SAMD21)
Development • 25 Dec 2021, 23:02 • pikim 3 Jan 2024, 12:12