Electronics > Microcontrollers

ESP32 Automated Sprinklersystem Project

(1/3) > >>

After receiving a water bill for over $400 due to an under ground pipe rupture, I became motivated to re-design my outside irrigation system to ensure that such an incident would never again occur.  A simple evaluation of the existing system quickly revealed the shortcomings of the design.  It was an accident waiting to happen.  I can't rely on city environmental services to monitor stuff like this, even though its their job. We can do better.

   An overall plan is designed for the replacement of the existing system with a new automated system controlled by an esp32 incorporating both an electric ball valve as well as a water meter.  The basic plan is discussed.  The project however will need to be broken into smaller projects as separate libraries will need to be made for the valve and meter.

  An electrical design is made for functionality of the valve as well as signaling for the ESP32 so that software can be written around it.  A DPDT relay is employed, wired as a flip-flop for this unit.  With this a quick program is assembled just to check functionality of the relay and then power supply through the relay.  With this working, the valve is then tested.

  The library was built around the valve with features I felt would be beneficial toward the functionality if the valve.  It has already been published to Arduino and PlatformIO library manager. Simply search for Ballvalve in the library manager of the respective IDE and install.  Instructions are contained in the example code.

Next Step will be development for the water meter.

Were back in part two of the series continuing with the creation of a library that further supports hardware for the project and publishing it.  This time it will be the water meter which uses a combination reed switch and magnet to generate a pulse for measurement. 

  Understanding how this works means that I don't actually need the meter but can produce my own meter emulator to make this project easier.  In its simplest form, a contact with two wires should get me out the gates.

  I start off with my usual library creation with a getVersion, but in addition to it, an interrupt that checks to see if the switch was closed and notifies accordingly. Dirty but effective for testing. With this working I can expand upon the arguments with more parameters to provide more context as to what it means when the switch closes as well as some functions that provide some basic readouts.

  Now with a readout of both gallons and liters, touching the wires shows the increment as specified in the object creation.  This number is stored in memory but now we need the final feature and that s the ability to store the information to a file.  For this spiffs will be employed. 

  With spifffs a new function to initialize the file system is created, this is complimented with services to update that file for each event to align the mechanical value on the meter with that in the file itself. Final testing of this is done by pulling power.

  To test this all out a small project board is used with a DC motor and a few batteries along with a POT to generate this signal on a reed switch with a magnet to emulate the meter for software testing.

We now arrive at the third chapter in the series. The first two were dedicated to the development of libraries for hardware needed for the project.  With libraries completed for the water meter and the valve we can continue designing the architecture that ties everything together while incoperating the quad relay module into our to be developed sprinklersystem library  a small support application will be written along with this activity.  It stands to reason our sprinklersystem library and overarching project will depend upon the two libraries created in chapter one and two, they will be included in the library for sprinklersystem and compiled in. 

  As there is no vectoring in esp32 an array will be created to store zone objects called storedzones, allowing for easy manipulation addition and removal of zones form the sprinklersystem object.  the array can handle 30 zones which is way overkill but acceptable.  Each zone has attributes that I mad add remove or change later in development, but this will get us off the ground.  Attributes from the valve and meter are already defined and probably wont change much.

  Within the sprinklersystem class, the overarching object is the class Zone and its attributes, as well as the zone array itself with associated helper functions, open close remove, and whatnot. The is no function to add sprinklersystem the app were creating does that.  The addzone function provides an opportunity to allow for any required validation of supplied parameters as demonstrated.

  The main program provided is simply a demonstration to create an object and demonstrate all of the functionality thus far.  This includes bad data to demonstrate errors.

While i think this might be an interesting project , if not for other then for the water waste detection.  :-+
I'm much more of a "Webpage" guy than youtube guy.

I have always lost interest fast in youtube videos describing a project,.
I like "letters" for tech documentation , and being able to set my own read pace.

But thank you for sharing  :)


You may want to add a normally open water valve on the main water input to the sprinkler system.  I did a project similar to this and came home to find a small pond in the yard because a relay stuck in the ON position.  Decided to use a NO valve connected to a separate controller that works as a watchdog for the system.  If it doesn't receive regular OK input from the main controller it turns off all water to the system until reset.   It should catch any issues with relays, sprinkler valves or controller issues.


[0] Message Index

[#] Next page

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod