Scream for Coffee. It Works. Unfortunately.
Scream for coffee. It works. Unfortunately.
In Day 18, the Roomba screamed at you. The scream was the output — the robot’s way of complaining about your floor. This is the opposite machine. Here the scream is the input. A microphone listens, a loudness gate decides whether you meant it, and only a real shout starts the timer. Talk normally and nothing happens. Laugh at it and nothing happens. Scream at it, properly, and it gives you 30 seconds of coffee. Three good screams earn a full cup. Nobody asked for this. I built it anyway.
Every number in this post comes from the simulated demo, run on a laptop with a scripted loudness track. No microphone, no Pi, no actual screaming. The track is printed in full below, so you can run it yourself and get the same count.
Why a Timer Needs a Throat
A coffee timer has one button and zero respect for effort. You press it, it counts down, you get coffee. The button does not care whether you are awake, whether you want the coffee, or whether you have earned it in any sense at all. It is the most honest appliance in the kitchen and also the most boring.
The problem is not that the button works. The problem is that it works too easily. Anything worth having should cost you something, and the cheapest currency I own is embarrassment. So the button is gone. In its place is a microphone and a rule: the timer only starts when the room gets loud enough, for long enough, that you cannot do it by accident. You want coffee, you announce it to the house. That is the whole product. It is stupid, and it works, and those two facts are not in conflict.
Underneath the joke it is the same engineering as a dozen real devices: a sensor, a threshold, a minimum duration, and one action on a confirmed signal. A smoke alarm does this. A baby monitor does this. A voice assistant does this, badly, every time it wakes up because the television said something that sounded like its name. The difference is that those devices try to be polite about false alarms. This one is not polite. It is just strict.
What You Need
You need a Raspberry Pi, any model that runs Python 3; a USB microphone, pointed at you and not at the kettle; a relay board or a GPIO pin driving a low-voltage indicator LED; and, if you want it to switch anything real, a smart plug with its own safety rating that takes the trigger from the Pi. The code uses only the Python standard library for the demo, so there is nothing to install to run it. Live microphone mode needs sounddevice and numpy, listed in requirements.txt.
This is a timer, not a kettle. It never switches mains power directly. The relay drives a low-voltage indicator, or the trigger input of a smart plug with its own safety rating — the smart plug does the actual switching. Do not wire mains into a breadboard because a blog post told you to. No shouting at neighbours is required either: the demo track is synthetic, and your real build only needs you to shout in your own kitchen, once, to calibrate it.
How It Works
A microphone, a gate, and a timer. Three parts, each doing one job.
The microphone produces one loudness reading per second, in decibels. The gate compares each reading to the threshold of 85 dB. A reading at or above 85 counts as loud; anything under it counts as quiet. But one loud second is not a scream. A door slamming is one loud second. A dropped pan is one loud second. So the gate also demands duration: a scream is a run of at least 2 consecutive seconds above the threshold. Shorter than that and the gate logs it as a rejected spike and moves on.
When a run qualifies, it is a burst, and a burst starts the timer. Each burst earns 30 seconds of brew time. The brew target is 90 seconds, so three bursts earn exactly one coffee. The timer is a small state machine with three states: IDLE, BREWING, and DONE. It sits in IDLE listening. The first burst moves it to BREWING and starts the credit counting. More bursts add more credit. When earned seconds reach 90, it moves to DONE, the relay fires, and the coffee is earned. Reset takes it back to IDLE for the next cup.
The settings live in config.py:
THRESHOLD_DB = 85
MIN_BURST_SECONDS = 2
BURST_CREDIT_SECONDS = 30
BREW_TARGET_SECONDS = 90
TRACK_SECONDS = 60
RELAY_GPIO_PIN = 17The gate lives in scream_timer.py. It takes one reading at a time and only speaks up when a run ends, so a long scream is reported once, not once per second:
class LoudnessGate:
def __init__(self, threshold_db=None, min_burst_seconds=None):
self.threshold_db = (
config.THRESHOLD_DB if threshold_db is None else threshold_db
)
self.min_burst_seconds = (
config.MIN_BURST_SECONDS
if min_burst_seconds is None
else min_burst_seconds
)
self._run_start = None
self._run_peak = None
self.bursts = []
self.spikes_rejected = 0
self.readings_above = 0
def feed(self, second, db):
if db >= self.threshold_db:
self.readings_above += 1
if self._run_start is None:
self._run_start = second
self._run_peak = db
else:
self._run_peak = max(self._run_peak, db)
return None
return self._close_run(second)When the run closes, the gate decides: long enough to be a burst, or a spike to reject:
def _close_run(self, second):
if self._run_start is None:
return None
duration = second - self._run_start
peak = self._run_peak
start = self._run_start
self._run_start = None
self._run_peak = None
if duration >= self.min_burst_seconds:
burst = {
"start_s": start,
"end_s": second - 1,
"duration_s": duration,
"peak_db": peak,
}
self.bursts.append(burst)
return {"type": "burst", **burst}
self.spikes_rejected += 1
return {
"type": "spike_rejected",
"start_s": start,
"duration_s": duration,
"peak_db": peak,
}The timer itself is small enough to read in one go. A burst starts it, or tops it up if it is already running, and reaching the target flips it to DONE and fires the relay:
class CoffeeTimer:
IDLE = "IDLE"
BREWING = "BREWING"
DONE = "DONE"
def __init__(self):
self.state = self.IDLE
self.earned_seconds = 0
self.timer_starts = 0
self.coffees_earned = 0
def on_burst(self, burst):
self.timer_starts += 1
self.earned_seconds += config.BURST_CREDIT_SECONDS
if self.state == self.IDLE:
self.state = self.BREWING
if self.earned_seconds >= config.BREW_TARGET_SECONDS:
self.state = self.DONE
self.coffees_earned += 1
set_relay(True)
return self.state
Why 85 dB
The threshold is the whole device, so it deserves a real reason, not a round number I liked.
Normal conversation at one metre is about 60 dB. A loud laugh is about 80 dB. A shout is about 88 to 90 dB. Put the line at 85 and it sits in the gap between laughing and shouting: laughing at your coffee will not start it, shouting will. Set it at 80 and every good joke brews a cup. Set it at 95 and you need a scream that hurts, every morning, before you have had coffee, which is when you least want to perform.
85 is also the standard workplace hearing-protection action level — the point where an 8-hour exposure gets safety paperwork. It is a number people have already met, which makes it easier to trust than a number I invented. Your kitchen is not a factory floor, and the calibration step matters more than the default: shout once, read the number your mic reports, and set the threshold a few dB under your real shout and well above your normal voice. The default is a starting point, not a law.
The Maths
Here it is, with the real numbers from the simulated demo, and nothing else. The demo ran a scripted 60-second track — one dB reading per second, 60 readings — through the same gate and timer the Pi build uses. Out of those 60 seconds, 44 were quiet (33 to 38 dB), 12 were burst seconds, 3 were near-miss readings, and 1 was the rejected spike. That adds up: 44 + 12 + 3 + 1 = 60.
The three bursts:
- Burst 1: t=10–12, 3 seconds, 88, 94, 91 dB, peak 94. Timer start #1, 30 seconds earned, state BREWING.
- Burst 2: t=30–33, 4 seconds, 90, 96, 92, 89 dB, peak 96. Timer start #2, 60 seconds earned, still BREWING.
- Burst 3: t=50–54, 5 seconds, 87, 93, 95, 90, 88 dB, peak 95. Timer start #3, 90 seconds earned, state DONE.
Total timer seconds earned: 3 bursts × 30 seconds = 90 seconds. The brew target is 90 seconds, so the demo earned exactly one coffee, with nothing left over. That is not a coincidence — the target was set so that three bursts is one cup. Two bursts would have earned 60 seconds and left you 30 short, staring at a timer that refuses to round up.
The near-misses are the interesting part. Two events, three readings, all under the line: 82 dB at t=20, then 84 and 83 dB at t=42–43. The 84 dB reading is the one to look at. It missed the threshold by exactly 1 dB, which sounds like nothing. It is not nothing. Decibels are logarithmic: every 10 dB multiplies the sound intensity by 10. So 1 dB is a factor of 10 raised to 0.1, which is about 1.26 — the 84 dB near-miss carried about 26 percent less sound intensity than the 85 dB threshold. Close in decibels, still under the line, still no coffee. The gate does not grade on effort.
The spike is the other interesting part. At t=24 the track hits 97 dB — louder than any of the three real bursts, louder than anything else in the whole minute. It lasted exactly one second, and the gate rejected it. In the first version of this gate, without the duration rule, that spike would have started the timer. One dropped pan, one coffee. That is a false start, and the demo had zero of them: 3 bursts, 3 timer starts, 0 false starts.
The loudness maths, for the record: the 12 burst seconds averaged 91.1 dB. The peak burst reading was 96 dB, which is 11 dB over the threshold — 10 raised to 1.1, or about 12.6 times the sound intensity of the 85 dB line. And 13 of the 60 readings were above the threshold in total: the 12 burst seconds plus the 1-second spike. Thirteen loud seconds, three bursts, one coffee.

The Demo Track
Printed in full, because a demo you cannot reproduce is a story, not a test. This is the exact track simulate.py feeds the gate:
TRACK_DB = [
34, 36, 33, 37, 35, 38, 34, 36, 35, 37, # t=0-9 quiet
88, 94, 91, # t=10-12 BURST 1
36, 38, 35, 37, 34, 36, 35, # t=13-19 quiet
82, # t=20 near-miss 1
37, 35, 36, # t=21-23 quiet
97, # t=24 1-s spike
36, 38, 35, 37, 34, # t=25-29 quiet
90, 96, 92, 89, # t=30-33 BURST 2
36, 35, 37, 38, 34, 36, 35, 37, # t=34-41 quiet
84, 83, # t=42-43 near-miss 2
36, 35, 37, 34, 36, 35, # t=44-49 quiet
87, 93, 95, 90, 88, # t=50-54 BURST 3
36, 35, 37, 34, 36, # t=55-59 quiet
]Copy it into simulate.py, run python3 simulate.py, and you should get the same count: 3 bursts, 3 timer starts, 0 false starts, 1 spike rejected, 2 near-miss events, 90 timer seconds earned, 1 coffee. If you change the threshold to 80, the near-misses become bursts and the demo earns its coffee a lot more easily — which is exactly how you find out your threshold is wrong. The demo writes the full per-second log to sample_data/loudness-log.json and .csv, so you can check every second against the track above.

What Broke
The first version of the gate had a threshold and nothing else. One loud second started the timer. I tested it against the track above and it gave me 4 timer starts instead of 3 — the 97 dB spike at t=24, one second of what was supposed to be a dropped pan, earned 30 seconds of coffee. That is the exact failure a threshold-only design has in a real kitchen: the loudest thing in the room is rarely a person. It is a cupboard door, a dropped mug, the kettle clicking off. A gate that fires on volume alone will brew coffee every time you unload the dishwasher.
The fix was the minimum burst duration: 2 consecutive seconds above the threshold. A door slam is over in one second. A scream is not. The spike still gets logged — the log says spike_rejected, peak 97 dB, 1 second — but it never touches the timer. The demo now reports 0 false starts, and the spike is the proof the duration rule exists, not a number I hid.
The second thing that broke was subtler. My first near-miss test used 86 dB readings, which are above the threshold, so they were bursts, not near-misses — I had written the test wrong and the demo “passed” by testing nothing. The near-misses in the final track are 82, 84 and 83 dB, all genuinely under the 85 dB line, with the 84 sitting exactly 1 dB short. If your test data cannot fail, it is not a test. It is a decoration.
The third thing is a limit, not a bug, and I am stating it plainly: the demo is synthetic. No real microphone was involved, no real room, no real kettle, no real neighbours. A real mic in a real kitchen will report different numbers for the same shout depending on distance, the mic, and whether the dishwasher is running. That is why the build instructions start with calibration, not with the default threshold. The demo proves the logic. Only your kitchen can prove the threshold.
Build It
Build it with the power off. Put the Pi somewhere the mic can hear you and cannot hear the kettle directly — pointing a microphone at a boiling kettle is how you brew coffee every time the water boils. Wire the relay output on GPIO 17 to a low-voltage indicator LED first, and watch it: scream, LED on, timer counting. Only then connect the trigger input of a rated smart plug, and never wire mains directly.
Then calibrate. Shout once at the mic from where you actually stand in the morning and read the number. Talk normally and read that number too. Set THRESHOLD_DB between them, closer to your shout. Run python3 simulate.py first to confirm the gate behaves on the scripted track, then swap in live_listen() from scream_timer.py for the real mic.
The folder holds scream_timer.py (the loudness gate, the timer state machine, the relay output, and live mic mode), simulate.py (the scripted 60-second demo), config.py (threshold, burst length, timer credit, brew target), requirements.txt (standard library only for the demo; sounddevice and numpy for live mode), README.md, and sample_data/, with the demo loudness log in JSON and CSV. Three Python files, each doing one job: settings, the brain, and the demo.

Expected Outcome
You get a timer that only starts when you shout at it, and a log that proves it. The demo’s outcome, run and verified: 60 seconds in, 3 bursts detected, 3 timer starts, 0 false starts, 1 spike rejected, 2 near-miss events, 90 timer seconds earned, 1 coffee. Your kitchen will be noisier and less tidy than the track, and that is fine — the track is the test, not the kitchen. Calibrate the threshold, keep the 2-second rule, and the only false starts you get will be the ones you perform on purpose.
And when it works — when you shout at a small plastic box at seven in the morning and it rewards you with coffee — you will understand why this project exists. Not because a button is hard. Because a button never made you laugh at yourself before breakfast. This one does, every single time. Unfortunately.
Download the Full Project
The full project is in the download below: scream_timer.py, simulate.py, config.py, requirements.txt, README.md, and the sample loudness log in JSON and CSV, from the 60-second simulated demo. Unzip it, run python3 simulate.py, and check your output matches the one above: 3 bursts, 3 timer starts, 0 false starts, 90 timer seconds earned, 1 coffee.
Premium Download
Get the complete project code ZIP
