-
Simple circuit to allow ESP-01 to control a pair of relays
06/30/2017 at 12:30 • 0 commentsThis project will use a circuit that I often use. It allows an ESP-01 to control a pair of relays.
Some issues to note
- The ESP-01 and the relay board are driven from a 4-volt supply. Even though the ESP-01 is rated for maximum 3.6v and the relay board is rated at 5v, I find that they both behave well at 4v. This means that I only need a single power supply.
- The ESP-01 has two GPIO pins available for use, but these must be pulled up with resistors to boot into run mode. This is why the two resistors are shown in the circuit.
- I actually only need one relay, but I have loads of these 2-relay boards. So it's not worth my while to buy a single-relay board. If you wish to use a single-relay board, you can remove the resistor R2 and connect GPIO-2 directly to 4v.
- The duplicated GND and 4v for the relay are for an odd reason. I have a selection of relay boards, and they randomly mix up the ground and power pins. So I have allowed for both combinations to be connected without crossing wires.
-
Software is updated to add more flexibility
06/27/2017 at 14:06 • 0 commentsI have been flooded with requests for different variants of this project. Some people want to follow a sunrise/sunset schedule. Some want to turn the lamp off in the middle of the night. Some want a different type of schedule completely.
To answer all of these requirements, I have moved away from the idea of following sunset and sunrise. Now I have only the concept of turning the lamp on once per day and turning the lamp off once per day.
To do this, I have defined a file (lamptimes.txt) which lists the daily on-time and off-time, for example
14 Mar 1837 0651 15 Mar 1839 0648 16 Mar 1840 0646
This means that the user can define any type of desired schedule, as long as it is only required once per day.
Next step is to tackle the hardware. Shouldn't be too difficult !!!
-
New revision of software works better offline
06/16/2017 at 12:40 • 0 commentsThe software is updated to remove the need to fetch the sunset time from sunrise-sunset.org. This means that the software will continue to run for years in the future, even if this API is removed.
The software now reads a file (sunset.txt) to find the sunset time for each day. The current date/time is fetched from google.com. Let's hope that google.com will still exist in years to come!
-
First version of software is now complete
06/15/2017 at 14:25 • 0 commentsThe first version of the software is now complete and has been tested.
The software has 3 main functions...
- Fetch the current time, sunset time, and solar noon time from the internet.
- Calculate how long until the next sunset and next solar midnight.
- Turn on the lamp at sunset and turn it off at solar midnight.
The most important aspect of the software is that it should continue to work even if internet connectivity is lost. Every 10 minutes, the times are refreshed from the internet. Even if this fails, the internal clock will continue to run, and the cycle will be repeated every 24 hours until the refresh from the internet is successful.
After a power failure, the program will wait for 30 seconds (init.lua) to allow internet conntivity to be restored. The the main program (suntracker.lua) is launched. The lamp defaults to ON, and will remain ON until a valid shedule has been downloaded from the internet.
Next step is to tackle the hardware...