Water management controler
Create a local conf.h
based off of conf-example.h
Install PubSub Client
On arduino ide, goto tools -> Library Search for pubsub Installed v2.8
Create a user and ACL for the user
Type | Pattern | Read Write |
---|---|---|
Topic | user - # | true /true |
docker build --pull --rm -f "dockerfile" -t trykle:latest "."
docker run -it --rm trykle:latest
# docker run -it --privileged -v /dev:/dev --rm trykle:latest
# docker run -it --privileged -v /dev/bus/usb:/dev/bus/usb --rm trykle:latest
docker run -it --privileged --device="class/DCDE6AF9-6610-4285-828F-CAAF78C424CC" --rm trykle:latest
arduino-cli core install esp8266:esp8266
arduino-cli core list
arduino-cli compile --fqbn arduino:esp8266:esp8266 MyFirstSketch
Main loop code
do_setup() Clear watchdog flag os.begin() os.optinos_setup() pd.init9) prograData init Real time clock sync Set last startup time Start network Sync ntp mqtt init reset all stations
do_loop() check flow Check ethernet packets Check State (AP mode or not) if inital. Set ap mode. start_server_ap if connecting. start_server_client, or timeout if connected. wifi_server->handleClient() or reboot, or timeout ui_state_machine() os.mqtt.loop() Check rain delayed Check soil sensor Check program Switch status (Stop all, manual start) Check if need to run a program based on current time ensure station has non-zero time and is not disabled Enqueue a program if match Check time for any running programs to stop them os.apply_all_station_bits() Activate / deactivate valves Sync time check_network check_weather
The Real time clock runs on the I2C protocol
The device address is 0x68
There are 13 registers
Real Time Clock Ic^2 signal
To read, it looks like you have to write the device address and the regsiter address, then read
The data is coded in binary-coded decimal (BCD)
Device Address Based on teh A0-1 pins
0 | 0 | 0 | 0 | 0x20 0 | 0 | 1 | 1 | 0x21 0 | 1 | 0 | 2 | 0x22 0 | 1 | 1 | 3 | 0x23 1 | 0 | 0 | 4 | 0x24 1 | 0 | 1 | 5 | 0x25 1 | 1 | 0 | 6 | 0x26 1 | 1 | 1 | 7 | 0x27
Register Address
Address | Access to |
---|---|
00h | IODIR |
01h | IPOL |
02h | GPINTEN |
03h | DEFVAL |
04h | INTCON |
05h | IOCON |
06h | GPPU |
07h | INTF |
08h | INTCAP (Read-only) |
09h | GPIO |
0Ah | OLA |
Opensprinkler code: