Getting Started With Long Range Wireless Temperature and Vibration Sensors

About: Design Develop Deploy

Sometimes vibration is the cause of serious issues in many applications. From machine shafts and bearings to hard disk performance, vibration causes machine damage, early replacement, low performance, and inflicts a major hit on accuracy. Monitoring and time to time analysis of vibration in the machine can solve the problem of early damage and wear and tear of the machine part.

In this instructable, we will be working on the IoT long-range wireless vibration and temperature sensors. These are industrial grade sensors with many widespread applications like.

  • Metalworking
  • Power generation
  • Mining
  • Food and Beverage

So, In this Instructable we will be going through the following:

  • Configuring Wireless Sensors using XCTU and Labview UI.
  • Getting the values of vibration from the sensor.
  • Understanding the working of xbee device and xbee protocol.
  • Configuring WiFi credentials and IP configuration using the captive portal

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Hardware and Software Specification

Hardware Specification

Software Specification

  • Arduino IDE
  • LabView Utility

Step 2: Configuring Wireless Sensor and Zigmo Receiver Using XCTU

Each IoT device needs a communication protocol to put the device over the cloud and to set up a wireless interface between different devices.

Here the Wireless Sensors and Zigmo Receiver use low power and long-range solution XBee. XBee uses a ZigBee protocol that specifies the operation in 902 to 928 MHz ISM bands.

Xbee can be configured using XCTU software

  1. Search for the Xbee device or add a new Xbee device by clicking on the top left icon.
  2. The device will be listed on the left-hand side panel.
  3. double click on the device to see the settings.
  4. Now click on the console icon on the top right corner
  5. You can see the value coming on the console output
  6. Here we are getting the frame of length 54 bytes
  7. these bytes would be further manipulated to get the real values. the procedure to get the real temperature and vibration values are mentioned in upcoming steps.

Step 3: Wireless Temperature and Vibration Values Analysis Using Labview Utility

The Sensor run in two modes

  • Configuration Mode: Configure the Pan ID, delay, No. of retries etc. More on this is beyond the scope of this instructable and will be explained in next instructable.
  • Run Mode: We are running the device in Run mode. And to analyze these value we are using the Labview Utility

This Labview UI shows the values in nice graphs. It shows the current as well as past values. You can go to this link to download the Labview UI.

click on the Run icon from the landing page menu to go to run mode.

Step 4: Configuring DHCP/Static IP Settings Using Captive Portal

We are using the captive portal to save the WiFi credentials and to hover through the IP settings. For the detailed introduction on the captive portal, you can go through the following instructable.

The captive portal gives us the option to choose between Static and DHCP settings. Just enter the credentials like Static IP, Subnet Mask, gateway and the Wireless Sensor Gateway will get configured on that IP.

Step 5: Saving WiFi Settings Using Captive Portal

A webpage is being hosted where a list showing available WiFi networks and there RSSI. Select the WiFi network and password and enter submit. The credentials will be saved in the EEPROM and the IP setting will be saved in the SPIFFS. More on this can be found in this instructable.

Step 6: Publishing Sensor Readings to UbiDots

Here we are using Wireless Temperature and Vibration Sensors with the ESP 32 gateway receiver to get the temperature and Humidity data. We are sending the data to UbiDots using the MQTT protocol. MQTT follows a publish and subscribe mechanism rather that request and response. It is faster and reliable than HTTP. This works as follows.

Reading the Wireless Sensor Data

  • We are getting a 29-byte frame from the Wireless Temperature and Vibration Sensors. This frame is manipulated to get the actual temperature and Vibration data.

if (Serial2.available())
{ data[0] = Serial2.read(); delay(k); if(data[0]==0x7E) { Serial.println("Got Packet"); while (!Serial2.available()); for ( i = 1; i< 55; i++) { data[i] = Serial2.read(); delay(1); } if(data[15]==0x7F) /////// to check if the recive data is correct { if(data[22]==0x08) //////// make sure the sensor type is correct { rms_x = ((uint16_t)(((data[24])<<16) + ((data[25])<<8) + (data[26]))/100); rms_y = ((uint16_t)(((data[27])<<16) + ((data[28])<<8) + (data[29]))/100); rms_z = ((uint16_t)(((data[30])<<16) + ((data[31])<<8) + (data[32]))/100); max_x = ((uint16_t)(((data[33])<<16) + ((data[34])<<8) + (data[35]))/100); max_y = ((uint16_t)(((data[36])<<16) + ((data[37])<<8) + (data[38]))/100); max_z = ((uint16_t)(((data[39])<<16) + ((data[40])<<8) + (data[41]))/100);

min_x = ((uint16_t)(((data[42])<<16) + ((data[43])<<8) + (data[44]))/100); min_y = ((uint16_t)(((data[45])<<16) + ((data[46])<<8) + (data[47]))/100); min_z = ((uint16_t)(((data[48])<<16) + ((data[49])<<8) + (data[50]))/100);

cTemp = ((((data[51]) * 256) + data[52])); float battery = ((data[18] * 256) + data[19]); float voltage = 0.00322 * battery; Serial.print("Sensor Number "); Serial.println(data[16]); Serial.print("Sensor Type "); Serial.println(data[22]); Serial.print("Firmware Version "); Serial.println(data[17]); Serial.print("Temperature in Celsius :"); Serial.print(cTemp); Serial.println(" C"); Serial.print("RMS vibration in X-axis :"); Serial.print(rms_x); Serial.println(" mg"); Serial.print("RMS vibration in Y-axis :"); Serial.print(rms_y); Serial.println(" mg"); Serial.print("RMS vibration in Z-axis :"); Serial.print(rms_z); Serial.println(" mg");

Serial.print("Min vibration in X-axis :"); Serial.print(min_x); Serial.println(" mg"); Serial.print("Min vibration in Y-axis :"); Serial.print(min_y); Serial.println(" mg"); Serial.print("Min vibration in Z-axis :"); Serial.print(min_z); Serial.println(" mg");

Serial.print("ADC value:"); Serial.println(battery); Serial.print("Battery Voltage:"); Serial.print(voltage); Serial.println("\n"); if (voltage < 1) { Serial.println("Time to Replace The Battery"); } } } else { for ( i = 0; i< 54; i++) { Serial.print(data[i]); Serial.print(" , "); delay(1); } } } }

Connecting to UbiDots MQTT API

  • Include the header file for the MQTT process.
#include "PubSubClient.h"
  • define other variables for MQTT like client name, broker address, token ID(We are fetching the token ID from EEPROM)

#define MQTT_CLIENT_NAME "ClientVBShightime123"
char mqttBroker[] = "things.ubidots.com"; char payload[100]; char topic[150]; //create variable to store token ID String tokenId;

  • Create variables to store different sensor data and create a char variable to store topic

#define VARIABLE_LABEL_TEMPF "tempF" // Assing the variable label
#define VARIABLE_LABEL_TEMPC "tempC" // Assing the variable label #define VARIABLE_LABEL_BAT "bat" #define VARIABLE_LABEL_HUMID "humid" // Assing the variable label

char topic1[100]; char topic2[100]; char topic3[100];

  • publish the data to the mentioned MQTT topic the payload will look like { "tempc" : {value: "tempData"}}

sprintf(topic1, "%s","");
sprintf(topic1, "%s%s", "/v1.6/devices/", DEVICE_LABEL); sprintf(payload, "%s", "");

// Cleans the payload sprintf(payload, "{\"%s\":", VARIABLE_LABEL_TEMPC);

// Adds the value sprintf(payload, "%s{\"value\":%s}", payload, str_cTemp);

// Adds the value sprintf(payload, "%s}", payload);

// Closes the dictionary brackets Serial.println(payload);

Serial.println(client.publish(topic1,payload) ? "published" : "notpublished");

//Do same for other topic as well


  • client.publish() publishes the data to UbiDots.

Step 7: Visualizing the Data

  • Go to Ubidots and Login to your account.
  • Navigate to the Dashboard from the Data tab listed on the top.
  • Now click the "+" icon to add the new widgets.
  • Select a widget from the list and add a variable and devices.
  • The sensor data can be visualized on the dashboard using different widgets.

Overall Code

The Over code for HTML and ESP32 can be found in this GitHub repository.

  1. ncd ESP32 breakout board.
  2. ncd Wireless temperature and Humidity Sensors.
  3. pubsubclient
  4. UbiDots

Be the First to Share

    Recommendations

    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest

    Discussions