The project is designed for learning purposes but can be further used in Power Plants for temperature sensing and generating alerts whenever the threshold is reached. I have learned some projects in Bolt IoT training and one of them was temperature sensing and sending SMS whenever a threshold is reached and out of curiosity, I thought can this alert message be sent on WhatsApp? so I searched for Whatsapp API and get to know its a very complicated process then I want to receive a message on Whatsapp anyhow so I have taken an alternative of Whatsapp API that is Twilio Whatsapp API which provides that service. I have used it and it worked then I thought can I send the Whatsapp message as well as SMS at the same time? so I change some things in the code and get to know yes it is also possible. In this project, LM35 sensor is used which senses the temperature and gives the temperature reading every 10 seconds as it is programmed to do so and an alert will be generated when the threshold or temperature limit is reached then it will automatically send the Whatsapp message followed by SMS to the owner.
Step I: Hardware Connectionsi) Take an LM35 temperature sensor.
ii) LM35 sensor has 3 pins as shown in Figure 1.1
iii) Hold the pin in such a way that you can read LM35 as per Figure1.1
iv)The leftmost pin is Vcc, the middle pin is an output pin and the rightmost pin is Ground pin.
v) Now Take a Bolt wifi module and male-female jumper wires.
vi) In male-female wire, the male connector is like a plug, in which the pins are inserted and the female connector looks like a jack which itself is a pin and inserted in plugs.
vi) In male-female wire, the male connector is like a plug, in which the pins are inserted and the female connector looks like a jack which itself is a pin and inserted in plugs.
viii) Now, Connect the female end of the wire to the Bolt wifi module as given below
1)VCC pin in 5V of Bolt wifi module
2)Output pin in A0 of Bolt wifi module
3)Ground pin in GND of Bolt wifi module
ix) Connect the Bolt wifi module with your mobile charger and switch on the charger.
After making the connections take a look at images below for cross-checking
Open the web browser and type https://cloud.boltiot.com/.
Login to your account if you don't have an account you can create it by simple google sign in
The screen, as shown above, will display for the first time if you open it the in the product section not linked is written
So the next thing we have to do is copy the Bolt Id and paste it in notepad as it is required in the further portion of the project.
On the left side of your screen, you can see many tabs you have to select the Products tab. There you will get an option to add product click on that the interface given below will appear
Give the product name as per convenience. Select input devices and GPIO pin
as we are taking input from the temperature sensor. Click on done.
Now, at the right-hand corner, you will saw link option click on a link and link the bolt device with the product
Step III: Getting Device ID and BolT API keyI have mentioned in the above section how to get device ID for simplicity I will write it again login to https://cloud.boltiot.com/ and note your device id.
Click on API tab from the left side of the window and note the API Key or paste it in the notepad
Open the web browser and type https://www.twilio.com/ or click on the link. Click on sign up
After signup, it may ask you to verify mobile and email do it.
Create a project after login, it will ask some questions like which language you code and for what purpose you want their service select SMS.
Click on get a trial number and also copy the trial number, Account SID and Auth token and save it somewhere.
Now click on https://www.twilio.com/whatsapp for generating Whatsapp messages then signup by entering the required details make sure to add Whatsapp number.
It will ask the same details as ask while performing SMS request but with one difference you need to select Whatsapp request instead of SMS request then the page shown below will appear
follow the instructions as it gives and copy the trial number, Account SID and Auth token and save it somewhere.
Step V: Ubuntu serverIf you have ubuntu O.S installed in your system then it is well and good or else you can use Vmware or Virtualbox to run ubuntu on your windows machine.
Open the terminal and perform the task as per given below.
mkdir command in ubuntu is used to create a folder
cd is used to change the directory
nano is used to create an editable document.
In this project, we are using python language. Now create a configuration file as given in the above figure in which fill the following details that you have saved in the previous section for SMS service.
SID = 'XXXXXXXXXXXXXXXXXXXXXX'
AUTH_TOKEN = 'XXXXXXXXXXXXXXXXXXX'
FROM_NUMBER = '+XXXXXXXXXXXXXXXXX'
TO_NUMBER = '+91XXXXXXXXXX'
API_KEY = 'XXXXXXXXXXXXXXXXXXXXX'
DEVICE_ID = 'BOLTXXXXX'
As we are generating an alert message via Whatsapp as well as SMS so we will create two conf file one is created in the above section.
Write sudo nano Whatconf.py in the terminal this will generate another configuration file in which fill the following details that you have saved from Whatsapp Twilio dashboard.
SID = 'XXXXXXXXXXXXXXXXXXXXXX'
AUTH_TOKEN = 'XXXXXXXXXXXXXXXXXXX'
FROM_NUMBER = 'whatsapp:+XXXXXXXXXXXX'
TO_NUMBER = 'whatsapp:+91XXXXXXXXXX'
API_KEY = 'XXXXXXXXXXXXXXXXXXXXX'
DEVICE_ID = 'BOLTXXXXX'
After saving both the files create the main file where the main logical code is written. Create the file by typing the command sudo nano whatsapptemp.py in the Ubuntu terminal and write the code written in the Complete Code section.
Step VI: Output of the code
Comments