IoT — ThingSpeak — ESP32-Long-Range-Wireless-Vibration-And-Temp

In this project, we will measure vibration and temperature using NCD vibration and temperature sensors, Esp32, ThingSpeak.

Vibration is truly a to and fro movement — or oscillation — of machines and components in motorized gadgets. Vibration in the industrial system may be a symptom, or motive, of a hassle, or it can be associated with everyday operation. For instance, oscillating sanders and vibratory tumblers depend upon vibration to feature. Internal combustion engines and tools drive, then again, revel in a sure amount of unavoidable vibration. Vibration can imply a hassle and if left unchecked can cause harm or expedited deterioration. Vibration can be resulting from one or extra factors at any given time, the maximum not unusual being an imbalance, misalignment, put on, and looseness. This damage can be minimized by analyzing Temperature and Vibration Data on ThingSpeak using esp32 and NCD wireless vibration and temperature sensors.

Step 1: Hardware and Software Required

Hardware Required:

  • 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.
  • 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.
  • I2C Cable: NodeLynk I2C cables with 4-color wire and latching connectors to link sensors and controllers together in any combination.
  • PARTICLE ELECTRON OR PHOTON COMPATIBLE I2C SHIELD
  • Long-Range Wireless Mesh Modem with USB Interface


Software Used:

Library Used

Arduino Client for MQTT

  • This library provides a client for doing simple publish/subscribe messaging with a server that supports MQTT
  • For more information about MQTT, visit mqtt.org.

Download

  • The latest version of the library can be downloaded from GitHub.

Documentation

  • The library comes with a number of example sketches. See File > Examples > PubSubClient within the Arduino application. Full API Documentation.

Compatible Hardware

  • The library uses the Arduino Ethernet Client API for interacting with the underlying network hardware. This means it Just Works with a growing number of boards and shields, including:
  1. Arduino Ethernet
  2. Arduino Ethernet Shield
  3. Arduino YUN — use the included YunClient in place of EthernetClient, and be sure to do a Bridge.begin() first
  4. Arduino WiFi Shield — if you want to send packets greater than 90 bytes with this shield, enable the MQTT_MAX_TRANSFER_SIZE option in PubSubClient.h.
  5. Sparkfun WiFly Shield — when used with this library.
  6. Intel Galileo/Edison
  7. ESP8266
  8. ESP32: The library cannot currently be used with hardware based on the ENC28J60 chip — such as the Nanode or the Nuelectronics Ethernet Shield. For those, there is an alternative library available.

Wire Library

The Wire library allows you to communicate with I2C devices, often also called “2 wire” or “TWI” (Two Wire Interface), which can download from Wire.h.

Step 2: 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-

Step 3: 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.
#include<Wire.h>
#include<PubSubClient>
#include<WiFiMulti.h>
#include<WiFi.h>
#include<HardwareSerial.h>
  • 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)
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;
int Rms_x;
int Rms_y;
int Rms_z;
  • Code to publish data to ThingSpeak:
String data_to_send = api_key;    
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);
  • 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.

Step 4: Serial Monitor Output:

Step 5: Making the ThingSpeak Work:

  • Create the account on ThigSpeak.
  • Create a new channel, by clicking on Channels.
  • Click on My Channels.
  • Click New Channel.
  • Inside New Channel, name the channel.
  • Name the Field inside the Channel, Field is the variable in which the data is published.
  • Now save the Channel.
  • Now you can find your API keys on the dashboard. Go to the tap on the homepage and find your ‘Write API Key’ which must be updated before uploading the code to ESP32.
  • 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.
  • To plot a graph between different vibration data, you can use MATLAB Visualization.
  • For this go to App, Click on MATLAB Visualization.
  • 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.
  • Then save and run the code.
  • You would see the plot.

Step 6: Output

Now you can see the different vibration and temp readings.

Share

    Recommendations

    • Backyard Contest

      Backyard Contest
    • Barbecue Challenge

      Barbecue Challenge
    • Sensors Contest

      Sensors Contest

    Discussions