Inspiration
Buildings fail at their connections, and they usually tell you first; the problem is they do it in a language nobody is listening to. A structure has a natural frequency set by its stiffness, so when a joint slips or a bolt backs out, the whole building starts ringing at a slightly lower note. This is a real method, called operational modal analysis, and it is used on bridges and tall buildings.
The part that is hard isn't noticing that something is wrong. It's finding out where. One frequency can only tell you the structure got softer somewhere. I wanted to find out whether three cheap accelerometers and some careful signal processing could point at the specific floor.
What it does
Tap the roof of a three-story steel-and-plywood tower and it rings. That ring carries the structure's frequencies, its damping, and its mode shape; how much each floor moves relative to the others. Loosen one bolted connection and all three change, each floor in a different and repeatable way.
Heartbeat learns those patterns once, then reports live on a console: whether the frame is sound, how far from sound it is, and which floor's connection has loosened. It updates within about four taps of you changing something, with a true accuracy of 89% or better at 95% confidence.
Tapping the building emulates movements that real buildings experience. When you tap the building, it responds with frequencies that we can measure to determine structure. Real buildings experience this same kind of force, but from natural factors. Wind, traffic, machinery, footsteps, distant construction, and micro-tremors in the ground cause buildings to sway and move around.
How I built it
Hardware. Four steel columns, a plywood base and three plywood floors, joined through corner braces with wing nuts, chosen because a wing nut is a connection you can loosen by hand by a repeatable amount and then tighten back. Three different accelerometers, one per floor, daisy-chained over a single I²C bus to an ESP32-S2 Feather. No soldering.
Firmware. Talks to all three sensors' registers directly rather than through driver libraries, and streams timestamped CSV at exactly 200 samples per second.
Detection. Every tap is measured on its own and the last 14 are pooled into a fingerprint of ten numbers. Three ideas carry it:
- Two frequencies, not one. The first bending mode bends mostly in the bottom story, so it is nearly blind to damage at the top; the third mode is the opposite. Watching both separates "something is loose" from "it is loose up there".
- Mode shape in three frequency bands. How far each floor moves per unit of roof motion, measured separately around 8, 18 and 34 Hz. This is what finally told level 2 and the roof apart. On the first mode alone they look nearly identical.
- Slip sensitivity. A tight bolted joint behaves the same however hard you hit it. A loose one slips, and the slip grows with the force, so its damping rises with tap strength while a tight joint's stays flat. Because it is a trend rather than a value, it doesn't care how hard you tapped.
Locating the fault then uses the direction the fingerprint moved rather than the distance it moved, because loosening a nut further pushes the same pattern further without changing its shape. That change alone took it from failing below half the trained severity to being correct down to a quarter of it.
Console. A local web dashboard showing a structural elevation of the tower with the faulty member highlighted, each sensor's live frequency, a 60 fps three-channel signal trace, and a live response spectrum computed in the browser.
Challenges I ran into
Building a structure with no power tools. No drill, no saw bench. Just a hacksaw, aviation snips, a file, an awl and two clamps. I chose 16-gauge perforated steel flat bar for the columns specifically because it comes pre-punched, so every connection could be bolted instead of drilled. Four 15½ in columns came out of two three-foot bars, cut with snips and then filed flat so the floors would seat square rather than rocking.
Level 2 and the roof were being swapped. Not weakly detected, but systematically reversed. The first mode barely distinguishes them, and that was all I was measuring the mode shape on. Adding the two upper frequency bands took held-out accuracy from 9/16 to 16/16.
One reading in eight was being thrown away. The console showed 175 Hz when the board was sending exactly 200. My reader thread was taking a lock for every single sample while the analysis thread held the same lock, so the serial buffer overflowed. Frequency is computed by counting samples, so losing 12% of them dragged every measurement 12% low — against a tolerance of about 1%. Rebuilt so the two threads share nothing mutable, and added a check that reads the board's own timestamps to catch it if it ever happens again.
The dashboard kept dying at random. Python writes a bare NaN into JSON, every browser refuses to parse it, and one unmeasurable number was killing the entire page. It only happened when my taps were all the same strength, which made it look random.
Accomplishments that I'm proud of
Every number in the project is measured rather than claimed, and the ones that didn't work out are in the write-up too. The accuracy figure comes with its confidence interval rather than being rounded up to 100%.
Beyond that: slip sensitivity is a feature I didn't expect to find. It came out of pushing back on my own assumption that inconsistent tapping was a problem to eliminate. It turned out to be signal, and it is the one indicator that works on a joint it has never seen loosened.
What I learned
That the interesting part of a sensing project is almost never the sensor. The accelerometers worked in an hour. Everything after that was physics — which modes respond to which story — and discipline about validating on data the model hadn't seen.
I also learned how easy it is to build something that looks like it works. Several versions were confidently and consistently wrong, and the only reason I know is that I kept held-out data and tested against it.
What's next for Heartbeat
Detecting more than one loose connection at a time; the current version correctly refuses to guess when the pattern matches nothing it knows. Compensating for temperature, which shifts a real building's frequency about as much as moderate damage does and is the central open problem in this field. And validating on a second, differently built tower, to show the method transfers rather than having been tuned to this one.
Built With
- accelerometer
- arduino
- c++
- css
- esp32
- fft
- html
- i2c
- javascript
- numpy
- pyserial
- python
- scipy