Skip to content
SpinSafe

SpinSafe

Edge AI for Predictive Maintenance

Created on 8th March 2026

•

SpinSafe

SpinSafe

Edge AI for Predictive Maintenance

The problem SpinSafe solves

Industrial motors and heavy machinery are the backbone of modern infrastructure, but they suffer from a critical flaw: they fail silently. By the time a human operator hears a grinding bearing, feels excessive vibration, or smells burning coils, the catastrophic damage is already done. This leads to massive financial losses from unplanned downtime, expensive emergency repairs, and severe workplace safety hazards.

Traditional monitoring systems simply push raw data to a dashboard and rely on humans to spot the trends. SpinSafe changes the paradigm by shifting maintenance from reactive to predictive using an autonomous, closed-loop Edge AI system.

Here is how SpinSafe makes existing industrial tasks easier, safer, and smarter:

Eliminates Unplanned Downtime: Instead of waiting for a machine to break, SpinSafe monitors micro-fluctuations in 3-axis vibration (MPU6050), thermal drift, and current load. It detects the invisible precursors to failure—like early-stage friction or rotor imbalance—allowing teams to schedule maintenance before a breakdown occurs.

Self-Learning Edge Intelligence: The biggest problem with static alarms is that every motor has a different baseline. SpinSafe solves this with a 10-second dynamic AI learning loop. The local Python Edge Gateway constantly analyzes live telemetry, re-trains a Decision Tree algorithm, and pushes custom thresholds back to the ESP32. It literally learns what "Healthy" looks like for that specific machine and adapts its fault detection in real-time.

Enhances Operational Safety: Mechanical stalls and rapid overheating are massive fire risks. SpinSafe features hard-coded safety lockouts that instantly cut power to the motor via a MOSFET if critical thresholds are breached, protecting both the equipment and the human operators nearby.

Democratizes Predictive Maintenance: Enterprise-grade ML monitoring usually costs thousands of dollars and requires massive cloud computing power. SpinSafe achieves localized, high-speed machine learning using affordable microcontrollers and a local hotspot, making advanced AI diagnostics accessible to small factory floors, HVAC maintainers, and hobbyist machinists.

Automated Auditing: By seamlessly integrating with Google Sheets via Webhooks, it replaces manual clipboard inspections with automated, second-by-second digital logging, creating a perfect paper trail for safety audits.

SpinSafe doesn't just tell you a motor is broken; it tells you exactly why it's going to break, long before it actually happens.

Challenges we ran into

  1. The "Ghost" MPU6050 (I2C Addressing & Sleep States)

Initially, the standard Adafruit_MPU6050 library completely failed to initialize the sensor. The hardware was stuck in a sleep state and wouldn't respond to the default 0x68 I2C address pings, causing the entire system to halt.

I had to bypass the high-level library and write a "Brute Force" register-level initialization. I programmed the ESP32 to manually scan the I2C bus, locate the sensor, and send a raw byte (0x00) directly to the MPU6050's Power Management 1 register (0x6B). This successfully forced the chip to wake up before handing control back to the Adafruit library.

  1. Phantom Loads & Current Sensor Calibration

The ACS712 current sensor is highly sensitive to magnetic noise and voltage drift. Even when the motor was completely turned off, the Blynk dashboard was registering a 45% load due to the sensor sitting at 2.52V instead of a perfect 2.5V baseline.

I implemented an Auto-Calibration Boot Sequence. When the ESP32 powers on, it takes 50 rapid samples of the current sensor while the MOSFET is explicitly pulled LOW (motor off). It averages these readings to establish a dynamic "True Zero" offset. I also added a software "noise gate" to ignore fluctuations under 0.35A, resulting in a perfectly clean 0% load reading when idle.

  1. The "Null State" Data Gap in the AI Loop

Because the Python Edge Gateway retrains the Decision Tree every 10 seconds, there was a gap right at bootup. The ESP32 would request the AI state before the first model was compiled, resulting in a null reading that broke the Blynk Status Bar and OLED display.

I modified the Python script to instantly generate a default model.json file with a "HEALTHY" state the millisecond the server boots. On the ESP32 side, I added JSON parsing error handling with a fallback string, ensuring the dashboard always displays a clean state, even if the Wi-Fi or local server momentarily drops.

  1. Asynchronous Loop Timing & RPM Accuracy

Calculating RPM using a simple pulseCount * 60 logic worked poorly when I integrated the heavy HTTPS Google Sheets logging and the 10-second AI sync. The loop duration fluctuated, causing massive RPM spikes (e.g., jumping to 16,000 RPM erroneously).

I abandoned fixed-loop timing and moved to a Time-Delta calculation (duration = currentMillis - lastRPMMillis). By calculating exactly how many milliseconds passed between pulse checks, the RPM became 100% accurate regardless of how long the ESP32 took to parse JSON or ping the cloud.

  1. Handling Google Sheets Strict HTTPS Redirects

Pushing data directly from an ESP32 to Google Sheets is notoriously difficult because Google App Scripts force multiple strict HTTPS redirects, which standard Arduino HTTP clients fail to follow.

I integrated the WiFiClientSecure library and used setInsecure() to bypass heavy SSL certificate validation (saving crucial memory on the ESP32). I then explicitly enabled HTTPC_STRICT_FOLLOW_REDIRECTS in the HTTPClient, allowing the microcontroller to successfully chase the Google redirects and log the data flawlessly.

Tracks Applied (1)

Internet of Things(IoT)

Technologies used

Discussion

Builders also viewed

See more projects on Devfolio