Excessive motor vibration? How to collect data with ESP32
Learn how to monitor industrial motor vibrations using piezoelectric sensors and low-cost microcontrollers to predict failures before factory downtime.
Summary
- Vibration sensors capture imperceptible mechanical oscillations that indicate premature wear in industrial bearings and shafts
- The ESP32 microcontroller processes high-frequency readings thanks to its dual-core processor and native Wi-Fi connectivity
- The fast Fourier transform decomposes the vibration signal into specific frequencies to identify mechanical defects with precision
- Predictive maintenance systems reduce unplanned downtime costs by anticipating replacements of critical parts
- Integrating low-cost hardware democratizes asset monitoring in small and medium-sized manufacturing plants
Why motors vibrate and how it breaks the factory
In modern industry, any rotating machine generates some baseline level of natural vibration due to mechanical movement. However, when this oscillation exceeds safe limits, it becomes the clearest symptom that something is going wrong inside. Worn bearings, misaligned shafts, or unbalanced rotors start shaking at specific frequencies. In practice, this means the machine is slowly destroying itself, leading to costly unplanned downtime.
To avoid unpleasant surprises during a shift, maintenance engineering has shifted from reactive repair models to predictive ones. Instead of replacing parts based on calendar time or waiting for smoke to appear, technicians monitor asset health in real time. Just like we discussed modernizing industrial systems in our article on how to read old meters using ESP32 and artificial intelligence, the key lies in extracting data from legacy or low-cost hardware to feed intelligent decisions.
Choosing the ideal hardware to capture movement
The core of a vibration monitoring system is the accelerometer, a small electronic component capable of measuring physical acceleration and gravity across multiple axes. For industrial applications, ordinary capacitive sensors cannot handle the high vibration frequencies of high-RPM electric motors. We need fast-response MEMS accelerometers or robust piezoelectric sensors capable of recording thousands of samples per second without losing fidelity.
On the processing side, the ESP32 emerges as a fantastic choice due to its unbeatable ratio of cost, processing power, and wireless connectivity. With dual processing cores running at 240 MHz, it can read sensor data via I2C or SPI buses without stuttering, while maintaining a stable Wi-Fi connection to stream telemetry packets to a central dashboard or cloud database.
Building the ESP32 data collection circuit
Physical assembly requires careful attention to the mechanical coupling between the sensor and the motor casing. If the sensor is loose or secured with weak tape, it will measure the vibration of the poorly secured mount itself, generating false positives. On the test bench, we connect the ADXL345 or MPU6050 accelerometer to the dedicated serial communication pins of the microcontroller, ensuring a stable 3.3V power supply.
The code running on the microcontroller must be optimized to prevent buffer overflows during continuous reading. For those already familiar with resilience in distributed systems, such as applying circuit breakers, remember that edge hardware must also be tolerant of network failures. If Wi-Fi drops, the ESP32 must temporarily store critical readings in internal flash memory before attempting retransmission.
Processing the vibration signal with functional code
Collecting raw acceleration data is not very useful if we do not know how to interpret it. The signal gathered from the motor shaft is a complex wave mixing multiple frequencies at once. To separate background noise from the actual signature of a damaged bearing, we apply lightweight mathematical algorithms directly inside the microcontroller firmware or send the batch for external processing.
#include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_ADXL345_U.h> Adafruit_ADXL345_Unified accel = Adafruit_ADXL345_Unified(12345); void setup(void) { Serial.begin(115200); if(!accel.begin()) { Serial.println("ADXL345 sensor not found!"); while(1); } accel.setRange(ADXL345_RANGE_16_G); } void loop(void) { sensors_event_t event; accel.getEvent(&event); Serial.print("X: "); Serial.print(event.acceleration.x); Serial.print(" | Y: "); Serial.print(event.acceleration.y); Serial.print(" | Z: "); Serial.println(event.acceleration.z); delay(50); }Analyzing frequencies to anticipate mechanical failures
When looking solely at total vibration amplitude, we might miss the onset of a localized problem. This is where spectral analysis comes in, transforming the signal from the time domain to the frequency domain. Each internal motor component — fan blades, bearing balls, gear teeth — has a characteristic rotation frequency that leaves a unique signature on the spectrum.
In practice, if the frequency corresponding to bearing ball pass begins to show abnormal energy spikes, the maintenance team knows exactly which part to order before the motor starts making audible noises on the factory floor. This foresight radically transforms operations, eliminating the element of surprise during maintenance windows.
Integrating collected data with monitoring platforms
Collecting thousands of samples per second is pointless if the data remains trapped in the ESP32 memory. The final stage of the architecture involves continuously sending this information via lightweight protocols like MQTT to a local broker or cloud server, where visualization tools display motor behavior in real time.
With trend charts and automated alerts configured, any deviation in vibration triggers an immediate notification on the responsible engineer's phone. This automation ensures the plant operates at maximum efficiency, cutting energy costs caused by mechanical friction and significantly extending equipment lifespan. To complement this implementation in production environments, see our related technical analyses on Unstable AI? How to use DSPy to structure prompts and Unstable Node.js API? How to apply circuit breaker.
Final considerations on predictive monitoring with microcontrollers
Using affordable microcontrollers like the ESP32 for industrial vibration monitoring proves that cutting-edge technology does not need to be prohibitively expensive or overly complex for everyday factory floors. By combining reliable sensors, efficient code, and a solid connectivity strategy, any company can implement a robust predictive maintenance system.
Investing time in the correct collection and interpretation of this data means transforming potential scrap into continuous uptime. Modern engineering demands decentralized intelligence at the edge, allowing every motor to tell its own story before asking for help.