Using the "SLEEP" command of Tasmota to reduce the absorption of a Sonoff

3 minutes of reading
  • Reduce the electrical consumption of household devices "ITEAD Smart Home"Thanks to the command"SLEEP”Of the alternative firmware Sonoff-Tasmota
  • Difficulty level: basso
  • configuration
  • a home automation actuator ITEAD Sonoff Smart Home riproprogrammed Sonoff-Tasmota (here a MASTERGUIDE on proreimbursement orderproprogramming)

All environments

Notes and disclaimer
  • qualsiasi eventuale modifica agli impianti domestici dev'essere progettata ed realizzata SOLO da personale qualificato;
  • any changes implemented in probefore is a propersonal responsibility as well as a profirst risk and danger (the contents of the present page are purely educational);
  • any changes implemented in proprior to a device it voids the guarantee, quality approvals and certifications.
Driving review: 2.1

CAUTION: This command has been passed (although it is still in use) by the command DYNAMIC SLEEP.

Sonoff 4channel board

The use of the firmware Sonoff-Tasmota on devices ITEAD Sonoff Smart Home enables a whole range of features that, by default, they would not be provided.

One of these, the subject of this guide, is that of regulation (live) of electrical absorption of the components Sonoff thanks to the adoption and configuration of the command "SLEEP". These devices, although they do it in a very limited way, to work they consume electricity.

To give some examples, the Sonoff Dual R2 absorbs from factory 1,24 W, while the Sonoff S20 1,11 W. Obviously we are talking about the state of rest, when the relay is not energized. In this second scenario, even if only slightly, consumption increases further.

Since you can get to have in the profirst home automation too dozens of these devices, the theme of consumption becomes therefore crucial: often i Sonoff are introduced to switch off entire branches of the profirst domestic electricity network in order to reduce consumption: it is absurd to think that they are then the same Sonoff arapppay back an indirect cost.

Every device Sonoff presents a clock internal, cyclical, which acts as a metronome during the execution of the firmware which, in turn, carries out the functions for which it is designed.

Firmware developers Sonoff-Tasmota they had the intuition to introduce a "sleep" state - after each clock cycle - which has the consequence of significantly reduce the absorption of the device. In essence, the device gives a minimum of "responsiveness" to the execution of commands (the more extensive the SLEEP value is) compared to a less electrical absorption. This responsiveness is lost because, if a command is implemented during the brief instant of sleep, this command will not be implemented until the following clock cycle (max 50ms after). On the other hand, if the command is physically commanded (eg pressing the button), this command will be lost.

Set this dormant state around 50 milliseconds (a good tradeoff between energy saving and responsiveness) reduces consumption from ~ 1,1 W to ~ 0,6 W.

Some examples:

DeviceSleep xnumxSleep xnumxSleep xnumxSleep xnumx
Sonoff Dual R21,24 W0,84 W0,76 W0,68 W
Sonoff S201,11 W0,77 W0,59 W0,51 W

Measurements were made with:

  • WiFi STA mode, enabled and connected (70% of signal)
  • MQTT enabled and connected
  • Syslog enabled and connected
  • Teleperiod 60 for debugging
  • open relays
  • 24-56 hours of measurement for a more precise result.

As can be seen, a significant reduction in the value of SLEEP does not correspond to a reduction in savings linear, therefore it is also sufficient a low value for optimal results.

The use of this command is as follows:

SleepView the current setting in progress (default: 0)
Sleep0 / offDisable the SLEEP function
Sleep1 250 ..Set the SLEEP function from 1 to 250 milliseconds, with 1 millisecond steps.

The command can be executed - both in interrogation and in setting - via MQTT, interface Web e via serial. More information on the command mode are available here.

To execute the command via MQTT it is sufficient to use a client connected to the same broker to which the device to be configured is connected or directly through his MQTT console present on the firmware web interface ("Console").

An example of querying the proproperty on Sonoff Basic:


To set a SLEEP of 50 millisecond duration, the command is:

cmnd/Sonoff/SLEEP 50

This behavior will remain until the command is executed:

cmnd/Sonoff/SLEEP off
cmnd/Sonoff/SLEEP 0

More information is available on the page dedicated to the topic in projet Sonoff-Tasmota present on GITHUB.

ITEAD Sonoff BasicATTENZIONE: remember that there is on our FORUM community an ad hoc section dedicated to Sonoff (and more generally to devices ESP8266), for any doubt, question, information on the specific merit of these components.

inDomus telegram channel