Skip to content

VEZY/Plant_watering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌊🌳 Autonomous plant watering system

Introduction

This project presents a smart autonomous plant watering system. The system is autonomous in energy using a 12v battery and a solar panel, and water the plant when the right conditions are all set, with a well thought (I hope) fail-proof system. It is smart because it communicates with the user(s) through the Telegram app.

The steps followed by the system are as follows:

  • the soil water content is always monitored;
  • if the soil water content is below a certain value (max_soil_moisture), the system:
    • (🔔) checks the water tank is not empty (and during) the watering event to avoid any damage to the pump running dry;
    • (🔔) checks the minimum water period between two watering events is exceeded. This is done to avoid watering the plants too many times during the day (better have a little dryness at some point), and to add some safety in case the soil moisture sensor is broken;
    • (🔔) start the irrigation ;
    • stops the irrigation whenever:
      • (🔔) the soil water content reaches a certain value (max_soil_moisture) or;
      • (🔔) the water tank is empty, in which case irrigation will resume as soon as it is filled again, or;
      • (🔔) the watering duration exceeds the maximum duration allowed for each watering event (watering_max_time). The aim here is to avoid running the pump until the water tank is empty if there is a leak in the system that would prevent the soil moisture to increase;
  • (🔔) checks that plants are watered at least every given period of time (max_wo_water), to avoid them to die if e.g. the soil moisture sensor is broken and return always high values ;

The user is notified by Telegram messages at every important step (denoted 🔔). The user can also trigger manually an irrigation event from Telegram, even if the soil water content is higher than the given value (max_soil_moisture). It is also possible to turn the whole system ON and OFF, ask if the system is up and running, or ask the current value of the soil water content.

Telegram snapshot

When you go out for vacations, simply add a friend to the Telegram group so they know when to visit your house to fill up the water tank!

Set up yours

To reproduce this project, you'll need some tools, some material, and the code from this project.

Code

To get the code from this project, either clone it (or better, fork it) using GIT, and if you don't know what GIT, clone and fork means, simply download it on your computer using this link 😺.

Then, configure it to your needs !

To use Telegram, the NodeMCU needs to be connected to the internet. I did it using its WIFI module and my home WIFI. To configure your own connection, open the plant_watering.ino script in Arduino IDE, and fill-in the missing values for your wifi credentials (I'm assuming you have WiFi):

String ssid  = "xxxxx"; // Name of your Wifi
String pass  = "xxxxx"; // Wifi Password

Then, we'll set up a Telegram bot, which is an user account a little like you have, but actually run by a robot (your NodeMCU). To do so, follow the steps described here. In few words:

  • Open Telegram (and connect with your account);
  • Create a new bot:
  • Search BotFather in your contacts (type it in the search bar), and open a conversation with it (as you'd do with any new contact);
  • Type /newbot in the conversation (watch for the case and include the /!)
  • Name your bot as you want, but end it with "bot" (e.g. "watering_balcony_bot");
  • Botfather gives you a bot token, keep it very secret (don't share it using GIT!!), we'll use it in few steps;
  • Search it in your contacts, and send it this message: /start
  • Copy the token returned by Botfather and paste it on your plant_watering.ino script here:
String token = "xxxxxx:xxxxxxxxxxxxxxxxxxxxxxx"; // Telegram bot token

Your bot is now alive !

To give it the ability to communicate with you, it needs to know your conversation ID. Because we want to be able to share what the bot is saying with other people in case we go out in vacation, I prefer to create a group chat instead. So create one (New Group), add your bot by searching its name, and add a third bot named IDBot temporarily. Then name your group chat as you want. Open your group chat, and type /getgroupid. IDBot will return a number such as -xxxxxxxxx (don't forget the minus when you copy it!), that's your group chat ID!

you can also ask /getid to get your personal ID, so your bot will send messages directly to you instead (not sending it to the group)

Copy the ID, and paste it on your plant_watering.ino script here:

int chatID = -000000000; // This the ID of your group chat

Paste the /getid here instead if you want the bot to send messages directly to you

Then, remove IDBot from your group just in case (we don't want any data leaked).

For the last step, you'll need to install the CTBot and ArduinoJson libraries. To do so, type ctrl+maj+I, search CTBot, and search for CTBot by Stefano Ledda, and click install. Then repeat for ArduinoJson, and search for ArduinoJson by Benoit Blanchon, but install the version 5.13.5 for now because CTBot is not compatible with the sixth version yet (you can check here if there are any changes).

And that's it, your code is ready ! Now you can upload it to the NodeMCU! If there are some errors, check that you selected NodeMCU 1.0 as the board type, and that you use the right version for your libraries.

Tools

The tools are very simple, I used for this project:

  • A soldering iron + tin (e.g. 220V 60W);
  • A multimeter (mine is a TackLife DM01M);
  • A flat screwdriver (tiny is better);
  • Cutting pliers;

If you have them you can also add some wire strippers, but they are not indispensable.

Material

Here is a list of the products used to build the system. I must say that I don't receive any incentives from Amazon, from which all products were bought.

To control the system:

For the autonomy in energy:

For the water tank:

The sensors:

And the irrigation system:

For a total of 237.40€. That's not cheap! But keep in mind that it's still cheaper than a pre-built system, and with a lot more capabilities! Also, some parts are only for prototyping (15.98€), and I purchased many components in groups of several pieces for other projects, e.g. 525 resistors is a crazy amount 🤪, you don't need 3 NodeMCU boards, nor 6 relays for this project.

Assembly

You can find the assembly of the parts using Fritzing to open the Fritzing project in this repository. Here is a view of the whole schematic:

Breadboard view

NB: the NodeMCU is connected to the solar charge controller by a USB cable (the one in the schematic does not have one). See the Material section for an example of a solar charge controller with a USB.

I made all custom parts available in the fritzing folder (all can be found on the internet except the water floater because I made it).

Acknowledgements

I would like to acknowledge my wonderful partner that let me do this during the weekends! And of course all the makers that made the project possible, such as @shurillu for the super CTBot library, EstebanP27 for his tutorial from which I learned a lot for this project! I would also like to thanks svgrepo from which I used SVGs as a basis for the logo.