Esp8266 deep sleep mode with DHT22 sensor - Page 1
Forum section: electronics / projects

author: Byachna
author_rank: Newbie
timestamp: April 09, 2017, 12:13:37 am
content: 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 dayMy 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

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: April 09, 2017, 12:44:33 am
content: 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 highwait for DHT to settletake the measurementwait for valuepush value to webservicewrite DHT Vcc lowdeep sleep for (time) / until interruptRegards,Frederik

author: Byachna
author_rank: Newbie
timestamp: April 09, 2017, 01:27:58 am
content: 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

author: Wiljan
author_rank: Regular Contributor
timestamp: April 09, 2017, 04:36:47 pm
content: There are a lot of discussion around on the the web on how to minimize the current when running the esp8266 from batteriesTry have a look herehttp://homecircuits.eu/blog/battery-powered-esp8266-iot-logger/or herehttps://openhomeautomation.net/esp8266-battery/Good luck

author: wassy
author_rank: Newbie
timestamp: March 07, 2018, 01:44:59 am
content: +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 configurationThanks

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: March 07, 2018, 02:01:51 am
content: Nice to hear that you and the OP could make use of itWhishing you a nice time here on the forums!

author: Xenohane
author_rank: Newbie
timestamp: December 01, 2019, 01:19:48 pm
content: @wassyCan 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