Skip to content

Timer Clock

Heinz Peter Hippenstiel edited this page May 2, 2019 · 11 revisions

ESPEasy ITEAD Sonoff S20 Timer-Clock

The Sonoff S20 has GPIO-12 attached to the relay, GPIO-0 attached to the button and GPIO-13 is attached to a green LED which is used as WLAN indicator. It has another blue LED which shows the state of the relay. Keep this in mind and adjust to your needs.

NOTE: In the meantime espurna has a neat schedule feature. You should have a look.

Steps for the setup:

Configure devices

Select the Devices link and add two devices:

  • Device: Switch Input
    Name: Relay
    1st GPIO: GPIO-12 (D6)
    Pull UP: (not selected)
    Enabled: (selected)
    Value Name 1: State
  • Device: Switch Input
    Name: Button
    1st GPIO: GPIO-0 (D3)
    Pull UP: (selected)
    Switch Button Type: Push Button Active Low
    Enabled: (selected)
    Value Name 1: State

For everything not listed use the default. The Enabled flag is maybe only in ESPEasy Mega.

Select the Hardware Link and change:

  • Wifi Status Led: GPIO-13 (D7)
  • Pin mode 0 (D3): Input

You could also set a default state for GPIO-13 but using a rule has the advantage that it's set close to the moment when WLAN is really active and not right from the start.

Configure rules

For the rules part a few things have to be considered:

  • Do some setup after boot
  • Switch the relay at defined times on or off
  • Act on a button press

After a device is powered on it must determine if the relay should be on or off depending on the time. Just like a classic timer-clock but with the difference that the ESP based device will have (hopefully) the current time unlike mechanical timer-clocks. This is done after a few seconds so that NTP was able to get the current time. Another thing (at least for the S20) is to set the WLAN LED active.

To switch the relay on and off at specific times is pretty straight forward.

Another part is to act on a button press. All that needs to be done is to check the current relay state and toggle it. On the S20 a blue LED indicating the relay state is automaticallly triggered too. Some people use the WLAN LED to display the state of the relay. In that case you need to adjust the rule.

See S20 rule for details. See switch rule for an example rules file for the Smart Switch that has only one LED. Use this rules and copy&paste them afer selecting the Rules link in ESPEasy (No link? See Configure ESPEasy basics).

Stichworte Deutsch

Zeitschaltuhr Timersteuerung

Clone this wiki locally