balcony watering system with raspberry pico w
Go to file
2023-07-01 05:23:49 +00:00
LICENSE Initial commit 2023-07-01 05:03:34 +00:00
Logger.py Dateien hochladen nach „“ 2023-07-01 05:04:15 +00:00
Networking.py Dateien hochladen nach „“ 2023-07-01 05:04:15 +00:00
NTP.py Dateien hochladen nach „“ 2023-07-01 05:04:15 +00:00
README.md „README.md“ ändern 2023-07-01 05:23:49 +00:00
TimeUtils.py Dateien hochladen nach „“ 2023-07-01 05:04:15 +00:00

raspberry-pico-balcony-watering

The goal of this project was to build an automated watering system for the vegetables on my balcony with soil moisture sensors. In addition, I included it into my home automation system FHEM.
You can manually turn on/off the watering pump, trigger a watering pulse (you can set the duration), turn on/off the automatic watering mode (this mode allows automatic watering, if soil moisture is below a threshold it triggers a watering pulse).
You can fully customize the parameters, for example the interval the system should read new soil moisture, what is the threshold for the soil moisture to be considered dry or wet

Setup

  1. Upload all *.py files to your Raspberry Pico W
  2. Set your wifi credentials in secrets.py file. Also set an api_key.
  3. Set values in configs.py file
  4. Be sure that you give your Pico W a static IP address on your router, so you know where the webservice is available and can configure it in FHEM

In the file configs.py set your configurations:
country: your countrycode (AT=Austria, DE=Germany...) (2-digit string)
ntp_host: set a ntp server (string url)
gmt_offset: offset to gmt for your timezone in hours (int)
auto_summertime: Enables changing to summertime (and back) automatically (True/False)
disable_wifi_powersavingmode: Wifi powersavingmode is enabled per default. Set to true to disable powersavingmode for Wifi (True/False)
api_port: Port on which the API is available (int)
log_housekeeping_days: Logfiles older than this value in days get deleted by housekeeping (int)
api_client_ip: Only this IP is allowed to use the API. Leave blank to allow all connections from all IPs (string)
pulse_duration: Duration of watering pulse (time between pump on and off) in seconds (int)
soil_moisture_measure_interval: Interval when to read new values from soil moisture sensors in minutes (int)
check_for_update: Interval when to check for OTA updates in minutes (int)
ota_host: Host for checking for OTA updates (http://ip-of-your-update-host) - leave empty to disable OTA updates

In the file secrets.py set your configurations:
ssid: Wifi name (string)
pw: Wifi password (string)
api: API key (string)

Hint: use openssl rand -hex 20 to generate the api_key

Hardware

Pico W API

You can configure the port, on which the API runs in configs.py in the 'api_port'-value. You also have to set an API-Key in secrets.py in the 'api'-value. Then you can call the API as follows:
http://servername/api_key/command[/json]

You can use the following commands:
wateron - Turns on the watering pump
wateroff - Turns off the watering pump
waterstate - Returns the state of the watering pump
waterpulse - Triggers the watering pump for the duration of pulse_duration (set it in configs.py)
autoon - Enables automatic watering mode
autooff - Disables automatic watering mode
autostate - Returns state of automatic watering mode
forcesoilread - Forces new readings from soil moisture sensors
waterlevel - Returns the level of the water tank
ping - Check if the API is up and running
stats - Returns some stats of the device
reboot - Reboots the device
logs - See logs of the device (you can add a number like .../stats/12 to see the latest 12 log lines) soils - See soil moisture of the device (usage like logs)

FHEM Integration