Plant Monitoring
![IMG_1529k.JPG](/proxy/?url=https://content.instructables.com/FIL/ETF3/KY79PR89/FILETF3KY79PR89.jpg&filename=IMG_1529k.JPG)
![IMG_1521k.JPG](/proxy/?url=https://content.instructables.com/FVE/VJM0/KY79RS6C/FVEVJM0KY79RS6C.jpg&filename=IMG_1521k.JPG)
![IMG_20220110_121525_1k.jpg](/proxy/?url=https://content.instructables.com/FVZ/WW6S/KY79RQYO/FVZWW6SKY79RQYO.jpg&filename=IMG_20220110_121525_1k.jpg)
A microcontroller based little tool was created that gives a feedback, weather the plants need watering or not, it also sends these information to a home server, that is attached to the same Wifi network.
Supplies
The used items:
- Wio Lite W600 - ATSAMD21 Cortex-M0 Wireless Development Board
- Grove Shield for Wio Lite
- 2 Grove Soil Moisture Sensors
- Grove - 16x2 LCD (White on Blue)
- grove cables
- recycled transparent plastic pill bottle
- 5V 2000mAh power bank, or 5V adapter
- USB-C cable
- some bolts and nuts to fix
Assamble Circuit
![plant mon.JPG](/proxy/?url=https://content.instructables.com/F09/WYSM/KY79Q6NL/F09WYSMKY79Q6NL.jpg&filename=plant mon.JPG)
The above circuit was assembled .
Assamble Tool
![IMG_20220110_111154_5k.jpg](/proxy/?url=https://content.instructables.com/FY6/FTMS/KY79RQZ6/FY6FTMSKY79RQZ6.jpg&filename=IMG_20220110_111154_5k.jpg)
The elements of the circuit was placed and fixed in the plastic pill bottle. A hole is needed in the top for the wires.
Code Preparation
Before uploading the code in Arduino IDE, Seeed SAMD boards should be installed. Instructions can be found here: https://wiki.seeedstudio.com/Wio-Lite-W600/
The installation of a few libraries are necessary too:
- Seeed Arduino W600 Master
- Arduino
- Wire
- Grove lcd rgb
For upload the Seeeduino Zero board among the Seeed SAMD Boards have to be selected as board type.
Upload Code
/*Plant Monitoring eng 1.0 VI 2021*/ #include "w600.h" #include <Arduino.h> #include <Wire.h> #include "rgb_lcd.h" #define WifiSerial Serial2 //serial number of seeeduino_zero (compatible with Wio Lite W600) #define SERIAL Serial #define debug SERIAL rgb_lcd lcd; AtWifi wifi; const char *TARGET_IP = "\"192.168.0...\""; // This is the IP address of the server uint16_t TARGET_PORT = 8080; uint16_t LOCAL_PORT = 80; int socket = -1; int connect_to_AP(int retries){ bool ssid_set = false; bool psswd_set = false; bool joined = false; int attempt = 0; debug.println(F("setting ssid ...")); while (!ssid_set && attempt < retries){ ssid_set = wifi.wifiStaSetTargetApSsid(F("YourSSID")); //type the access point name here delay(150); } if (!ssid_set){ debug.println(F("failed to set ssid")); return 0; } attempt = 0; debug.println(F("setting password")); while (!psswd_set && attempt < retries){ psswd_set = wifi.wifiStaSetTargetApPswd(F("YourPassWord")); // type the access point password here delay(150); } if (!psswd_set){ debug.println(F("failed to set password")); return 0; } attempt = 0; while (!joined && attempt < retries){ joined = wifi.sendAT(F("AT+WJOIN")); //join network delay(1500); } if (!joined){ debug.println(F("failed to join network")); return 0; } debug.println(F("connected to AP")); return 1; } int create_socket(int retries){ int socket = -1; for (int attempt = 0; attempt < retries; attempt ++){ debug.print(F("Creating socket to remote server, attempt:"));debug.println(attempt+1); socket = wifi.wifiCreateSocketSTA(TCP,Client,TARGET_IP,TARGET_PORT,LOCAL_PORT); if (socket >= 0) { debug.print(F("connected to remote server. Socket="));debug.println(socket); delay(400); return socket; } delay(1000); } debug.println(F("failed to connect to remote server")); return socket; } void configure_wifi(int retries){ for (int attempt = 0; attempt < retries; attempt ++) { debug.print(F("Configuring wifi, attempt:")); debug.println(attempt + 1); wifi.sendAT(F("AT+Z")); //wifi_reset delay(1500); if (wifi.wifiSetMode(STA)){ debug.println(F("wifi configured")); delay(100); return; } } debug.println(F("wifi configuration failed")); } void setup() { debug.begin(115200); wifi.begin(WifiSerial,9600); configure_wifi(5); connect_to_AP(5); socket = create_socket(5); lcd.begin(16, 2); // set up the LCD's number of columns and rows lcd.print("Starting..."); // Print welcome message to the LCD delay(2000); lcd.clear(); } void loop(){ float moist1 = analogRead(A0); Serial.println("Moisture, palmtree: "); Serial.println(moist1); if (moist1 > 300){ Serial.println("Palmtree is OK."); lcd.setCursor(0, 0); //set the cursor to column 0, line (note: line 1 is the 2nd row, counting begins with 0) lcd.println("Palm: Alright."); char info1[] = ("MESSAGE The soil of the palmtree is OK."); //MESSAGE is indicating the data type to be sent wifi.wifiSocketSend(socket, info1); } else if (300 >= moist1){ Serial.println("Irrigation of the palmtree is required!"); lcd.setCursor(0, 0); lcd.println("Palm: Irrigate!"); char info1[] = ("MESSAGE Irrigation of the palmtree is required!"); wifi.wifiSocketSend(socket, info1); } float moist2 = analogRead(A1); Serial.println("Moisture, avokado: "); Serial.println(moist2); if (moist2 > 300){ Serial.println("The soil of the avocado is OK."); lcd.setCursor(0, 1); lcd.println("Avok.: Alright."); char info2[] = ("The soil of the palmtree is OK."); //2nd part of the message wifi.wifiSocketSend(socket, info2); } else if (300 >= moist2){ Serial.println("Irrigation of the avocado is required!"); lcd.setCursor(0, 1); lcd.println("Avok.: Irrigate!"); char info2[] = ("Irrigation of the avocado is required!"); //2nd part of the message wifi.wifiSocketSend(socket, info2); } debug.println("Message is sent."); delay(10000); }
Final Step
![IMG_1526k.JPG](/proxy/?url=https://content.instructables.com/FF4/L3VD/KY79RFFR/FF4L3VDKY79RFFR.jpg&filename=IMG_1526k.JPG)
After upoding the code place the moisture sensors into the pots of the plants and connect the gadget to a 5V powerbank or adapter, and let it run!