An automated street lighting system is designed to automatically switch ON the Street Light alongside the roads( or path) or the light lamp just outside our house on the onset of dark weather or at dusk & switch them off automatically after sunrise or during the light hours.
This system would help in reducing the electricity consumption & also save from unprecedented accidents & thus will increase the safety of the pedestrians & prevent mishaps.
It works on the principle that the light intensity in the surroundings is monitored by the LDR(Light Dependent Resistor) continuously & it keeps on sending that data to the Bolt Cloud through the Bolt Iot Wifi Module which processes the python program & controls the LED(output device) connected to the circuit according to the instructions given in the program.
The LDR is a sensor(input device) so its output is connected to the A0 pin which is the analog to digital converter pin. So, the analog output of the LDR is converted to the digital format & this is important as our computers understand only digital data. One leg of the LDR is connected to the 10K ohm resistor in series & to the A0 pin and its other leg is connected to 3.3V & the 10k ohm resistor's other leg is connected to GND. When the intensity of light falling on the LDR increases, its internal resistance decreases & in turn the voltage across it by Ohm's Law. Since the Bolt Module cannot read resistance values, but it can read voltage values, hence a voltage divider circuit is made and the input to the Bolt module is the voltage across 10k ohm resistance (since it is connected between an LDR terminal and ground) which depends on the resistance across LDR. LDR terminals don't have polarity. The power supply to the LDR is given using 3.3V pin of the bolt module.
The (positive) longer end of the Led is connected to a 330K ohm resistor in series with the GPIO pin(pin 4 here) and the negative (shorter) leg of the LED is connected to the GND.
In the Python program, the Bolt cloud is linked to our Python code using the Bolt API key and the device_id which are passed as parameter to the mybolt object of the Bolt class.
When the light intensity around the area falls below the set threshold, the LDR senses that change & the street lights are switched ON automatically and a corresponding notification is sent on our mobile & the lights are switched OFF automatically when the LDR readings exceeds the threshold value.
To send a message to my cell phone that the lamp lights outside my house have been turned ON, I have used Telegram.
To set up Telegram for sending alert messages to mobile, follow the steps described below:--)Steps to sign-up for/sign-in to Telegram- Go to the Playstore or App Store on your phone and search for Telegram.
- Download and Install the latest version of Telegram app.
- Signup for a new account or sign in to Telegram by providing your mobile number.
- Telegram will call you OR send you a SMS to verify your mobile number.
- Get your account verified and approve any permissions if required.
- You will be logged in to Telegram and will be shown a screen similar to the one below. (It's okay if it differs from the screenshot below)
- Go to the home screen of the Telegram app.
- Swipe from the left side to reveal the menu.
- Click on "New Channel".
- It will ask you for a Name and Description for your channel. Give a suitable name and description. Adding photo is optional.
- In the next screen set the channel as Public.
- On the same screen, it will ask you to enter a permanent link for your channel. You can use lowercase letters and numbers 0-9 to create the channel link.
- Please note that the channel link name is global and you will be able to create a channel link only if the link name is available. The channel link name is something similar to an email address, i.e. only one unique email ID can exist at one time.
- You can keep the channel link name as temperature_alert_ followed by your email ID. Example, if my email ID is developer@boltiot.com, I can keep the channel link name as temperature_alert_developer_boltiot_com(I have removed the @ and. symbol since it was not allowed and replaced it with an underscore _). This is just a suggestion. You can keep the channel link name as you like as long as it is valid.
- Keep a note of this Channel permanent link name. It will be required later on to send messages to this channel. For example, the channel link name in the screenshot below is "temperature_alert".
- Congratulations! You have created a new channel. You can also view this channel from your app home screen.
- You can click on the channel name at the top to view more details about it.
- Next we will need to create and add a Bot to the channel so that it can post alerts for us in this channel.
Telegram allows us to create a new bot with the help of a bot called as "BotFather". It is a single bot to create and manage other bots.
- On the Home screen of the app, click on the search icon on the top right and type in "botfather".
- In the search results, click on the correct result for "BotFather" as shown below. The correct "BotFather" will have a blue tick mark next to its name. This will take you to a chat window with the "BotFather".
- The chat will have a few items already and will display you a list of commands to get started.
- Since we need to create a new Bot, go ahead and type in "/newbot" in the window.
- It will ask you to type in few more details like Bot name and Bot username.
- When your bot is created successfully, you will be shown a screen similar to the one below and will contain the Bot Token. This token is used to control your Bot as well as send messages on behalf of it. Please keep this token secure as it will allow anyone to access your Bot.
- In the screenshot above, the Bot token is "894346529:AAhuJ2XJQy5dlEtLYF0sc0Z_qu0fSqihSSc". Please save it as telegram_bot_id. The telegram_bot_id is saved as "bot" followed by the bot token. So, in this example, the telegram_bot_id will be "bot894346529:AAhuJ2XJQy5dlEtLYF0sc0Z_qu0fSqihSSc".
- The telegram_bot_id will be used in the python code to send messages. The python code will be taught in the later lessons.
- Also, please be careful when saving the Bot ID. You may get confused between 0 and O, I and 1 etc. as they are similar looking.
- Congratulations, you have created a new Bot. Now, we will need to add it to the channel we have created previously so that we can send alerts.
- From the App home screen, open the channel we have created earlier.
- In the screen, click on the channel name on the top to open the information for the Channel.
- Click on the Administrators button so that we can add the newly created bot to the channel.
- Search for the bot that we have created using the Bot's username. Once you have found the correct Bot click on it to add it to the channel. Please make sure you have clicked on the Administrators button in the previous step as this will allow our bot to post to the channel.
- You will be asked to confirm the rights for the bot. Press on the tick mark on the top right to continue adding the bot to the channel. Make sure that the bot has the rights to "Post Messages".
- You will now see the newly created Bot in the list of administrators for the channel.
Now, you can type the Python code for receiving alert messages.
Comments