ThingSpeak-IFTTT-ESP32-Predictive-Machine-Monitoring

by Manish_Jugran in Circuits > Wireless

2158 Views, 0 Favorites, 0 Comments

ThingSpeak-IFTTT-ESP32-Predictive-Machine-Monitoring

thing2.jpg

In this project, we will measure vibration and temperature using NCD vibration and temperature sensor, ESP32, and ThingSpeak.We will also send different temperature and vibration readings to Google Sheet Using ThingSpeak and IFTTT for analyzing vibration sensor data.

The rising of new technology i.e, the Internet of Things, heavy industry has started adopting sensor-based data collection to solve its biggest challenges, principal among them process downtime in the form of shutdowns and process delays. Machine monitoring also called predictive maintenance or condition monitoring is the practice of monitoring electrical equipment through sensors in order to accumulate diagnostic data. To achieve this, data acquisition systems and data loggers are used to monitor all kinds of equipment, such as boilers, motors, and engines. Following condition are measured:


  • Temperature and Humidity Data Monitoring
  • Current and Voltage Monitoring
  • Vibration Monitoring: In this article, we will read Temperature, vibration and publish the data on ThingSpeak. ThingSpeak and IFTTT support graphs, UI, notifications, and emails. These features make it ideal for predictive maintenance analysis. We will also get the data in google sheets which will make predictive maintenance analysis more easier.

Hardware and Software Required

Vibration-Sensor-Zigmo.png
ESP32_1-600x400.png

Hardware Required:

  1. ESP-32: The ESP32 makes it easy to use the Arduino IDE and the Arduino Wire Language for IoT applications. This ESp32 IoT Module combines Wi-Fi, Bluetooth, and Bluetooth BLE for a variety of diverse applications. This module comes fully-equipped with 2 CPU cores that can be controlled and powered individually, and with an adjustable clock frequency of 80 MHz to 240 MHz. This ESP32 IoT WiFi BLE Module with Integrated USB is designed to fit in all ncd.io IoT products.
  2. IoT Long Range Wireless Vibration And Temperature Sensor: IoT Long Range Wireless Vibration And Temperature Sensor are battery operated and wireless, meaning that current or communication wires need not be pulled to get it up and operating. It tracks the vibration information of your machine constantly and captures and operating hours at full resolution together with other temperature parameters. In this, we are using NCD’s Long Range IoT Industrial wireless vibration and temperature sensor, boasting up to a 2 Mile range using a wireless mesh networking architecture.
  3. Long-Range Wireless Mesh Modem with USB Interface

Software Used:

  1. Arduino IDE
  2. ThigSpeak
  3. IFTTT

Library Used:

  1. PubSubClient Library
  2. Wire.h

Steps to Send Data to Labview Vibration and Temperature Platform Using IoT Long Range Wireless Vibration and Temperature Sensor and Long Range Wireless Mesh Modem With USB Interface-

  1. First, we need a Labview utility application which is ncd.io Wireless Vibration and Temperature Sensor.exe file on which data can be viewed.
  2. This Labview software will work with ncd.io wireless Vibration Temperature sensor only
  3. To use this UI, you will need to install following drivers Install run time engine from here 64bit
  4. 32 bit
  5. Install NI Visa Driver
  6. Install LabVIEW Run-Time Engine and NI-Serial Runtime
  7. Getting started guide for this product.

Uploading the Code to ESP32 Using Arduino IDE:

As esp32 is an important part to publish your vibration and temperature data to ThingSpeak.

  • Download and include the PubSubClient Library and Wire.h Library.
  • Download and include WiFiMulti.h and HardwareSerial.h Library.
<p>#include<Wire.h><br>#include<PubSubClient>
#include<WiFiMulti.h>
#include<WiFi.h>
#include<HardwareSerial.h></p>
  • You must assign your unique API key provided by ThingSpeak, SSID (WiFi Name) and Password of the available network.
const char* ssid     = "Yourssid"; // Your SSID (Name of your WiFi)<br>const char* password = "Wifipass"; //Your Wifi password<br>const char* host = "api.thingspeak.com";
String api_key = "APIKEY"; // Your API Key provied by thingspeak
  • Define the variable on which the data will store as a string and send it to ThingSpeak.
int value;<br>int Temp;<br>int Rms_x;

int Rms_y; 

int Rms_z;<br>
  • Code to publish data to ThingSpeak:
<p>String data_to_send = api_key;    <br>data_to_send += "&field1=";    
data_to_send += String(Rms_x);    
data_to_send += "&field2=";   
data_to_send += String(Temp);   
data_to_send += "&field3=";  
data_to_send += String(Rms_y);  
data_to_send += "&field4=";   
data_to_send += String(Rms_z);    
data_to_send += "\r\n\r\n";<br>client.print("POST /update HTTP/1.1\n");    
client.print("Host: api.thingspeak.com\n");   
client.print("Connection: close\n");   
client.print("X-THINGSPEAKAPIKEY: " + api_key + "\n");    
client.print("Content-Type: application/x-www-form-urlencoded\n");    
client.print("Content-Length: ");    
client.print(data_to_send.length());    
client.print("\n\n");   
client.print(data_to_send);</p>
  • Compile and upload the Esp32-Thingspeak.ino
  • To verify the connectivity of the device and the data sent, open the serial monitor. If no response is seen, try unplugging your ESP32 and then plugging it again. Make sure the baud rate of the Serial monitor is set to the same one specified in your code 115200.

Serial Monitor Output:

serial output2.JPG

Making the ThingSpeak Work:

Thingspeak1.JPG
Thingspeak2.JPG
Thingspeak3.JPG
Thigspeak5.JPG
Thigspeak6.JPG
Thigspeak8.JPG
Thigspeak7.JPG
Thigspeak9.JPG
Thigspeak11.JPG
Thigspeak13.JPG
Thigspeak17.JPG
  1. Create the account on ThigSpeak.
  2. Create a new channel, by clicking on Channels
  3. .Click on My Channels.
  4. Click New Channel.
  5. Inside New Channel, name the channel.
  6. Name the Field inside the Channel, Field is the variable in which the data is published.
  7. Now save the Channel
  8. .Now you can find your API keys on the dashboard.
  9. Go to the tap on the homepage and find your ‘Write API Key’ which must be updated before uploading the code to ESP32.
  10. Once Channel is created you would be able to view your temperature and vibration data in private view with Fields you created inside the Channel.
  11. To plot a graph between different vibration data, you can use MATLAB Visualization.
  12. For this go to App, Click on MATLAB Visualization.
  13. Inside it select Custom, in this, we have select create 2-D line plots with y-axes on both left and right sides. Now click create.MATLAB code will be autogenerated as you create visualization but you have to edit field id, read channel id, can check the following figure.
  14. Then save and run the code.
  15. You would see the plot.

Output:

plot1.JPG
Thiongspeak_output.JPG

Create an IFTTT Applet

event1.JPG
event2.JPG
event4.JPG
event5.JPG
event6.JPG
event7.JPG
event8.JPG
event9.JPG
sheets1.JPG
sheets2.JPG
sheets3.JPG
sheets4.JPG
sheets6.JPG
timecontrol4.JPG

IFTTT is a web service that lets you create applets that act in response to another action. You can use the IFTTT Webhooks service to create web requests to trigger an action. The incoming action is an HTTP request to the webserver, and the outgoing action is an email message.

  1. First, create an IFTTT account.
  2. Create an applet. Select My Applets.
  3. Click the New Applet button.
  4. Select the input action. Click the word this.
  5. Click the Webhooks service. Enter Webhooks in the search field. Select the Webhooks.
  6. Choose a trigger.
  7. Complete the trigger fields. After you select Webhooks as the trigger, click the Receive a web request box to continue. Enter an event name.
  8. Create trigger.
  9. Now the trigger is created, for resulting action click That.
  10. Enter “Google Sheets” in the search bar, and select the “Google Sheets” box.
  11. If you have not connected to Google Sheet, then connect it first. Now choose action. Select add a row to a spreadsheet.
  12. Then, complete the action fields.
  13. Your applet should be created after you press the Finish
  14. Retrieve your Webhooks trigger information. Select My Applets, Services and search for Webhooks. Click Webhooks and Documentation button. You see your key and the format for sending a request. Enter the event name. The event name for this example is VibrationAndTempData.You can test the service using the test button or by pasting the URL into your browser.

Create a MATLAB Analysis

analysis1.JPG
analysis2.JPG
analysis3.JPG
sheet7.JPG

You can use the result of your analysis to trigger web requests, such as writing a trigger to IFTTT.

  1. Click Apps, MATLAB Analysis and select New.
  2. Make Trigger data from IFTTT 5 to Google Sheet code. You can take help from Trigger Email from IFTTT in the Examples section.
  3. Name your analysis and modify the code.
  4. Save your MATLAB Analysis.

Create a Time Control to Run Your Analysis

analysis5.JPG
timecontrol.JPG
timecontrol2.JPG

Evaluate your ThingSpeak channel data and trigger other events.

  1. Click Apps, TimeControl, and then click New TimeControl.
  2. Save your TimeControl.

OUTPUT

Google sheet.JPG
  • At last, data is retrieved in Google Sheet.