Rohan Jadhav
Published © GPL3+

Smart Plant Monitoring with SMS Alert: Keep Plants Hydrated!

Have a busy schedule? Worried if they wither? Then this project is just for you. Now you can keep your plants hydrated!

IntermediateFull instructions provided3 hours4,953
Smart Plant Monitoring with SMS Alert: Keep Plants Hydrated!

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Light Dependent Resistor Sensor
×1
LED (generic)
LED (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×4
Male/Male Jumper Wires
×4

Software apps and online services

SMS Messaging API
Twilio SMS Messaging API
ubuntu server

Story

Read more

Code

Source.py

Python
This is main source file. Run this to get the actual output.
#Source Python File

#Importing Files
import config
from boltiot import Sms,Bolt
import json,time

#Declaring the threshold values
threshold_light=1000
theshold_dmax=12
threshold_dmin=7

mybolt=Bolt(config.DEVICE_API_KEY, config.DEVICE_ID)
sms=Sms(config.SSID, config.AUTH_TOKEN, config.TO_NUMBER, config.FROM_NUMBER)

#function for led
def led(pin,value):
 response=mybolt.digitalWrite(pin,value)

while True:
 #Input from LDR
 response=mybolt.analogRead('A0')
 data=json.loads(response)

 #Input from Ultrasonic HC-SR04 Module
 response=mybolt.serialRead('10')
 data2=json.loads(response)
 print(data['value'])
 print(data2['value'])
 try:
  light_intensity=int(data['value'])
  distance=int(data2['value'])
  print(light_intensity)

  #Checking if it's daytime or Night time
  if light_intensity > threshold_light:
   #Checking if the Plants have water or not
   if distance > threshold_dmax:
    print("Its Sunny Daylight! Flower are dry with no water!")
    print("Pour water")
    response=sms.send_sms("Flowers will wither! Water required!")
    led('1','HIGH')
    led('3','LOW')
    time.sleep(10)
    led('1','LOW')
   else :
    print(Plants dont need water!")
    led('1','LOW')
  else :
   print("Shh! Its night time! Plants are sleeping! No need of water!")
   led('1','LOW')
 except Exception as e:
  print("Error", e)
 time.sleep(10)

config.py

Python
This is the config file for your bolt iot module and twillio.
#Config File

DEVICE_API_KEY='XXXXXXXXXXXXXXXXXX'
DEVICE_ID='BOLTXXXXXXXX'

#Twilio Sms
SSID='XXXXXXXXXXXXXXXX'
AUTH_TOKEN='XXXXXXXXXXXXXXX'
FROM_NUMBER="+XXXXXXXXXXX'
TO_NUMBER="+91XXXXXXXXXX'

ArduinoProg.ino

Arduino
This is the arduino file to get input from the ultrasonic sensor.
#include <BoltDeviceCredentials.h>
#include <BoltIoT-Arduino-Helper.h>
#include <Ultrasonic.h>

#define ULTRASONIC_TRIG_PIN 11
#define ULTRASONIC_ECHO_PIN 12

#ifndef API_KEY
#define API_KEY   ""
#endif
#ifndef DEVICE_ID
#define DEVICE_ID ""
#endif

Ultrasonic ultrasonic(ULTRASONIC_TRIG_PIN,ULTRASONIC_ECHO_PIN);
int distance=0;

void setup() {
  // put your setup code here, to run once:
  boltiot.Begin(Serial);
  Serial.begin(9600);
  boltiot.setCommandString("GetDistance",ultrasonic.distanceRead());
}

void loop() {
  // put your main code here, to run repeatedly:
 boltiot.handleCommand();
 Serial.println(ultrasonic.distanceRead());
 delay(1000);
}

Credits

Rohan Jadhav

Rohan Jadhav

1 project • 3 followers

Comments