🎯 Objective

Implement a system that utilizes temperature and vibration sensors in vehicles. The collected data is uploaded to the FAVORIOT IoT platform, where it’s analyzed to detect damage patterns and schedule proactive maintenance.


🧰 Hardware Components

  1. ESP8266 NodeMCU (for WiFi connectivity and microcontroller functionality)
  2. LM35 or DS18B20 Temperature Sensor
  3. SW-420 or GY-521 (with MPU6050) Vibration Sensor
  4. Jumper wires & Breadboard
  5. USB Cable for programming

🌐 FAVORIOT Platform Setup

  1. Register/Login at https://platform.favoriot.com.
  2. Navigate to Developer > IoT Devices.
  3. Click on + Add Device and fill in the required details:
    • Device Name: e.g., VehicleSensorNode
    • Device Developer ID: e.g., vehicle_sensor_node
    • Description: e.g., Vehicle sensor node for predictive maintenance
    • Template: Select Custom
  4. After creating the device, copy the Access Token provided. This token will be used for authenticating API requests from your hardware.

🧪 Wiring Diagram

LM35 Temperature Sensor

  • VCC → 3.3V
  • GND → GND
  • OUT → A0

SW-420 Vibration Sensor

  • VCC → 3.3V
  • GND → GND
  • D0 → D1 (GPIO5)

📟 Arduino Source Code

Ensure you have the necessary libraries installed in your Arduino IDE.

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

// Replace with your network credentials
const char* ssid = "Your_SSID";
const char* password = "Your_PASSWORD";

// FAVORIOT settings
const char* serverName = "https://apiv2.favoriot.com/v2/streams";
const char* accessToken = "Your_DEVICE_ACCESS_TOKEN"; // Use the Access Token from FAVORIOT

#define TEMP_SENSOR A0
#define VIBRATION_SENSOR D1

void setup() {
  Serial.begin(115200);
  pinMode(VIBRATION_SENSOR, INPUT);
  
  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");
}

void loop() {
  // Read temperature from LM35
  int tempReading = analogRead(TEMP_SENSOR);
  float voltage = tempReading * (3.3 / 1024.0);
  float temperature = voltage * 100.0; // LM35 outputs 10mV per degree Celsius

  // Read vibration sensor state
  int vibrationState = digitalRead(VIBRATION_SENSOR); // 1 = no vibration, 0 = vibration detected

  // Prepare JSON payload
  String jsonPayload = "{";
  jsonPayload += "\"device_developer_id\": \"vehicle_sensor_node\",";
  jsonPayload += "\"data\": {";
  jsonPayload += "\"temperature\": \"" + String(temperature) + "\",";
  jsonPayload += "\"vibration\": \"" + String(vibrationState) + "\"";
  jsonPayload += "}}";

  // Send data to FAVORIOT
  if (WiFi.status() == WL_CONNECTED) {
    HTTPClient http;
    http.begin(serverName);
    http.addHeader("Content-Type", "application/json");
    http.addHeader("accessToken", accessToken); // Use 'accessToken' as the header key

    int httpResponseCode = http.POST(jsonPayload);
    if (httpResponseCode > 0) {
      String response = http.getString();
      Serial.println("Response: " + response);
    } else {
      Serial.println("Error in HTTP POST: " + String(httpResponseCode));
    }
    http.end();
  } else {
    Serial.println("WiFi Disconnected");
  }

  delay(15000); // Send data every 15 seconds
}

📊 Visualizing Data on FAVORIOT Dashboard

  1. Access Data Streams:
    • Navigate to Data Streams > My Data Stream to view incoming data from your device.
  2. Create Dashboard:
    • Go to Dashboard > My Dashboard.
    • Click on + Create Dashboard and provide a name and description.
  3. Add Widgets:
    • Within your dashboard, click on + Widget to add visual components:
      • Line Chart: Plot temperature over time.
      • Gauge: Display real-time temperature.
      • Indicator: Show vibration status (e.g., Normal or Alert).

📈 Analyzing Data for Predictive Maintenance

  • Vibration Analysis:
    • Continuous readings of vibration = 0 may indicate abnormal vibrations or potential mechanical issues.
  • Temperature Monitoring:
    • Consistently high temperatures (e.g., above 80°C) can signal overheating components.

By setting up Rules in FAVORIOT, you can trigger alerts or notifications when certain thresholds are crossed, facilitating proactive maintenance.


🚀 Further Enhancements

  • GPS Integration: Add a GPS module to log the vehicle’s location alongside sensor data.
  • Machine Learning: Utilize historical data to train models that predict failures before they occur.
  • Notifications: Integrate with messaging services to send real-time alerts to maintenance teams.

References

Disclaimer

This article provides a step-by-step guide and only serves as a guideline. The source code may need adjustments to fit the final project design.


Feel free to reach out if you have any questions or need further assistance setting up your predictive maintenance system using FAVORIOT.


Podcast also available on PocketCasts, SoundCloud, Spotify, Google Podcasts, Apple Podcasts, and RSS.

One response

  1. […] Predictive Vehicle Maintenance Based on Sensors and FAVORIOT Objective: To implement a system that uses temperature and vibration sensors, uploading the data to the FAVORIOT platform to identify damage patterns and schedule early maintenance. […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This

Share this post with your friends!

Discover more from IoT World

Subscribe now to keep reading and get access to the full archive.

Continue reading