There is system from which you get the value of the intensity of light in your room. yahh Room Light Monitoring system or Alert System is such a useful IoT tool or project.
This tool can be used in many ways, such as to check the lighting condition of the room, i.e whether the room looks perfect or not?
The other use of this system is that if the lights of the room are off and someone enters in your room without your notice and if this system is connected then it send you an alert on your phone.
Hardware Required- 1 x Bolt IoT Module
- 1 x Micro USB cable
- 1 x LDR (2 legged device with a red wave pattern disk on top)
- 1 x 330 Ohm resistor (orange, brown, gold color code)
Insert one lead of LDR into Bolt Module's 3v3 pin and the second lead of LDR into the A0 pin. Insert one leg of 330 ohm resistor into the GND pin and the second leg of the resistor also into the A0 pin
Warning!! Note that at point do the 3.3V and GND pins orwires coming out of them touch each other. If you short power to Ground without a resistor even accidentally, the current drawn might be high enough to destroy the Bolt Module
NOW, we will start the coding part from here. To monitoring the light intensity we will use the Python Language
Open your python editor and type or copy/paste the following configuration parameters
SSID = 'You can find SSID in your Twilio Dashboard'
AUTH_TOKEN = 'You can find on your Twilio Dashboard'
FROM_NUMBER ='This is the no. generated by Twilio. You can find this on your Twilio Dashboard'
TO_NUMBER = 'This is your number. Make sure you are adding +91 in beginning'
API_KEY = 'This is your Bolt Cloud account API key'
DEVICE_ID = 'This is the ID of your Bolt device'
FRAME_SIZE = 10
MUL_FACTOR = 6
To
get the above value you need to create a account on Twilio and Bolt Cloud.
Note: You have to replace all the above value with your credentials. You can find the first four values in Twilio dashboard and the last two in Bolt Cloud dashboard.
You can set the FRMAE_SIZE to 10, and the MUL_FACTOR to 6 for now. Once done, you can save the configurations file by pressing 'CTRL+x'
create one more file. This File will contain the main Code
The algorithm for the code can be broken down into the following steps:
1) Fetch the latest sensor value from the Bolt device.
2) Store the sensor value in a list, that will be used for computing z-score.
3) Compute the z-score and upper and lower threshold bounds for normal and anomalous readings.
4) Check if the sensor reading is within the range for normal readings.
5) If it is not in range, send the SMS.
6) Wait for 10 seconds.
7) Repeat from step 1.
In this project, we are using the z-score algorithm to dynamically change the bounds at which an SMS alert is sent on your mobile number
So when you move the light source close to or away from the LDR slowly, the bounds also start changing slowly.
But when you move the light source close to or away from the LDR very fast, bounds do not change fast enough, and the system detects an anomaly and send an SMS alert.
So how does this system help us know if someone turned on or off the lights?
Well throughout the day, the light in the room will change with the rising and setting of the sun. This change will be slow, and the bounds for the system will change to match this change. But when someone turns on or turns off the lights in the room, the intensity of light in the room will change suddenly. Because of this, the system will detect an anomaly and quickly alert you that someone is in your room.
Comments