Temperature monitoring plays an important role in a server room or in a lab to maintain temperature below a certain threshold. In those cases, monitoring temperature and taking specific actions will prevent downtime due to the risk of overheating and will extend life of equipment.
In this project, we use ThingSpeak, an open source IoT application to store and retrieve data from the things over Internet. We use Pushover application, a free notification service for 7 days, to send notifications and MQTT.fx, a desktop MQTT client, to publish values to a channel.
We will set up React Application of ThingSpeak that would monitor the temperature. It would notify the user to take a specific action when it goes beyond a threshold with a push notification. These notifications are sent via Pushover when the condition is met and action is triggered by the React. The Push notification appearing in the mobile is configured in the ThingHTTP Application of ThingSpeak.
Temperature values are fed into the ThingSpeak using MQTT.fx application (instead of using DHT11 sensor).
Following are the steps to be followed to get the application working.
Step 1: ThingSpeak Channel ConfigurationTo log the data we need a new ThingSpeak Channel that would hold the temperature and humidity readings. So, create a channel with two fields (we would be majorly focusing on temperature field):
- Temperature
- Humidity
Then hit Save button.
Refer to this Link to learn more about other optional fields while creating new channel.
Step 2: Configure Pushover Application on MobileTo get notifications to the mobile, we need to configure Pushover application as follows.
Login/Sign Up to Pushover in the desktop.
Once logged in it would provide a User Key unique to every user. Add the device to which we need the notifications to be sent under Your Devices.(Eg: myphone). Then create an application in Your Applications (Eg: ThingSpeak_Pushover), through which the device gets notifications.
Application configuration is as shown below and then hit Save.
Once the application is created, each application has its unique API Token/Key.
To learn more about Pushover API follow the link.
Step 3: Configure a ThingHTTP Application in ThingSpeakThingHTTP is used to POST the message on HTTP to Pushover, which in turn is sent to the mobile.
Following is the configuration of ThingHTTP:
Name : Name of the application
The API key is auto generated by ThingHTTP
URL :https://api.pushover.net/1/messages.json
HTTP Auth Username : Pushover login Username
HTTP Auth password : Pushover login password
Method : POST
Content Type: application/x-www-form-urlencoded
Host : api.pushover.net
Body : user=PUSHOVER USER KEY& token=PUSHOVER APPLICATION API TOKEN &device=myphone&message="Heyy! Temperature is (%%trigger%%). Turn on the AC"
Then hit Save ThingHTTP.
%%trigger%% in the body is replaced with the value that triggered the React.
Step 4: Configure React Application of ThingSpeakConfigure the React Application of ThingSpeak, to React and send a Push notification when the temperature is beyond a Threshold ( Eg : 25 C).
Configure React as follows:
In this project, we would use MQTT protocol to publish the values of temperature to ThingSpeak channel. To update the values of a particular channel, MQTT should be connected to the channel of ThingSpeak.
To connect ThingSpeak and MQTT.fx,
- 2. Create a new ThingSpeak MQTT profile in MQTT.fx application by clicking on the Gear icon next to connect.
Configure the profile as shown below.
Generate the Client ID for the new profile added.
Add the login credentials of MQTT.fx in User Credentials.
Click on Apply and then OK.
Now connect to the ThingSpeak MQTT profile and add the following URL to publish
channels/CHANNEL_ID/publish/fields/field1/WRITE API KEY OF CHANNEL
Then click publish, to publish the values of temperature to the channel id provided in the URL.(Eg :40)
To read more about MQTT.fx refer Link.
- 1. We could see that the value 40 published via MQTT.fx got updated in the Temperature field of ThingSpeak channel.
- 2. As the temperature is beyond 25 C, it will trigger a message(Push notification) to the device (myphone) configured in Pushover.
If you've made it this far, you have working real-time notifier reacting for the condition specified. But, what other changes could be made to the project?
- You needreal-timenotifications using a sensor? The MQTT.fx could be replaced with a sensor and connect the sensor and ThingSpeak using arduino. This could send the real time temperature to ThingSpeak and we could get the notifications based on the condition provided.
- You don't want to use Pushover application? This project is compatible with other notification apps like Twilio. You just need to change the configuration in ThingHTTP according to the applications API.
Comments