What do you do when you need to check the sensor values of your Iot project anytime? You just login to your cloud to check it. Seems simple, right? But what if you had to check the values once in every hour or once in every few minutes and that to many times in a day. That would be a little (very) cumbersome, right? Now, imagine a world where you could get the sensor values via SMS and Email by just saying "Send me the sensor values" to your Google Assistant. Wait, wait, wait. That situation is no more imaginary because you yourselves could do that in a few steps. Read on to find out.
In this project, we will be receiving the temperature sensor values from LM35 sensor via SMS and Email through a command to Google Assistant.
Step 1 : Hardware SetupHold the LM35 sensor in your hand such that the name is visible to you. The three pins, from left to right, are VCC, output and GND. Connect the three pins to female-to-male wires. Connect the three wires, corresponding to the three pins from left to right, to 5 V, A0 and GND pins on the Bolt WiFi module. Connect the WiFi module to a 5 V power source. Make sure it is connected to an active internet connection.
Step 2 : Creating an IFTTT module in IntegromatLogin to your Integromat account. If you haven't signed up on Integromat, then you can create an account by clicking here. After logging in, click on "Create a new scenario" on the top-right of the screen. Select IFTTT, HTTP, Mailgun and Twilio in the screen to select the required tools and then click "Continue". Then click on the white circle and select IFTTT from the list and then select "Receive Data" from the menu. This module is essential to connect it to the Applet on IFTTT which will be discussed later. Click on "Add" to add a new Webhook followed by giving a suitable name to it and click on "Save". Now, you will be getting a URL or link. Save it for further purpose.
Next, click on "+" symbol attached to the module to add a new module. Select "HTTP" followed by "Make a request". This is required to receive the sensor values from the Bolt Iot Cloud. In the URL, paste the link https://cloud.boltiot.com/remote/your-bolt-iot-api-key/analogRead?pin=A0&deviceName=BOLTXXXXXXX. Replace "your-bolt-iot-api-key" and "BOLTXXXXXXX" with your respective credentials which you can easily find in your Bolt Iot Cloud. Let the method be "GET" and click "OK".
The above link is used to fetch the sensor values from Bolt Iot Cloud. The output of the above link will be in the form of {"value": "XXX", "success": "1"} where XXX are the sensor values.
Now, click again on "+" and type "Flow Control" in the search box and select it followed by "Router". Two white circles must be made. Click on the first white circle and select "Mailgun" followed by "Send an email". Here, Mailgun is used to receive the Email with the temperature. If you are already having an account in Mailgun, then you must be having the API key and Domain Name which can be easily found in your Mailgun account. If you don't have an account in Mailgun, then you can follow the Alternative Step given below. Fill in the required details as asked for. Type the recipient's mail (which is your Email address). In the "Sender" field, type "test@yourdomainname". In the "Content" section, we need to write the temperature value and not the sensor value. To convert the temperature value to the sensor value we need to divide the number by 10.24. To get the sensor value in the form XXX, we need to eliminate all the other characters for which we use the function "substring". Click on "A" symbol in the dialog box beside and select "substring".
In the first space inside the brackets, click on "Data" option under the star symbol followed by "11" and "14" in the second space and third space. Strictly speaking, this is not the right method to fetch the sensor value so am using a hack to get. If someone knows the right way, they can mention the method in the comment section below.
The latter is done to capture only the "XXX" from the output. This number is then divided by 10.24
After clicking on the white circle, instead of selecting "Mailgun" type "Email" in the search box and select it. Select "Send me an Email" in the options shown. Type your preferred "Subject" of the Email and for the "Content" you can follow the same procedure as shown in the above Step. This alternate is useful only to avoid making an account on Mailgun and getting the API key and Domain Name after that.
Now, click on the remaining white circle and select "Twilio" followed by "Send a message". This module is required to receive the temperature as an SMS. If you already have an account on Twilio, then you must be already having the SID and Auth Token. If you don't have an account, then you can make one from here. Personally, I find it very useful to receive SMS through APIs. In the "Recipient Number", type your phone number and in the "Message" copy and paste the same content that you have written for Mailgun.
Before saving the scenario, don't forget to switch on the "Scheduling" which is at the bottom of the screen and select the "Run scenario" as "Immediately". Your final scenario should look like this.
Login to your IFTTT account. If you haven't signed up on IFTTT, then you can create an account by clicking here. After logging in, click on "New Applet" under the "My Applets" section. Click on "+this" followed by "Google Assistant" after searching for it in the search box. Click on "Say a simple phrase" in the following screen. Type the command for which you want to trigger the required action.
Click on "Trigger" followed by "+that". Search for "Webhooks" in the search box and select it followed by selecting "Make a web request" in the following screen. In the URL field, paste the link which we got in Step 2 after creating an IFTTT module in Integromat. This step is very essential to run the scenario in Integromat when you say the command to Google Assistant. Afterwards, select "POST" in method and click on "Create Action". Write a suitable name for the applet and select "Finish".
That's it. Now see the magic when you take out your mobile phone and say "Ok Google, send the temperature sensor value."
Comments
Please log in or sign up to comment.