This project deals with automatic turning ON and OFF of a LED depending upon the surrounding intensity of light. It is done by running a Python code that takes the value read by the light sensor (LDR) of our circuit, uploaded to the Bolt cloud. This sensor value is then compared with the threshold value given by us in the code ( we can set any value as threshold as per requirement). If the sensor value is less than the threshold value the LED turns ON. And if it is greater than the threshold value LED (ON) turns OFF.
For this we will have to create two python files. I created conf.py and autoled.py (we will see the codes later).
- The configuration file (conf.py) consists of your API key and device id which are available on the bolt IoT dashboard. It also consists of the threshold value given by us. All these will be used in the autoled.py by importing the configuration file.
- The autoled file requests the sensor value from the bolt cloud. It then compares the value with the threshold (I have set it 200). Using if else statements, LED can be turned ON and OFF easily. This file require to import the Bolt module from the boltiot library. For that, boltiot library must be installed first using the following command in the Linux terminal.
# pip3 install boltiot
The complete circuit looks like below,
We will see all the steps to make this circuit later on.
Following is the video testing the working of this project.
What's happening in the video? Let me explain,
- After completing the circuit, connect bolt WiFi module to bolt cloud.
- Run the autoled.py file by using the command
# python3 autoled.py
- In the video two sensor values have already been received as 563 and 493. Both these values are greater than threshold (200). So LED remains OFF.
- After some time another value is received as 1024 which is again much greater.
- Now I turned the room's light OFF to decrease the intensity of light around the LDR.
- This time the sensor value is too low (6). As it is less than the threshold, LED turns ON after few seconds.
- The next value received is 12 and LED remains ON ( 12 < 200).
- Now I again turned the room's light ON. The sensor value again jumped to 1024. As this value is greater than threshold (200), LED turns OFF.
So, this is how it works. Now let's move on to making this project.
Comments
Please log in or sign up to comment.