Skip to content

weigu1/garden_watering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Watering the garden with valves per MQTT over WiFi using an ESP8266

garden_watering

Some infos

The vegetable garden must be regularly supplied with water. To save water, I use drip hoses, and to simplify my life, I have automated the control of the irrigation.

It began with a command of a box with 5 magnetic valves from Hunter. The box contained 5 valves Hunter PGV 101 MMB (3/4", 25 mm). The valves need 24 VAC, so we need a transformer. As the valves are never open at the same time a current of 1 A should suffice. There are cheap relay shields out there with Optocoupler, perfect for this project. An ESP8266 (Lolin/Wemos D1 mini pro V2 ) connects us with the network over WiFi and MQTT and is used to send commands and get data. The ESP8266 board is also powered by the transformer. This is done with a LM2596 DC/DC buck converter breakout board.

As the whole thing is contained in a IP65 waterproof enclosure, I wanted to monitor temperature and humidity in the box and added a BMP280 sensor. A piece of PLA from my 3D printer created with FreeCAD (files on git) helped to connect everything together.

BOM

  • 5 valves Hunter PGV 101 MMB (3/4", 25 mm, 24 VAC)
  • Trafo 24 VAC
  • 8 Channel DC 5 V AC 230 V Relay Shield with Optocoupler
  • LM2596 DC/DC Buck Converter
  • Lolin/Wemos D1 mini pro V2
  • BMP280 breakout board
  • BOPLA ET-237 Euromas II, 200x120x90 mm³, IP65

Software

The software communicates per MQTT over WiFi. It uses my ESPToolbox library for WiFi and logging functions and to get the time. To avoid version problems the lib is included in the sketch folder. Programming is done over OTA.

We get two topics:

    String MQTT_TOPIC_OUT = "weigu/garden/watering/data";
    String MQTT_TOPIC_IN = "weigu/garden/watering/command";

Commands are in JSON and have the following JSON format (I eliminated the square brackets in the new version 1.1 because openHAB had problems with those when transforming):

    {"Relay_(0-4)":4,"Time_min":20}
    {"Auto_(0-1)":1} 
    {"Event_(nr_relay_start_duration)":"3 3 2021 5"}   

mqtt publish

  • With the first command you can start or stop manually the watering of a relay. Watering stops automatically after x minutes. To stop manually the time is set to zero: {"Relay_(0-4)":4,"Time_min":0}

  • The second command (version 1.1) switches automatic watering on (1) or off (0).

  • With the third command (version 1.1) we can also change via MQTT the watering events in the events array. Supported are up to 10 (0-9) events. Default are 5 events but you can add events in the config.h file. In the automated watering array we define the start times of a relay and duration of watering events. If we want e.g. that relay 3 opens at 15h15 for 15 minutes we add the line: {3,1515,15} to the array. With the command: {"Event_(nr_relay_start_duration)":"3 3 2021 5"} we can change this. The first number is the event number (0-9).

The following is seen on the data channel:

mqtt subscribe

In the new version (1.1) all relevant data you must or can change are in a config (config.h) file, also contained in the main folder. You can also place this file in the sketchbook/library folder named Secrets and rename it to your needs (e.g. secrets.h).

In the main file (.ino) you can activate or deactivate features by commenting or uncommenting some lines. Here you must activate USE_SECRETS:

In the config.h file, you must change the WiFi parameter and the MQTT server address. In the automated watering array we define the start times and duration of watering events.

Other things we perhaps want to change are the publishing interval PUBLISH_TIME or the MQTT topics.

About

Watering the garden with valves per MQTT over WiFi using an ESP8266

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors