What if I told you there exists a system from which you can get the value of the Intensity of light of your room? Wouldn't that be great?
This system can be used in many ways, such as to check the lighting condition of the room, i.e whether the room looks dull 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)
- Step 1: Insert one lead of the LDR into the Bolt Module's 3v3 Pin.
- Step 2: Insert other lead of the LDR into the A0 pin
- Step 3: Insert one leg of the 330 Ohm resistor into the GND pin
- Step 4: Insert the other leg of the resistor also into the A0 pin
- Warning!! Make sure that at no point do the 3.3V (or even 5V) and GND pins or wires 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
After the editor is open, type in 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
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 FRAME_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.
VIDEO:OUTPUT:
This is the Execution of the program
Note: The account_sid and sid are hidden by me
In this project, we are using the Z-score algorithm to dynamically change the bounds at which an alert is sent.
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, the bounds do not change fast enough, and the system detects an anomaly and sends 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