esp8266 clock using Tasmota

I was looking for something else, and stumbled across an interesting post:

Tasmota is general purpose open source firmware for cheap Wifi capable microcomputer boards. A few bucks and a little software magic later you have something useful… like a clock.

Features:

  • Has NTP built in so it will automatically get the correct time
  • Changes when daylight savings time does
  • Adjustable brightness

The author used a D1 mini board, which I don’t have. I do have a hand full of extra esp8266 boards though. I looked up the documentation for the tasmota module:

https://github.com/tasmota/docs/blob/development/docs/TM163x.md

It documents the setup, wiring, and the commands needed to send the time to the board. It worked pretty much on the first try. I did have to hunt around for a USB cable that had the data wiring. A lot of the cheapo cables just carry power and dispensed with the other two wires.

You’ll also need the timezone table so you can set it up correctly:

https://tasmota.github.io/docs/Timezone-Table/

I need to print a case for it too, but there are quite a few free on the 3D models sites.

———— Update! —————

Finished it up with a case: 

———— Update! —————

One of the important tenets of Edge Computing is to push as much behavior off the server as possible. If the connection to the server is down the system should continue to work in a reasonable manner. I.E. if the internet is down you should still be able to turn the lights on and off.

I’d like to change the brightness down at night to save power and make it easier to sleep. So I’ll push that feature to the clock itself using Tasmota rules and timers.

Here’s the script to setup timers to change the brightness based on time of day:

(The ‘#’ denotes a comment. Don’t paste that into the tasmota console.)

# become a clock on boot up
Rule1 ON System#Boot DO DisplayClock 1 ENDON
Rule1 1

# setup timers. Normal sunrise is fine, enable timers
Sunrise 1
Timers 1

# set Timer2 to 10 minutes after sunset every day of the week, run a rule
Timer2 {"Enable":1,"Mode":2,"Time":"0:10","Window":0,"Days":"SMTWTFS","Repeat":1,"Output":1,"Action":3}

# set Timer3 to 10 minutes after sunrise every day of the week, run a rule
Timer3 {"Enable":1,"Mode":1,"Time":"0:10","Window":0,"Days":"SMTWTFS","Repeat":1,"Output":1,"Action":3}

# concatenate all the events into one rule
# turn brightness up 10 minutes after sunrise
# down 10 minutes after sunset
# down even more after 11pm ( 23 hours after midnight, 23 * 60 = 660 minutes after midnight)
Rule2
 ON Clock#Timer=2 DO DisplayDimmer 26 ENDON
 ON Clock#Timer=3 DO DisplayDimmer 44 ENDON
 ON Time#Minute=660 DO DisplayDimmer 13 ENDON

Rule2 1


Leave a comment