I am having arduino uno and DHT11 temperature sensor. I am basically planning to make event based system. Example if first it reads temperature 23 degree then it sends to server. Then if temperature is not changing at least 10% threshold value, I want NOT TO SEND the data. My requirement; In this time I want arduino to sleep down and if temperature changes I will wake up my arduino.

Is it possible? I want small sample code.


  • No, that is not possible. The DHT11 requires a sequence of pulses to read the temperature. The Arduino can only do that when it is not sleeping. You can read the temperature for example every few seconds or minutes and go to sleep after that. I think the DHT11 starts internally reading a new temperature after a temperature has been requested from it. That means you get the temperature of the previous time. That means if you read the temperature every minute, you get the temperate of a minute before. Have you choosen a DHT library and a sleep library? – Jot Nov 20 '17 at 6:48
  • @Jot. Post that as an answer – user31481 Nov 20 '17 at 8:38
  • Welcome to Arduino SE. Please realize that this is not a free design house, homework-answering service or an on-line technical encyclopedia, copied out to you on demand. People will help you take the next step if your question shows that you've done as much as you possibly could on your own. – user31481 Nov 20 '17 at 8:38
  • As @Jot said, it is impossible, but you can use another MCU which is more light weight, such as ATtiny85. Reference these 2 projects #1: technoblogy.com/show?KX0 , #2: arduinoelectronics.wordpress.com/2014/01/06/… , ATtiny85 just using 0.7mA - 8mA in normal mode. Also you also can consider using Arduino Pro Mini, it does not contain the USB Serial IC, could reduce ~40mA. – Allen Chak Nov 20 '17 at 8:44
  • It's not possible the way you described, but it is possible. You can make the Arduino sleep for a certain amount of time instead, using the Watchdog Timer. So you'd sleep the Arduino for 8 seconds; wake up; do a reading of the temperature; depending on the value send it to the server; then repeat. Please note that if you want to preserve power by sleeping, using a Arduino UNO is a bad idea. This is because the UNO has some other components on the board that will stay on, and suck away power, even in the ATMega328 is sleeping. – Gerben Nov 20 '17 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.