Hydroponics, also known as soil-less farming is a concept popular these days. It is also called as 'The future of Farming'. It is the method of growing fruits and vegetables with help of water, hence Hydroponics. Hydro means 'water' and ponics means 'work'. So the 'water working'. This is true because the nutrients that are needed by plants for survival and growth is supplied by the water itself.
What Plants need?For proper growth of plants they require light, nutrients and proper temperature. These can be given to plants as per their needs. If we fulfill the parameter to just the right amount we get the maximum growth of the plant.
Automation in hydroponics can be done. It is difficult to automated the whole farm, but it is not impossible. We can also monitor the health of the farm by connecting the sensor data to the internet, so that we can check the farm even if we are far away.
NXP rapid IOT kit and AutomationNXP's rapid IOT kit is a good way to get basic knowledge in IOT and connectivity. In this project we are integrating NXP module with raspberry pi and then raspberry pi will send the data to the data base. Where we can monitor our farms health. We can also control our farms with help of IOT (which can be done in future project).
Connecting NXP module and Raspberry piNXP IOT module can communicate via Bluetooth, NFC and Thread. For our project we have connected the NXP module with raspberry pi via Bluetooth or BLE.
For using bluetooth, we have used the library
import pygatt
To initialize the GATT tool we have used
NXP = pygatt.GATTToolBackend()
The BLE or bluetooth address for every module is unique. The unique BLE code can be found at the back of the module.
BLE_address = '00:60:37:0A:B0:46' #Bluetooth address of NXP module
After this we need to get data in the raspberry pi via bluetooth. Each data or parameter have it's own unique key. This key can be found in NXP IDE in BLE section. Every data has it's own unique characteristic uuid which can be used to decode the data. The characteristic uuid can be see in the right middle.
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
We have used the next two lines of code to connect to the NXP module.
NXP.start()
dev = NXP.connect(BLE_address)
After the connection is established we need to get individual data from the module by using the uuid. The given line of code is to extract data and then unpack the data as it is encoded.
var_temp = dev.char_read(temp_uuid)
temp = struct.unpack('<f',var_temp)[0]
Connecting Raspberry pi to Mysql databaseAfter we receive data from individual sensor we have to send it to the database in form of MySQL request.
toMysql(light,temp,humidity)
The given function is used to push the the data to mysql
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
The toMysql is a function created to pass the data to the database. The url given in requests.post is the url to push the sql data to. (the url name have been changed for confidential purpose). You can even use your own url if you have created a webservice with php.
Connecting Raspberry pi and TwilioJust in case if we have a problem in the system or any parameter is too high we could get an emergency SMS. To integrate SMS with raspberry pi we have used Twilio sms service.
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") #Enter the message.
The above function can be used to connect twilio with raspberry pi. We can also apply some condition where we could get a message during if any parameters exceeds.
if temp > 40:
sms()
Here we get an sms if temperature is above 40 degree celcuis.
Future...?With increase in the tread in hydroponics farming, We also have to move up with the tread of technology. Technology such as IOT, Bluetooth and AI can be Incorporated in the hydroponics farm to improve the farm efficiency to its maximum. We have been working to bring automation in hydroponics farm and to connect farm to the internet for better monitoring and control.
Comments