Author Topic: Esp8266 deep sleep mode with DHT22 sensor  (Read 7243 times)

0 Members and 1 Guest are viewing this topic.

Offline Byachna

  • Newbie
  • Posts: 4
Esp8266 deep sleep mode with DHT22 sensor
« on: April 09, 2017, 12:13:37 am »
Hello All,

I'm planning a small project that utilizes an esp8266 and a DHT22 temperature & humidity sensor to periodically post the temperature and humidity values of my humidor to a Webservice. I was reading around online and saw some similar projects having issues with the DHT22 sensor dying after a few deep sleep cycles on the esp8266.

The reason for the deep sleep is that I would love to have this setup run on battery, without having to change it every other day :)

My questions to you are:
1. Does anyone have experience with this esp8266/dht22 setup?
2. Are there any other temp/humidity sensor combos more reliable yet relatively cheap as the dht22?

I appreciate any input you could give!

Thanks,
Brandon
 

Offline frozenfrogz

  • Frequent Contributor
  • **
  • Posts: 934
  • Country: de
  • Having fun with Arduino and Raspberry Pi
Re: Esp8266 deep sleep mode with DHT22 sensor
« Reply #1 on: April 09, 2017, 12:44:33 am »
I have not used the DHT22 myself, but from what I heard you should be good if you write the DHT Vcc pin low before going to sleep and high after wake up. So don’t connect the sensor directly to the battery but use a GPIO. That way the sensor does a full reset on power restore and you should be good. The issue of not being able to read from the sensor after some time / sleep - wake cycles seems to only appear if the sensor is running while the ESP cycles. Also, there have been reports of bad measurements if the DHT22 is close to the WiFi antenna. It seems to be sensitive to RF interference, so shielding or bigger distance from the ESP is preferable.
The routine would be something like (pseudo code):

wake ESP from deep sleep (external interrupt on CH_DP, or RTC event)
write DHT Vcc high
wait for DHT to settle
take the measurement
wait for value
push value to webservice
write DHT Vcc low
deep sleep for (time) / until interrupt

Regards,
Frederik
He’s like a trained ape. Without the training.
 
The following users thanked this post: wassy

Offline Byachna

  • Newbie
  • Posts: 4
Re: Esp8266 deep sleep mode with DHT22 sensor
« Reply #2 on: April 09, 2017, 01:27:58 am »
Hi Frederik,

Thank you for the helpful response :). After reading through your pseudo code, it seems like a very logical thing to actually shut the sensor off before sending the esp8266 into deep-sleep mode. I should be receiving the components to make this project by Monday, so I hope to post my findings as I progress!

-Brandon
 
The following users thanked this post: frozenfrogz

Online Wiljan

  • Regular Contributor
  • *
  • Posts: 172
  • Country: dk
Re: Esp8266 deep sleep mode with DHT22 sensor
« Reply #3 on: April 09, 2017, 04:36:47 pm »
There are a lot of discussion around on the the web on how to minimize the current when running the esp8266 from batteries

Try have a look here

http://homecircuits.eu/blog/battery-powered-esp8266-iot-logger/

or here

https://openhomeautomation.net/esp8266-battery/

Good luck  :)
 

Offline wassy

  • Contributor
  • Posts: 8
  • Country: gb
Re: Esp8266 deep sleep mode with DHT22 sensor
« Reply #4 on: March 07, 2018, 01:44:59 am »
+1 to frozenfrog. Thanks for the advice. I also found that I need to switch VCC to the DHT22 before and after deepSleep mode.

I found other advice on the web that said set the data pin to output mode and set it low just before deep sleep, but that didn't seem to have any effect in my case. Disabling the DHT22 by setting VCC low via a GPIO pin just before going into deepSleep did the job for me, now it seems to report reliably on wakeup. I set the pin low on startup, small delay then set it high, slightly longer delay, then read the sensor, then set it low again before deep sleep is the setup I am currently running. I don't know if all of those states are needed. I will do some experimenting to find the best configuration

Thanks
 
The following users thanked this post: frozenfrogz

Offline frozenfrogz

  • Frequent Contributor
  • **
  • Posts: 934
  • Country: de
  • Having fun with Arduino and Raspberry Pi
Re: Esp8266 deep sleep mode with DHT22 sensor
« Reply #5 on: March 07, 2018, 02:01:51 am »
Nice to hear that you and the OP could make use of it :)

Whishing you a nice time here on the forums!
He’s like a trained ape. Without the training.
 

Offline Xenohane

  • Newbie
  • Posts: 1
  • Country: dk
Re: Esp8266 deep sleep mode with DHT22 sensor
« Reply #6 on: December 01, 2019, 01:19:48 pm »
@wassy

Can you share your code, what you did to make it work? I am at my wit's end, I feel like I have tried everything..

I currently set the pin low before I enter deep sleep, but I still cannot measure anything before I disconnect ground or VCC..  But when I do that the first time, it also starts working after a deep sleep.

So now I have to power it up, wait a little bit, unplug vcc, then it will work even after deep sleep
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf