Rushabh Jain
Published © GPL3+

Surveillance of Hydroponics Farm

A plant monitoring system which records light, temperature and humidity of the surrounding and the information can be displayed online.

IntermediateFull instructions provided4 hours1,864
Surveillance of Hydroponics Farm

Things used in this project

Story

Read more

Schematics

Automatic Hydroponics plant

Code

NXP

Python
import time
import pygatt
import twilio
import struct
import requests

#function to push data into database
def toMysql(light,temp,humidity):
    userdata = {"light":light, "temperature":temp, "humidity":humidity}
    requests.post('https://hydroponic.000webhostapp.com/testing/testPhp.php', params=userdata)  #Enter the url to push data to

def sms(): #function to send sms
    # Your Account SID from twilio.com/console
    account_sid = "Account_SID" 
    # Your Auth Token from twilio.com/console
    auth_token  = "Authentication_token"

    client = Client(account_sid, auth_token)

    client.messages.create(
        to="Receiver_number", #Enter the receivers number
        from_="Twilio_number", #Enter the number given by twilio 
        body="Warning!! \n Temperature too high")

NXP = pygatt.GATTToolBackend()

BLE_address = '00:60:37:0A:B0:46' #Bluetooth address of NXP module 

temp_uuid = '1305b3ca-096e-4366-9f68-1ae8df01f279' # temparature UUID
light_uuid = '1305b3ca-096e-4366-9f68-1ae8df01f27b' # light UUID
humid_uuid = '1305b3ca-096e-4366-9f68-1ae8df01f27a' # humidity UUID

try:
    NXP.start()
    dev = NXP.connect(BLE_address)
    
    while(1):
        
        var_temp = dev.char_read(temp_uuid)
        var_light = dev.char_read(light_uuid)
        var_humid = dev.char_read(humid_uuid)
        
        temp = struct.unpack('<f',var_temp)[0]
        light = struct.unpack('<i',var_light)[0]
        humidity = struct.unpack('<f',var_humid)[0]
        
        print(light,temp,humidity)
        toMysql(light,temp,humidity)
        time.sleep(5)
        
        if temp > 30:
           sms()
        
finally:
    NXP.stop()

Credits

Rushabh Jain

Rushabh Jain

10 projects • 43 followers
An engineer who loves to solve problems with technology. Expertise in Embedded firmware and software.
Thanks to Aditya Singh.

Comments