-
1Install Loboris Micropython for ESP32
The code depends my personal fork of Loboris Micropython for ESP32 which contains some improvements to the requests library. You will need to build and flash this as described in Build Micropython for ESP32Build Micropython for ESP32, substituting the clone URL with that for my repository.
-
2Configure Thingspeak
Configure a ThingSpeak channel something like:
-
3Obtain RTC Library
Download urtc real time clock (RTC) library.
-
4Create python file configuration file
Create a file called secrets.py and fill in appropriate values:
"""Secret values required to connect to services.""" WIFI_SSID = 'XXXXXX' WIFI_PASSPHRASE = 'XXXXXX' THINGSPEAK_API_KEY = 'XXXXXX' WUNDERGROUND_API_KEY = 'XXXXXX' WUNDERGROUND_STATION = '/NZ/christchurch' WUNDERGROUND_LOCATION = 'zmw:00000.7.93781'
-
5Update wakeup time
By default the RTC will wake the ESP32 from deep sleep at 5am GMT every day, if you want a different time edit the value of the RTC_ALARM constant in water_system.py.
-
6Copy application python files to ESP32
Copy all the python files to the ESP32; urtc.py, secrets.py and all the python files from the github project
-
7Initialize and install system
Set the 'No Sleep' DIP switch to 'on', press the RST button to reset the ESP32, then connect using Putty or similar serial client and initialize the RTC by executing the following:
import wifi import water_system wifi.connect() water_system.initialize_rtc_from_ntp() # Get date time, to verify setting. water_system.datetime()
Set the 'No Sleep' DIP switch to 'off', press the RST button to reset the ESP32 and connect to your water system.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.