Skip to content

Latest commit

 

History

History
142 lines (95 loc) · 6.15 KB

README.md

File metadata and controls

142 lines (95 loc) · 6.15 KB

Simple raspberry pi pico irrigation controlled via HTTP.

Alt text

1. General notes:

a. More fun projects: https://pico.otilia.dev/

b. This is controlled via telegram. (a listener to web buttons then makes HTTP requests, will share the repository later, ping and I can speed it up if you're curious)

2. How it looks

2.1. Videos in action

2.2. Cover open and all pieces visible:

Alt text

2.3. Wires without without fiberglass sheathe:

Alt text

2.4. USB cable connector

Alt text

3. Components used:

Items below are listed for completeness and were used mostly because I already had them, there are simpler alternatives if starting from scratch.

3.1. Main black box:

Box: https://www.amazon.nl/-/en/Distributor-Waterproof-Surface-Mounted-Junction-Diameter/dp/B0BQBP43H2/

Logic:

goodies:

3.2. Power supply/cable:

3.3. Solenoid valves and hookup:

Notes:

  • should use the solid core wires from 1 to extend wires from solenoids.
  • Use the rubber rings on all connections to avoid water leaking
  • Water hammer arrestor is IMPORTANT - you don't want to destroy pipes when switching via solenoid.

4. Software

You should copy over all files in "src/base/" and "src/derived" on the pico in "/" directory. To get callstack when exceptions are reported you need a custom compiled micropython. https://github.com/AdrianCX/custom_micropython It will work with official micropython, you just won't have full callstack.:

Logic is as follows:

  1. src/base - common server components that can be reused for other projects
  • board initialization - config, wifi, http listener.
  • logger - send any logs from system over UDP to a remote host.
  • upload/download APIs - so we can change files remotely if we want to add functionality or fix bugs
  • status API - quick glance over system and any problematic exceptions
  1. src/derived - irrigation system logic
  • safety.py - needed by "base" - item imported on boot - initialize environment (stop water flow for example)
  • derived_logic.py - main logic for HTTP handling
  • irrigation.py - GPIO and utilities for handling solenoids

5. Debugging

Change config.ini UDP_IP/UDP_PORT to point to a machine where you can run netcat on and start up netcat:

root@kube:~# netcat -ukl 51001

227933 Logger.Update() Status: OK
235968 MainLoop.update() green button pressed
238100 MainLoop.update() red button pressed
238205 Logger.Update() Status: OK
247058 MainLoop.update() buttons 1 1, battery: 45259
248280 Logger.Update() Status: OK
250271 MainLoop.handleOpen() duration: 30
258313 Logger.Update() Status: OK
268392 Logger.Update() Status: OK
278471 Logger.Update() Status: OK
280505 MainLoop.update() Irrigation shut off due to timer

6. APIs available:

See "scripts/" folder for wrappers over each API.

a. GET /api/open/{timeSeconds}

Open up all pipes and keep them open for "timeSeconds"

b. GET /api/close

Close all pipes.

c. POST /sys/upload/{filename}

Write body to the given filename

d. GET /sys/read/{filename}

Read data from given filename

e. POST /sys/restart

Soft restart - useful after uploading files.

f. GET /sys/status

General system status