The machine condition monitor: hear a bearing failing weeks before it stops the line.
A pump bearing seizes on a Friday night. The line stops, the spare is two days away, and the weekend's orders go out late. Looking back, the warning was there for weeks: the machine was shaking a little more every day, and nobody was measuring it.
Build a small monitor for that motor or pump. It feels the vibration three thousand times a second, turns it into the numbers a vibration analyst reads first, and tells the right person when the machine starts to change.
What you end with
A motor or pump that reports its condition every minute: how hard it is shaking (velocity in mm/s, in three directions), which zone that is, whether impacts are showing, the main frequencies, the bearing temperature, and how long and how often it runs. You get an alert when the zone changes, when the vibration has doubled from the machine's own normal, and when the monitor goes quiet.
What you need
Rough prices for single parts bought online, in
Get the parts wherever suits you: a local electronics shop, or online. Pick a shop and each Find it link searches there.
| # | Part | Qty | About |
|---|---|---|---|
| 1 | ESP32 DevKitAny 30 or 38 pin boardFind it | 1 | KSh 650USD 5.00 |
| 2 | ADXL345 accelerometer (GY-291)3 axes, 3200 samples a second on SPIFind it | 1 | KSh 260USD 2.00 |
| 3 | Pot magnet, 32 mmFlat face; the sensor is glued on its steel topFind it | 1 | KSh 325USD 2.50 |
| 4 | DS18B20 temperature probeSteel probe on a 1 m cableFind it | 1 | KSh 195USD 1.50 |
| 5 | Current clamp (optional)SCT-013-030, 1 V at 30 A, for running hours from the currentFind it | 1 | KSh 650USD 5.00 |
| 6 | Shielded cable, 8 coreFrom the sensor to the box; 1 m or lessFind it | 1 m | KSh 260USD 2.00 |
| 7 | Perfboard and parts4.7 k, two 10 k, 10 µF, screw terminalsFind it | 1 | KSh 130USD 1.00 |
| 8 | PG7 cable glandsFor 3 to 6.5 mm cablesFind it | 4 | KSh 260USD 2.00 |
| 9 | Two-part epoxyHard setting, to fix the sensor to the magnetFind it | 1 | KSh 260USD 2.00 |
| 10 | USB cable and 5 V adapter1 A or moreFind it | 1 | KSh 520USD 4.00 |
| 11 | Screws4 x M3 x 10 for the lid, 2 for the frameFind it | 6 | KSh 130USD 1.00 |
| 12 | PETGCopes with a warm motor roomFind it | 150 g | KSh 390USD 3.00 |
| Total | KSh 4,030USD 31 |
Also: a 3D printer, a soldering iron, aluminium tape, and an account on siliconwit.io (free).

The design, in 3D and on paper
Turn it, open Parts to hide the lid or the pod cap, and use Section to cut through the box and the sensor pod. The parts carry the numbers of the parts list.

Build it
Each step links to the lesson section that teaches it. Open one only when you need it.
Tick each step as you finish it. Your place is kept, so you can stop and come back.
Kept on this device. Sign in to keep it on every device.Kept with your account.
Wire it on the desk
Wire it on the desk first, and fit it to the machine only when it works.
- Keep the sensor cable under 1 m and shielded, with the shield to GND at the box end only. Long SPI wires near a motor drive pick up noise.
- The clamp goes round one wire of the motor supply, not the whole cable. The SCT-013-030 has its burden inside, so its leads are safe to leave open.
Make the sensor pod
- Sand the steel top of the pot magnet clean. Glue the ADXL345 board flat on it with a thin layer of hard two-part epoxy, chip side up. Nothing soft (foam tape, a plastic spacer) goes between the chip and the steel.
- Mark the board's x and y arrows on the magnet: you will line them up with the machine.
- Solder the shielded cable to the board, and put the printed cap over it, with the cable through the side hole. A ring of silicone holds the cap and keeps oil out.
Every layer between the machine and the chip is a spring, and a spring makes the reading too large near its own resonance. A thin hard glue line on a steel magnet keeps that resonance well above 1 kHz; a flat magnet on a flat, clean pad is usually good to a few kilohertz.
Flash and check on the desk
Open machine_monitor/machine_monitor.ino, choose ESP32 Dev Module, and install PubSubClient, ArduinoJson (version 7), OneWire and DallasTemperature. Compiled with the esp32 core 4.0.0: 1.11 MB of flash (84 % of the default app space), 64 KB of RAM for global data, and about 130 KB taken from the heap at start for the sample blocks and the spectra. No warnings from the sketch.
How it works: a task of its own empties the sensor's 32-sample buffer every 4 ms into a block of 4096 samples (1.28 s). For each block and each direction, the board takes a Hann-windowed FFT, divides each line by 2πf to turn acceleration into velocity, and adds up the lines from 10 Hz to 1 kHz. Gravity, slow tilt and drift never enter, because they sit below 10 Hz. The DSP was tested on a laptop with signals of known size; the tolerance is 2 %:
velocity: 15.0 Hz, 2.00 mm/s in -> 1.989 mm/s (0.54 %)velocity: 50.0 Hz, 1.40 mm/s in -> 1.407 mm/s (0.52 %)velocity: 903.0 Hz, 4.50 mm/s in -> 4.500 mm/s (0.00 %)drift: 50 Hz at 2.8 mm/s with gravity, a 0.3 Hz tilt and a 5 Hz sway reads 2.800 mm/snoise: 400 ug/sqrt(Hz) reads 0.197 mm/s on its own; under 1.40 mm/s it reads 1.415 mm/speaks: 200.0 Hz 4.00 mm/s, 25.0 Hz 3.00 mm/s (sum 5.00 mm/s)crest: sine 1.414 (sqrt 2 = 1.414); with impacts 5.01v reads about 0.2 mm/s (the sensor's own noise). Stand it on a running desk fan's base: v rises, and f1 sits near the fan's turning speed in turns a second.Print the box and the pod cap
PETG, 0.2 mm layers, 4 walls, 20 % infill, no supports. About 150 g in all.
| Part | Lay it |
|---|---|
| Box | On its back, open side up. 101 x 147 mm with its ears. |
| Lid | Front face down, skirt up. |
| Pod cap | Closed top down. |
Every cable enters the box from below through a gland, the lid's skirt hangs 6 mm over the walls, and a weep hole lets condensation out. Checked in FreeCAD 1.1: the board, its USB plug and the perfboard fit, and the cap clears the magnet and the sensor board.
Fit it to the machine, stopped
- With the machine stopped, isolated and locked off, pick a flat spot on the bearing housing, as close to the bearing as you can: on the drive end of a motor, or the pump's bearing nearest the impeller. Clean off paint flakes, rust and oil.
- Touch one edge of the magnet down and roll it onto the spot. Do not let it snap on: the shock can damage the sensor, and it can trap a finger.
- Line the board's x arrow up horizontal, across the shaft, and y vertical; z then points along the shaft. Mark the spot with paint, so the sensor goes back in the same place after any work.
- Press the DS18B20's steel probe against the housing beside the pod, under a strip of aluminium tape.
- Mount the box on the frame or a wall, not on the machine. Run both cables through their glands, clear of every moving part, and tie them down.
Connect it
On siliconwit.io, our monitoring service: Add Device, then Define my own device, with the fields of the reading below, and a data interval of 60 seconds. Copy the Device ID and Access Token into these lines, with your Wi-Fi above them, and upload again:
const char* MQTT_HOST = "mqtt.siliconwit.io";const int MQTT_PORT = 8883; // MQTT over TLSconst char* DEVICE_ID = "SWD-XXXXXX"; // client ID, username, and the topic nameconst char* MQTT_PASS = "your-access-token"; // the Access Token#define USE_TLS 1 // 0 only for a test broker on your own network: then port 1883, and no certificateOne reading a minute, on d/<device-id>/t. Features only: the waveform stays on the board.
{"v":2.31,"v_x":2.31,"v_y":1.64,"v_z":0.82,"zone":2,"a_rms":0.071,"a_peak":0.31,"crest":3.10, "f1":24.6,"p1":2.02,"f2":49.2,"p2":0.91,"f3":98.4,"p3":0.40,"temp":41.5,"running":1, "run_h":1032.50,"starts":214,"trend":1.12,"ts":1795000630}The link is MQTT over TLS on port 8883, with the ISRG Root X1 certificate in the sketch. After a failed connect it waits 5, 10, 20, 40, then 60 seconds. While the network is down it keeps up to 12 hours of short readings and sends them later with their own times. A watchdog restarts the board if the code gets stuck; the sampling task keeps going while the board reconnects. Your own Mosquitto broker works the same: change the broker lines, as on the live sensor node.
Set the zones, and let it learn its normal
The standards for machine vibration (ISO 20816, which replaced ISO 10816) sort the velocity on a bearing housing into four zones:
The boundaries depend on the machine's size and its foundation. The sketch starts with the values often quoted for medium machines (15 to 300 kW) on rigid foundations: 1.4, 2.8 and 4.5 mm/s. Check the standard for your machine, and any limit from its maker, and set yours:
// --- your machine ---float ZONES[3] = {1.4f, 2.8f, 4.5f}; // mm/s: the A/B, B/C and C/D boundaries for your machine's classfloat RUN_MM_S = 0.6f; // above this the machine counts as running (the sensor's own noise is about 0.2)const float BASE_HOURS = 24; // running hours that make the machine's own baselineA table knows the class, not your machine. So for its first 24 running hours the board learns the machine's own level, and then sends trend: today's level over that baseline. A machine that sits in zone A but has gone from 0.9 to 1.8 mm/s has doubled, and something in it has changed. After a repair, send rebaseline:
d/SWD-XXXXXX/c {"command":"zones","value":[2.3,4.5,7.1],"session":"a1"}d/SWD-XXXXXX/k/a1 {"status":"ok"}d/SWD-XXXXXX/c {"command":"rebaseline","session":"a2"} after a repaird/SWD-XXXXXX/k/a2 {"status":"ok"}d/SWD-XXXXXX/c {"command":"zones","value":[4,2,1],"session":"a3"}d/SWD-XXXXXX/k/a3 {"status":"error","message":"zones must be three rising values in mm/s, such as [1.4,2.8,4.5]"}Set the alerts
Email alerts come with the free account; SMS with the Business plan. Send each one to the person who can act on it:
zone 3 or more, held for 30 minutes: plan the repair Zone Dzone equal to 4, held for 10 minutes: decide about stopping, today Doubledtrend above 2, held for an hour: the machine has changed Running hottemp above your limit, held for 15 minutes Not reportingthe device silent for 10 minutes "Held for" keeps one knock or one start from waking anyone. The last alert matters as much as the others: a monitor that has lost its power cannot say so itself.
Read the record
- The trend over weeks is the warning. A slow rise, week on week, gives you time to order the part and plan the stop, instead of finding out on a Friday night.
- The lines point to the cause. A large line at the turning speed (1×) often means unbalance; a large 2× with high axial (
v_z) often means misalignment; many multiples can mean looseness. Confirm with an analyst before you act on it. - Crest factor rising while
vstays flat is a hint of impacts, worth a closer look by someone with a wide-band sensor. - Running hours and starts plan the greasing and the service by use, not by the calendar.
You are done when
- On the desk,
vreads about 0.2 mm/s at rest and rises on a running fan, withf1near its speed. - On the machine, all three directions report, and
runningfollows the machine on and off. - The zone, the temperature and the running hours arrive every minute, and
trendappears after 24 running hours. - An alert reaches your phone when you unplug the monitor for ten minutes.
- You have marked the measuring point, and the sensor goes back there after any work on the machine.
Downloads
- Build sheet: parts, wiring and the steps on two A4 pagesmachine-condition-monitor-build-sheet.pdf · 91 KB
- Firmware: Arduino sketch, DSP, testsmachine-condition-monitor-firmware.zip · 19 KB
- Print files (STL) and print notesmachine-condition-monitor-stl.zip · 76 KB
- Drawings: the assembly, then the box, the lid and the pod cap, with every size in mm (4 A3 sheets)machine-condition-monitor-drawings.pdf · 147 KB
- FreeCAD 1.1 model, with the spreadsheetMachineConditionMonitor.FCStd · 40 KB
- STEP, every part and moduleMachineConditionMonitor.step · 213 KB
- Wiring drawingmachine-condition-monitor-wiring.svg · 19 KB
Checked: the firmware compiles for the ESP32 with no warnings from the sketch, with and without TLS and the clamp. Its DSP (the FFT, velocity RMS from sines of known size, drift, sensor noise, crest factor, peaks, zones, running hours and the baseline) passes 30 checks on a laptop, within 2 %. The parts were checked in FreeCAD 1.1. A build on a real machine, beside a calibrated vibration meter, is next: if your readings differ, tell us in the discussion below.
References
- Time Waveform, Overall Levels and Severity: the overall level, zones A to D and crest factor.
- Sensors, Mounting and Measurement Points: what a MEMS sensor can and cannot see, and why mounting decides.
- Trending, Alarm Limits and Baselines: limits from the machine's own history.
- Envelope Analysis: how bearing defects are found, with the wide-band sensor this build does not have.
- ISO 20816-1 and ISO 20816-3: machine vibration, measurement and evaluation; the zone boundaries for your machine class.
- Analog Devices ADXL345 data sheet: 3200 samples a second, full resolution 3.9 mg a count, and the SPI timing.
Ways to take this build
Fitted and watched by us
Our engineers fit the sensors, watch the readings and send a monthly record of what it found and saved.
Start with one siteKSh 15,000USD 150 for the build
Four video meetings over about six weeks: plan it, show progress, show it working. Ends in a project record anyone can check.
Build it with a supervisorOpen to all
Every step, the firmware and the printable files. Tick the steps as you go.
Start step 1Priced for the group
Your staff or students build the machine condition monitor together, with reviews and a record for each person.
Ask for a groupPlus opens the worked answers in the lessons each step links to: see Plus.
Made by
Engineers who build what they teach, and answer for it.



My notes on this page
Kept on this device. To have them on every device, turn on keeping in My notes.
Tip: select words in the lesson, or tap a figure or an equation, to put a note right there.
Notes on earlier wording
The lesson has changed and these words are no longer in it. Your notes are kept, with the words you chose.