Close

Improvements

A project log for Simple IOT

A workshop on IOT including a simple IOT device using Wemos D1, a DS18B20 temperature sensor, a battery shield and a rechargeable battery.

Radu MotisanRadu Motisan 09/07/2017 at 16:420 Comments

This simple construction illustrates the IOT concept and provides a solid base for expanding to more complicated sensors. The EXP Protocol can be used to add additional readings to the "Simple IOT Device", including sensors for CO2 or PM2.5. Since the Simple IOT device runs on a battery, power consumption can be implemented in the code, turning the ESP8266 Radio off to save power, and only reconnecting before data upload. A good approach is to have it take measurements every 30-60 minutes and sleep in between. There are four types of sleep modes for the ESP8266: No-sleep, Modem-sleep, Light-sleep, and Deep-sleep. They all have different functions and different current cost:

  • NO-SLEEP: The No-Sleep setting will keep everything on at all times. This will drain the most current. 
  • MODEM-SLEEP: Modem-sleep is the default mode for the ESP8266. It's only enabled when you're connected to an access point. In this mode, the ESP8266 will disable the modem (WiFi) as much as possible. It turns off the modem between DTIM Beacon intervals. This interval is set by your router.
  • LIGHT-SLEEP: Light-sleep performs the same function as Modem-sleep, but also turns off the system clock and suspends the CPU. The CPU isn't off; it's just idling.
  • DEEP-SLEEP: Everything is off but the Real Time Clock (RTC), which is how the computer keeps time. Since everything is off, this is the most power efficient option. 
  • You can use the Deep-sleep mode to have the ESP8266 go idle when measurements are not needed . You can take temperature readings every 60minutes and have the Wemos D1 go to sleep in between. Then on wake-up, make sure the connection is up before retransmitting. The logic is as follows:

  • Read sensor
  • Sleep for n microseconds 
  • Repeat
  • The sleep time is specified in microseconds (µs), and you can call it with: ESP.deepSleep(50e6); // 50e6 is 50 seconds

    Discussions