The hardware prototype is described on hackaday.io: Sun Tracker prototype
The hardware schematic is the following:
In the loop():
- change LED blinking according to WIFI status
- read the settings (max_error, sensitivity, update_period, start_time, stop_time) and apply them to the SunTracker object
- call:
- LED_loop
- SunTracker.loop (only if now time is inside start_time and stop_time)
- AutoConnect loop
- config the local time (by NTP) using the TimeZone (at any time Internet is newly available)
- enable / disable the sun tracking according to start_time and stop_time. It works only if the local time was set by NTP at least once after reboot.
See also AutoConnect by Hieromon
- Automatically start a WIFI hostpot (ESP32 softAP) with a captive portal at first run of if there's no connection to a WIFi hotspot
- Let to connect to a WIFI hotspot
- Reconnect in case of reboot or connection lost
- Let to change settings with a web interface
In its constructor receives the pins where:
-
PDR1, PDR2, RELE1, RELE2, RUNEND1, RUNEND2 are connected
-
Read the two photo resistors: PDR1 and PDR2
-
Check if the average of PDR1 and PDR2 values is above the minimum required (sensitivity)
-
Compare their values with max_error
-
Activate the two relays to rotate the DC motor to a new position in which abs(pdr2-pdr1) < avg(PDR1,PDR2) * max_error/100
-
Stop both relays if one of the End-Of-Run is reached (closed)