Due to the increasing demand in the food supply, the production of perishable goods such as fruit and vegetables continues to rise. Cold rooms are very important because they help to prolong the shelf life of fresh goods. I have developed a system that will ensure the Lighting and temperature of Cold Storages. Light and Temperature are two important factors that determine the quality and long life of stored food.1. Hardware Connections
Here, I have made a parallel connection of LDR (Light Sensor) and LM35 (Temperature Sensor), so they can sense values independently, however you can also connect them in Series.
Since Bolt Wifi Module has only one Analog pin, System will measure analog values of Temperature, however LDR will only sense where light is on (value: 1) or off (value: 0).
- Connect Supply Voltage end of LM35 to 5v, Output Voltage end to A0 (Analog pin) and Ground Pin to GND.
- Connect one end of LDR to 3v supply and another end to GPIO on Bolt Wifi Module. (Note: There are 5 GPIOs on Module) Also, connect one end of a resistor with GPIO and other to GND.
- Now connect longer leg (positive) of LED to GPIO and shorter one (negative) to GND. Similarly, you can connect Buzzer (optional)
- Now you are good to go to connect Module to Power Supply.
- I have done coding in Linux Terminal on Windows. (Available only in Windows 10) However, you can do it by either Digital Ocean or VM.
- To create or edit file command: sudo nano <filename with extension>
- To run python file, python <filename>.py
- First, you need to create account on Twilio.
- Then create a configuration file, which contains SID, Authorized Token, From Number, To number, API key, Device ID. API key, Device ID you will get from BOLT Cloud Dashboard. Other details you will get after signing up in Twilio.
- Make sure your configuration details are valid.
- Now open new file and start writing code for system, which include importing necessary header file.
- If Bolt python library is not installed, first write pip install boltiot on terminal.
- json is a python library used for handling all operations on JSON objects. JSON is nothing but a data communication format widely used on the Internet for sending/receiving data between a client and server. More information on JSON can be found here. Remember, 'json' is the python library used for handling JSON objects and JSON is a data communication format.
The algorithm for the code can be broken down into the following steps -
- Fetch the latest sensor value from the Bolt device.
- Check if the sensor value is in the range specified in our min and max values.
- If it is not in range, send the SMS.
- Wait for 10 seconds.
- Repeat from step 1.
from boltiot import Sms, Bolt
MAX_LIMIT = 45
MIN_LIMIT = -10
###you can vary values here according to your requirement
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
print("\nReading Temperature Values")
A_response = mybolt.analogRead('A0')
A_data = json.loads(A_response)
Temp =(int(A_data['value'])*100) / 1024 ##convertin values to Degree Celsius
print("\nTemperature in degree celsius")
print("\nSensing presence of Light")
D_response = mybolt.digitalRead('0')
D_data = json.loads(D_response)
D_value = int(D_data['value'])
if (D_value ==0) or (Temp > MAX_LIMIT) or (Temp < MIN_IMIT):
mybolt.digitalWrite('1','HIGH') ## LED output
mybolt.digitalWrite('2','HIGH') ##Buzzer Output
print("\n Making request ot Twilio to send SMS")
response = sms.send_sms("Alert Message: There is issue with light or Tempe rature in Cold storage" + " The current Temperature is " + str(Temp) + " degree Celsius")
print(\n"Response received from Twilio is: " + str(response))
elif D_value == 1:
except Exception as e:
print("\nError occured: Below are the details")
###digitalRead(), analogRead(), digitalWrite() are functions of bolt python library
Video demonstrates the system's response when placed in darkness and when placed in the light. Similarly to that LED will glow up and Buzzer will sound when temperature range will not be maintained as per requirement, also the owner will get notified through text message.
Note: One can customize this product by adding mail notification or whatsapp or telegram notification system. Also one can add a feature of anamoly detection to temperature sensor values to get information about sudden variation. Due to limited resources, I have not implemented this, but if you want to know contact me.
If you are confused about anything feel free to contact me, suggestions/ ideas of improvisation are also welcomed.