Plant-Sitter

by yspinzi in Circuits > Arduino

237 Views, 0 Favorites, 0 Comments

Plant-Sitter

FLOW.png
Plant-sitter

This is a DIY guide for making an advance plant monitoring system that includes:

  • Email notifications about your plant
  • Show you a colorful live preview of the plant and its condition
  • Show you a dashboard with information about the current temperature near the plant, how much water and light it has
  • Make the plant say “water me" when its thirsty
  • Blue lights water bar to indicate how much water the flower has

*NOTE: attached to some steps are the relevant code files in the text format. You could also use the following link to see the full project in GitHub: https://github.com/idolevitt/plant-sitter

Supplies

WhatsApp Image 2022-02-09 at 16.24.36.jpeg
  1. Adafruit circuit express
  2. Esp 8366
  3. Flower planted in dirt
  4. Some sort of uncoated conducting wire

Building the Skeleton That Allows Running All Features Together

This part is the ‘main’ of the code. This is where everything begins.

First it runs setup in order to connect to all interfaces (Wi-fi, Servers…) and the enter ‘loop’ that allow each feature to be timely activated by gap times you choose (for each one).

 

Note: feel free to prepare only the structure itself and in each step come back and fill in only the current feature’s parameters and invocation.

Create a Header File That Connects to Wi-fi

It is a short step that requires a simple connection code (just use ours..) and fill in relevant Wi-fi identifiers.

Connect the CPX Board to the ESP8266

Integromat

integromat.png

This part of the code integrates with integromat.

What we need to do is simple:

1.    Create an account at www.integromat.com

2.    Create a new Scenario

3.    Add a Webhooks module (this is a module that will listen to our https requests)

4.    Add a Gmail or any other mailing app to the flow (this stage might require extra configuration- Integromat will assist you with the relevant manual)

5.    Fill in the mail details and contents with the rules you would like (if/else…).

6.    Click on the clock icon at the bottom left and set up a scheduler (we recommend no more than once every 4 hours so you won’t get spammed by your flower)

*note: the scheduler should be scheduled during daytime, because we’re checking the light in the room

 

After you configured Integromat it should look like the picture above.

The next step in the Integromat integration is creating a Blynk web hook to send the https get request to the Integromat webhook.

In order to do so you need to create a webhook widget on Blynk that listens to a virtual pin.

Now, when everything set up, add a header file in your Arduino code that will trigger the virtual pin the Blynk is listening to.

Web Dashboard

results.png

In steps 5-8 we are going to build the web dashboard.

We’re gonna do some drawing, editing and writing some code in HTML, JavaScript and CSS, So get your artistic skills warmed up!

1.png

Draw the following: happy flower, thirsty flower, hot temperature, cold temperature, sun and moon(you can use our drawings, added to the article)

2.png

Edit the images using any editing software to remove the background (we worked photoshop).

Note: save them as .png so the background would stay transparent.

  1. Build an HTML and CSS scripts to preview the dashboard as you like
  2. Build a JavaScript code that will make the code refresh every couple of minutes (so the dashboard would update if there is a change in the plant state) and make the sun and moon rotate around the flower according to the time of day.

Build a Local Server That Listens to the Cpx and Updates the Web Dashboard

1.    Create a project in whatever language you fill most comfortable (python, java, C#...)

2.    Create a skeleton file for the html code:

copy of the html file you created to a text file in the project, and change the flower and temperature images source names to something indicative.(so the server will create the new html file from the skeleton and replace the content of the old HTML file)

3.    Create Server: create a http listener in the language you are working with,

once a request has being received the handler would parse the parameters and update the html code accordingly

Create a Header File That Sends Http Requests to the Local Server

Create a header file that sends http requests with the parameters you configured in the local server handler, that indicates whether the plant is happy/ thirsty and cold/ warm.

Create a Header File With a Function That Makes the Cpx Say “Water Me!”

Downloads

Create a Header File With a Function That Make the Light of the Cpx Update With Accordance to the Amount of Water the Cpx Has

Create a Header File That Communicates With MQTT Web Dashboard Using Io.adafruit

5.jpg

1. Create your customed web dashboard:

  • For each parameter create a feed + one for the SOS button
  • Create a new dashboard and place new blocks however you like

(you can see an example for a dashboard below)

  • Make sure each block is connected to the right feed

2. Create header file:

  • Make sure you create a variable for each path of a feed
  • File should contain: Setup (connection to MQTT server), MQTT Callback method to allow receiving information from the dashboard (i.e. activating SOS button) and a publisher method for each parameter that is shown in the dashboard. All implementations can be found in the file below.

Downloads

Additional Useful Code

  • finalProject - Manages the project's flow
  • Defines_and_inclusions - defines that are bound in one file
  • ConnectToWifi - Module that connects to wifi
  • statsCalculator - Calculates normalized sensor indices