SafeDrive makes drivers feel what their passengers feel
Drivers rarely notice their own hard braking, sudden starts or sharp turns. SafeDrive recognises these moves on its own chip. In the app, Tofu the buddy floats and spins with every move the car makes.
- Role
- Individual project · hardware, ML, firmware, app
- Timeline
- Spring 2026
- Built with
- ESP32-S3, motion sensor, OLED
- Status
- Working prototype, tested in cars
In this project, you can see how I designed everything from the model on the chip to the character on the phone.
Why I built it
Bad driving is easy to feel and hard to say.
Have you ever sat in a car where every stop throws you forward?
Hard braking, sudden starts and sharp turns are easy to do and easy to forget. To change a habit, drivers need to notice it the moment it happens. They also cannot look away from the road to read a report. What helps is feedback that arrives right away and needs no reading.
Meet Tofu, the passenger in your phone.
While you drive
Nothing to read on the road. Tofu reacts to each move with motion, a sound and a short voice line. The score drops by the same points the box takes off.
Getting started
Onboarding page design
Setting up the box feels like meeting a friend. Tofu shows each rule instead of explaining it.
After you park
Look back kindly, one tip at a time.
The good parts come first, then one tip per kind of moment. A sudden stop may have been the right call, so Tofu never blames.
Over the week
Every drive is saved, so progress shows.
Each trip goes into the journal with its score, so drivers can see how their week is going and whether they are getting smoother.
Designing Tofu
How I work with AI to design Tofu
I built the app with Claude Code and gave Tofu a voice with ElevenLabs. AI brought speed and volume; taste and every final call stayed with me. The work moved through five stages, and the middle two looped many times.
- The background, and who it is for
- Which direction is worth pursuing
- A critique, with references and sketches
- How each moment should feel
- The final call
- Research and a plan to approve
- Many options, fast
- A redraw that matches what I showed
- Working code, motion and sound
- A voice in the tone I asked for
-
1Frame
Give AI the context before asking for anything.
MeThe background, who the user is, the flow they go through, and the look I want.
AIResearches similar apps and comes back with a plan for me to approve.
SafeDrive is pure hardware, and its only screen shows a number… Design a phone app for people who just bought the box… Look at similar apps first, then show me a plan.
-
2Go wideClaude Code
Get many options fast, then find the spark.
AIThree directions on the same screens, and a lineup of characters and faces.
MePick what is worth pursuing and merge the best parts: B’s tone, C’s ribbon, A’s gauge.
-
Steer and build looped until it felt right
-
3SteerClaude Code
Show it, don’t just tell it.
MeCritique every version, and send a screenshot or a sketch when words fall short.
AIRedraws the version to match what I showed.

A reference I sent -
4Build and feelClaude Code
The build shows what a still screen can’t.
AIA working app with motion and sound.
MeRide along and react. Too polite? Make it slam forward like a roller coaster.
-
-
5Voice and polishElevenLabs
Give Tofu a voice and the right words.
AIVoice lines in the tone I asked for: tense, not cheerful.
MeCompare options side by side and make the final call.
Behind the app · Hardware
Behind Tofu: hardware I designed and built.
- In the momentA fresh check on your driving every two seconds
- At a glanceOne score from 0 to 100, plus the move it just noticed
- Works offlineNo network needed: every prediction runs on the chip
- Compact buildA thumb-sized board and a motion sensor, on battery power
From a jolt in the car to a score on the screen.
Every two seconds, SafeDrive reads how the car moved. A small machine-learning model names the move. Then a few simple rules decide whether it costs points.
A motion sensor feels the car 50 times a second.
An MPU-6050 measures how the car speeds up and turns, in six directions. It shares one pair of wires with the screen on a XIAO ESP32-S3 board.
- Rate
- 50 Hz
- Axes
- ax ay az · gx gy gz
- Window
- 100 samples = 2 s
Two seconds of motion become 78 numbers.
A spectral-analysis step in Edge Impulse describes how strongly and how quickly the car moved in each direction, so the model gets a short summary instead of 600 raw readings.
- Input
- 600 values
- Features
- 78
- Block
- Spectral analysis
Labeled windows per class
- Sharp turn482
- Normal400
- Hard brake371
- Idle250
- Rapid accel.226
1,729 windows · axis 0–500
A small neural network names the moment.
It picks one of five moments and says how sure it is. When it is less than 60% sure, SafeDrive counts the window as normal driving. An unsure guess never costs points.
- Model
- Edge Impulse default NN
- Quantized
- int8
- Measured
- 6.01 ms per window
- 100Start score, at power-on
- −3Hard brake, confirmed
- −2Rapid acceleration, confirmed
- −2Sharp turn, confirmed
- +0.5Each minute that ends on normal or idle, up to 100
Simple rules decide what costs points.
A risky moment counts only when it shows up three times in a row. The score stays between 0 and 100. See the rules play out on a recorded log ↓
The result shows on the box and in the app.
The box’s small screen shows the score in large type and the move it just noticed. It also counts hard brakes, quick starts and sharp turns. In the SafeDrive app, Tofu acts out the same move and the score drops by the same points.
- Refresh
- Every window, about 2 s
- Screen
- SSD1306, two-colour
How I collected and labeled the data
All the data comes from a real car. I took the hardware into the car and drove on a safe, closed stretch of road. There I recorded many rounds of hard braking, quick starts and sharp turns, plus normal driving and idling. Five sessions between April 15 and 19, 2026 gave about 48 minutes of 50 Hz motion data.
A Python logger I wrote reads the board’s motion stream over USB. One key press sets the label for every new line:
LABEL_KEYS = {
"n": "normal",
"b": "hard_brake",
"a": "rapid_acceleration",
"t": "sharp_turn",
"i": "idle",
}
with label_lock:
label = current_label
row = parts + [label]
rows_buffer.append(row)
Excerpt from serial_logger.py. Each row is timestamp_ms, ax, ay, az, gx, gy, gz, label.
A second script cut the recordings into 2-second windows and uploaded them to Edge Impulse. A window was kept only if at least 80% of its samples shared one label. Risky moments are short, so their windows start every 0.2 s. Normal and idle windows start every second, capped at 400 and 250. The windows were split 80/20 into training and test sets at random, per label.
Fitting a machine-learning model on a tiny chip.
The model has to live on the board. So I trained five versions that change two things. One is how much driving it sees at once: 1, 1.5 or 2 seconds. The other is how compactly it stores its numbers: int8 or float32. All five fit easily, so I chose on accuracy.
Deployed
A · 2-second window, int8
The longest window and the best validation score. This is the model on the device.
- Validation
- 79%
- Training
- Not logged
- Est. inference
- ~1 ms
- Est. model flash
- 15.9 KB
- Seeing more helpedAccuracy rose from 63% to 72% to 79% as the window grew from 1 to 2 seconds. A brake or a turn needs more than a second of context.
- Compact did not mean worseAt 2 seconds, the compact int8 version scored 79% against 71% and ran about twice as fast in Edge Impulse’s estimate.
- I kept the number I could repeatThe first run showed 92%. Retraining kept landing at 79%, so I report 79%.
See the full comparison and the first run
| Config | Window | Stored as | Training | Validation | Est. inference | Est. RAM | Est. flash |
|---|---|---|---|---|---|---|---|
| A · deployed | 2000 ms | int8 | — | 79% | ~1 ms | ~1.4 KB | ~15.9 KB |
| B | 1000 ms | int8 | 78% | 63% | ~1 ms | ~1.4 KB | ~15.9 KB |
| C | 1500 ms | int8 | 80% | 72% | ~1 ms | ~1.4 KB | ~15.9 KB |
| D | 2000 ms | float32 | 82% | 71% | ~2 ms | ~1.4 KB | ~11.4 KB |
| E | 1000 ms | float32 | 71% | 44% | ~2 ms | ~1.0 KB | ~17.8 KB |
From my sweep log. Training accuracy was not logged for A. Resource figures are Edge Impulse estimates for the model alone; on the device A measured 6.01 ms per inference.
Only a repeated warning costs points.
One guess can be wrong: a pothole can look like a hard brake. If every guess took points away, the score would feel unfair and jumpy. So SafeDrive waits until it sees the same risky moment three times in a row before it counts it.
Replay of a recorded drive log
Score:100
normal
HB:0 RA:0 ST:0
OLED layout redrawn from the firmware. Counters start at 0 for this excerpt.
Press Play or Step to walk through 22 recorded windows, about 44 seconds.
- Unsure means normalBelow 60% confidence, the moment is shown as normal.
- Two is not enoughTwo hard brakes then normal cost nothing. Three in a row cost 3 points.
- Then it starts overA long event costs points once, not every two seconds.
Read the scoring code and the original log
if (label == last_label) {
debounce_counter++;
} else {
debounce_counter = 1;
last_label = label;
}
// Confirm event only when consecutive predictions reach threshold
if (debounce_counter == DEBOUNCE_COUNT) { // DEBOUNCE_COUNT = 3
if (label == "hard_brake") {
score = max(0.0f, score - PENALTY_HARD_BRAKE); // 3.0
count_hard_brake++;
} ...
debounce_counter = 0; // so the same event doesn't keep penalising
}
Excerpt from 04_full_system.ino. Normal and idle labels reset the streak before this runs. The +0.5 bonus is checked once a minute against the label at that moment.
It works in a real car, sharp turns included.
I put the finished device on a car dashboard and drove with it. Sensing, the model, the rules and the screen all ran on the board. On recordings it never trained on, it named about three in four moments correctly. Sharp turns were the move it caught most reliably.
Named correctly, by moment
- Sharp turn82.5%
- Idle80%
- Normal77.5%
- Hard brake73.3%
- Rapid accel.65.2%
See the test output, resources and parts
Accuracy is counted per 2-second window across five recording sessions. Windows overlap and were split at random, so a brand-new drive may score a little lower. 6.01 ms covers the model alone; a penalty needs three windows, about six seconds.
| Resource | Used | Available | Share |
|---|---|---|---|
| Flash | 429 KB | 3.2 MB app partition | 13% |
| RAM (static) | 27.6 KB | 320 KB | 8% |
| Model alone (estimate) | 15.9 KB flash · 1.4 KB RAM | — | — |
Battery: from datasheet currents I estimated about 10 hours on a 1000 mAh LiPo, above the 7-hour target. I have not measured it yet.
| Part | Price |
|---|---|
| XIAO ESP32-S3 | $14.00 |
| MPU-6050 motion sensor | $15.99 |
| 1000 mAh LiPo battery | $7.99 |
| Total listed | $37.98 |
The OLED screen is not on the budget sheet.
Feedback
What people said.
For hardware and a model this small, the accuracy is already very high. There is not much to fault.
There is a real market for this. Many insurance companies already put devices like it in cars.
This is really cool. The app feels friendly, and I would want it on my own phone.
From idea to market
Who needs it most, and how I would prove it.
-
1
Friends & family
Friends and family who want to drive smoother for the people in their car try it for a few weeks.
MeasureHard brakes per hour, first week vs last
-
2
New ride-hail drivers
New drivers, and drivers with low ratings. Passengers rarely tell a driver they feel sick; they just leave a low rating. SafeDrive tells the driver first.
MeasureChange in passenger rating
-
3
Pitch with data
Smoother drivers mean better ratings. I bring the pilot numbers to ride-hail and map apps.
MeasureDrivers still using it after a month
What the product needs on the way
Tofu beside any navigation
Most people drive with a map open. With CarPlay, Tofu could sit as a small card next to any navigation app. It would react to each move, so drivers never have to leave the map.
More drivers, more roads
Everything so far came from my own recordings. Data from more people, cars and road conditions would let the model hold up on drives it has never seen.
The business plan
Passengers don’t complain. They just leave a low rating. SafeDrive tells the driver first.
- Who it’s forNew ride-hail drivers and drivers with low passenger ratings
- What they getKnow what passengers feel, without being told to their face
- How it makes moneyA subscription for drivers, or a license per fleet
Lead with the feeling. The first weeks are free, so the first drive sells it.
Lead with pilot numbers, and start as a feature inside their app.
Appendix
Explore the build
I modelled the enclosure in Fusion 360 and 3D-printed it. My files keep three saved versions of the lid, body and side lid; the window in the lid frames the OLED.
| Part | Role | Connection |
|---|---|---|
| XIAO ESP32S3 Sense | Runs the model, rules and display | SDA D4 · SCL D5 |
| MPU-6050 (GY-521) | 6-axis motion | I²C 0x68 |
| SSD1306 128×64 OLED | Score display | I²C 0x3C |
| 1000 mAh LiPo | Power | — |
The app’s design previews, kept as they were written.
Early explorations
The app’s design previews, kept as they were written.
FAQ
Questions people ask
Why not just use the phone’s motion sensor?
I started from hardware because I wanted to build the sensing myself, from the sensor to the model on the chip. A phone has the same kind of motion sensor, so next I want to try SafeDrive on the phone alone. Then anyone could use it without buying a device. See the hardware ↑
Isn’t an app distracting while driving?
I designed the drive screen so drivers don’t need to read it. Tofu reacts with motion, a sound and a short voice line, so drivers can hear it without looking. Scores and tips only show up after they park. I’m also exploring Tofu as a small card inside navigation apps or CarPlay, so drivers can know how the ride feels at a glance without opening a separate app. See Tofu in action ↑ · See Tofu beside navigation ↑
How accurate is it, and on what data?
On data it never trained on, it got 76.7% right, and 79.1% on validation. All the data came from my own drives: five sessions, 48 minutes. Sharp turns were the easiest to recognize, quick starts the hardest. See the full results ↑