We tend to lose an ample amount of time during the early morning hours simply due to utter laziness... What if we could use those precious hours of "Me-time" to ourselves and brighten up the day completely and with full of Josh... Worry not, here comes my project, Bolt Up, whose job primarily is to break all those barriers stopping you from using your "Me-time" to your fullest... Bolt Up is an alarm clock programmed to wake up the users as per the time specified.
I have provided a google drive link containing the video clip of the working model of "Bolt Up", towards the end of this project description. Please do have a glance at the video clip too.
Before diving into explaining how I came about to doing this project, let me furnish you with the prerequisites we require to be fully ready to proceed further.
Prerequisites required:
1. Telegram Messenger application : It is a 3rd party messaging application where we can send and receive messages in the form of files too. Here you can get to know about what Telegram is : https://telegram.org/ Download link for Desktop App : https://desktop.telegram.org/
2. VMware Virtual Machine : VMware is a virtual machine that helps you to work in multiple Operating systems other than your host OS. We can run any Linux OS on top of our host OS. Download link : https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_workstation_player/12_0
3. Ubuntu OS: We will be working on our code portion in this OS. So in order to proceed further, we might have to download this too. Download link : http://releases.ubuntu.com/16.04/ubuntu-16.04.6-server-i386.iso
4. Bolt IoT android app : This is to cross check whether our device is properly working and to check online/offline issues and restart the device if we encounter any problem during the course of the project. In order to proceed further we will need to link our Bolt device with our Bolt IoT account. Download link : https://play.google.com/store/apps/details?id=com.bolt.com.bolt
Alright, now that we have downloaded all our resources, we need to configure them to move forward.
For Telegram :- Create an account in Telegram by providing your mobile number
- Create a channel in Telegram.
- Provide a name for the channel, set it as public.
- Provide a sensible link for the channel (t.me/########) as this will be highly essential in further proceedings.
- Now that the channel has been created, we need to create our Bot which is gonna help us wake up.
- Search for BotFather in telegram. The proper Botfather will be having a blue tick near its name, like the one below.
- Once inside, create a newbot using " /newbot " command in the type area.
- Now we need to specify a name for our bot. Go ahead and name it.
- Upon naming it, we need to provide our bot an username. Please be specific, sensible and unique while providing a username as we will be using this username later to identify our bot. For convenience, store all the necessary information in a word document or notepad.
- Upon providing a valid username, we will be provided with an access token which is again an important entity, so save this also with all the necessary information.
- Upon finishing we will be having our page like this :
- Now, move to our Telegram channel, and select Manage channel from the options in the top right hand side. The following window would open. From here, choose Administrators.
- Upon moving to administrators, select add administrator and type in your bot's username there. Select your bot's username and add it here. Further we need to be specifying permissions to the bot. The required permissions will be granted by default, so do not worry, leave it as it is and move further.
- And that is it. Our Telegram channel, with the Telegram bot is done.
For VMware and Ubuntu OS:
- After downloading and installing VMware, open VMware, choose non-commercial use option and press continue.
- Another window opens, here select "Create a new virtual machine".
- Select "Installer disc image", browse to the location where the Ubuntu OS file has been downloaded and select the same. Need not unzip the file if it is in.rar or.zip format. Select in the same format itself.
- In the next page, it will ask for credentials. Enter the credentials and note them down somewhere safe as these credentials will be useful every time we log into the Ubuntu OS.
- Select next, once into the page where it asks for the disk size. Set the disk size upto 10 GB, and select "Store virtual disk as a single file", click next.
- Follow the on-screen directions from now and do not make any unnecessary changes unless important.
- The OS will start to install and will take some time to be completely ready and finally we will be landing on the screen shown below.
- Enter your username and password. Note that the password will not be visible as you type it, this has been made for security purposes.
- And that is it, Ubuntu OS interfacing has been done...
Now, with this our prerequisites are done. Now let's move to how I have done this project.
Hardware Connections : { "-->" - to be connected to }
- Long Pin ( marked + on top of it ) of buzzer --> pin 1 of the Bolt Wifi Module.
- Short Pin ( negative pin ) of buzzer--> GND of the Bolt Wifi Module.
The following are the screenshots for your reference :
In my case, RED wire is to positive pin of buzzer and ORANGE wire is to negative pin of buzzer.
After the hardware connections are done successfully, we can move to the software or the implementation side.
Software Implementation part:
Now this is the place where, those information that we have declared important and saved somewhere safe will come into action.
- Log into Ubuntu OS, create a directory and open up a python file to pen down the configurations for building Bolt Up.
- As you can see from the below screenshot, I have created a directory named "bolt_alarm" and I have made 2 python files, one named "conf.py" to store all the configurations and the other named "wake_me_up.py" that stores the important code for Bolt Up.
- Now moving on to the contents of conf.py file : Telegram chat id, will be visible under the link section in channel info. Telegram bot id is the token access provided by BotFather. While entering the bot id prefix the id with "bot", so that it looks like "bot31247927294...." Bolt API key and device ID will be available to you in your bolt account page.
- Moving on to "wake_me_up.py". Let me break down the code into fragments for explaining and finally will put up the full code.
- Fragment 1 : Here we are importing requests, used to make http requests, json, which is a data-interchange format used as a mode of communication between client and server, and time, to get the current time as well as to enable the program control to sleep for a fixed amount of time. From the boltiot library, we invoke the Bolt functionality. We also import the conf python file that we have constructed in the previous step. Finally, we are building an object for Bolt with bolt_api_key and device_id as its parameters.
- Fragment 2 : The send_telegram_message method deals with how the message that is written later in the code is being sent to telegram and how the bot communicates with the user and displays it to them. The url variable helps in pointing the program control to our channel's url in order to send the message. Here "data" is a dictionary that is used to hold chat_id and text message that is meant to be sent to telegram once the condition satisfies. Under the try except block, the response variable here, is used to make a HTTP request to Telegram which uses the url that we have constructed earlier. Further in the code, the url, response in the form of text are being printed. These are not mandatory, but just for explanation, I have coded these entities. Next, telegram_data contains the response variable (in the form of text) which has been converted to json format. The "ok" factor is a boolean entity which tells us whether the message that we plan to send, has reached properly or not. Finally in this fragment, the try block is handled by an except block that catches the exception and prints the error message.
- Fragment 3 : This fragment deals with the condition check, as to when to wake up the user and when the message has to be sent to Telegram. current_time_hrs reads the hours part of the current time. current_time_mins reads the minutes part of the current time. current_time reads the full current time in hours, minutes and seconds. For me, I wanted Bolt Up to wake me up at 5:00 at morning. So I chose the 24-hours format. You may change it to 12-hours format if you wish to do so. As soon as Bolt Up sees the time to be 05:00, it prints a message "Time to wake up...". The message field holds the content that needs to be sent to Telegram, when it is 05:00. telegram_status tells you the status of the message sent. response = mybolt.digitalWrite( '1', 'HIGH' ) sets the buzzer ON. Similarly, response = mybolt.digitalWrite( '1', 'LOW' ) sets the buzzer OFF. time.sleep(10) sees to that this code snippet repeats itself for every 10 seconds. Since when an alarm starts shouting, we tend to snooze them or dismiss them off, I have set the alarm functionality with a sleep time of 10 seconds, so that the user will not be able to wake up just for switching it off, but can wake completely up. The buzzer would beep every 10 seconds, so it would not allow the user to turn it off and sleep back tight again. This proves to be one advantage from the normal alarm clock.
- And finally, the complete code for your reference.
For experimentation purpose, I set the alarm clock to 1:05 in the afternoon.
Time for the Output :
- Start the code : sudo python3 wake_me_up.py
- The following is one of the iterations of the alarm clock trying to wake up the user from sleep.
The time crosses and the waking up process ends, but the time is constantly recorded here...
And, here I have the telegram bot asking me to wake up by sending me messages, along with the buzzer's loud beeps to wake you up effectively :
The above has been done for experimentation purpose but I have designed the program to wake the user up at 05:00 in the morning promptly. The timing can be changed as per user's requirements.
Here i am attaching my video link containing the working model of Bolt UP. Please do watch the video for the complete understanding of the project. Video link : https://drive.google.com/file/d/1DnUnu-a60Gc2-3ySXIPukEZBen_4LuyQ/view?usp=sharing
I hope I have furnished the complete information on how I have built Bolt UP. I wish this serves to be completely useful and informative for those who strive to build projects like this.
I am completely open to suggestions, please feel free to suggest tips and tricks to produce more and more versions of my Bolt UP project.
Thank You,
Dinesh Balaji
Comments