- Thu Nov 01, 2018 5:24 am
#78970
I have lots of ESP8266 devices that I turn on/off at various times, but none of them have any idea what the current time i is.
I use a Raspberry Pi as the heart of the system, and it does know what the current time is. It can synchronise with an NTP clock if one is available, but runs quite happily, and accurately, for long periods without one. In your situation, you may want to add a small ‘UPS’ type device to the Pi so that it keeps running if the power goes off. A small power bank designed for mobile phones is ideal for this.
The Raspberry Pi runs Node-Red and an MQTT broker called Mosquitto, the timing/scheduling is done with a node called Big Timer by Peter Scargill. As well as turning devices on or off at specific times, Big Timer can operate devices based on dawn or dusk times (with an offset if needed, so you can turn lights on x minutes before dusk, and off again y minutes after dawn). It’s simple to override the schedule too, or suspend it for a given period of days.
The ESP devices run a very simple MQTT client that connects to the Pi and listen for instructions sent as MQTT messages. These can be specific to one device, or apply to a group of devices. The devices can also send messages back as confirmations, or even feed data like temperature and humidity back to the Pi via MQTT messages.
All of this works fine without any internet connectivity, provided your Wi-Fi is still up and running.
It might sound like a bit of an overkill for what you’re trying to do, and a bit of a steep learning curve, but it’s actually quite simple, and relatively cheap, to get up and running.
Pete.