Code Monkey home page Code Monkey logo

water-system's Introduction

Garden Watering System Controller

This MicroPython project on an ESP32-C3 (SeeedStudio Xiao) uses weather API's to determine if significant rain has fallen in the last day, or is forecast today, and if so disables the garden watering system to conserve water. It reports the rainfall and system status to ThingSpeak.

The project is run off a single 3.3V 1600mAh LiFePO4 battery (18650) and uses the deep sleep mode of the ESP32-C3 to extend the battery life.

This controller is suitable for use with automatic watering systems which expose the ability to disable the system by making a connection open circuit.

MicroPython

The current release of firmware for the ESP32-C3; v1.9.1, does not support deep sleep. I built my own firmware using v4.4.3 of the ESP-IDF and the v1.9.1 tag of the Micropython with patch esp32c3_wakeup_ext.patch (from modmachine: Implemented GPIO wake-up for ESP32-C3) applied.

Schematic

If the schematic appears to be missing details, download it and view it locally, or zoom the web page.

Circuit Schematic

Container

I used a polycarbonate box with a build-in O-ring seal. A PTFE breathable vent was fitted to allow air, but not water vapor in and out. The electrical connections exiting the container to the watering system must be completely sealed.

Weather API's

All weather API calls and rain calculations are in weather.py, you will need to update the services called and the code used to extract data from the responses.

Usage

Configure a ThingSpeak channel something like:

ThingSpeak channel

Download the library:

  • urtc real time clock (RTC) library.

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'

HEADER = {'User-Agent': 'XXXX'}
LOCATION = 'lat=-XX.XXX&lon=YYY.YYY'

By default the RTC will wake the ESP32-C3 from deep sleep at 5am GMT every day, if you want a different time edit the value of the RTC_ALARM constant in config.py.

Copy all the python files to the ESP32-C3.

Set the 'No Sleep' DIP switch to 'on', press the RST button to reset the ESP32-C3, then connect using Putty or similar serial client and initialize the RTC by executing the following:

import wifi
import clock

wifi.connect()
clock.initialize_rtc_from_ntp()

# Get date time, to verify setting.
clock.timestamp()

Set the 'No Sleep' DIP switch to 'off', press the RST button to reset the ESP32-C3 and connect to your water system.

Retrieve System Log

Connect using Putty or similar serial client:

import water_system as w
w.init_ftp()

Then retrieve the log file using the ip address from above:

curl -v -O "ftp://<ip address>/system.log"

water-system's People

Contributors

chrisb2 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.