Author Topic: Inconsistent DHT22 readings in sleep mode, solved using a delay()  (Read 1612 times)

joaquimbs

  • NewMember
  • *
  • Posts: 1
Hello,

I am building myself a low power thermostat, running with 3xAAA NiMH connected to VIN. If you are interested, please find the whole project in https://github.com/joaquimBS/ArduinoRepo/tree/develop/sketches/Thermostat

DHT22 pins:
 VCC connected to Mote 3V3.
 GND connected to Mote GND.
 DATA connected to a Mote digital IO.

I programmed 20 seconds sleep period by sleeping 20 times 1s, and after that I run a cycle of sampling data, doing some internal logic with it, sending the data to my RX Mote (which is connected to an ESP8266) and then back to sleep.

So far so good. I read ~23uA during sleep time (measured with a multimeter, so I assume it's some kind of average).

At some point the thermostat switches ON the heater, and the temp readings rises almost a full 1ºC. :-( When the heater is turned OFF again, the temp readings drop again 1ºC.

The only difference is that, due to a SW bug, the function doing HeaterON was doing a delay(250), while the HeaterOFF wasn't.

Finally, I noticed that when plugging in the battery (the thermostat is awake during 10s), the temp reading were the same as when the heater is ON (the delay(250) active), so I assume that temp reading is the right one.

Additionally, adding a delay(250) to the HeaterOFF, make the temp readings consistent, during HeaterON and HeaterOFF states.

I used different DHT22 libraries, one with some delay before making the measurement, one without it, etc. But what makes the difference is the delay after the reading.

So here is the question, to the Moteino & DHT22 users. How do you integrate those two? Are you experiencing any issues?

I know the DHT22 has some restrictions regarding the sampling period, but since I am respecting this, I no longer know what to do...

Many thanks!


LukaQ

  • Sr. Member
  • ****
  • Posts: 302
  • Country: si
Re: Inconsistent DHT22 readings in sleep mode, solved using a delay()
« Reply #1 on: February 13, 2018, 07:27:52 AM »
If you can make code run for DHT22 on any arduino, then it will work on moteino also. You will just have to keep setting for moteino and add DHT code to it

ChemE

  • Sr. Member
  • ****
  • Posts: 419
  • Country: us
Re: Inconsistent DHT22 readings in sleep mode, solved using a delay()
« Reply #2 on: February 13, 2018, 08:03:04 AM »
Why sleep and wake 20 times every second rather than sleeping for 8s 3 times?  If you are wanting to maximize battery life, you should wake as seldom as possible for your application.