Slouch once. Get sprayed. Sit up forever.
A reminder you can ignore is not a reminder. Day 24 proved that on my own laptop: the Posture Nagger dims the screen when I slouch for more than 10 seconds, and I learned to squint through the dimming and keep slouching. So this is the same detector with a different ending. Same MediaPipe Pose shoulder-to-hip angle, same 20-degree line, same 10-second hold. This time the consequence is physical: a Raspberry Pi, a small water pump and a spray bottle. Slouch for 10 seconds and the chair sprays your shoulder. Every number in this post comes from the simulated demo, run on a laptop with no Pi, no pump and no water. No chair was involved. No coffee was reached for in anger.
Why a Screen Dim Is Not Enough
The Posture Nagger works, in the narrow sense that it notices. It watches the angle between your shoulders and your hips, and when that angle passes 20 degrees from vertical for 10 seconds, it dims the screen and tells you to sit up. The problem is that the punishment is negotiable. You can lean closer to the dim screen. You can turn the brightness back up. You can, and I did, treat the nag as background noise and carry on slouching, now with a darker screen.
A spray is not negotiable. Water on your shoulder is a fact, not a notification. It does not ask for your attention, it takes it. That is the whole idea: take the detector from Day 24, which was already tested and already worked, and bolt a consequence onto it that you cannot dismiss with a keypress. Underneath the joke it is the same engineering as a dozen real devices: a sensor, a threshold, a hold timer so brief movements do not trigger it, and a cooldown so it does not fire non-stop.
What You Need
You need a Raspberry Pi, any model that runs Python 3; a webcam; a small 5 V water pump and a spray bottle or nozzle; a relay module to switch the pump, because the Pi’s GPIO pins cannot drive a pump directly; a manual kill switch, a plain push button; a few jumper wires, a water bottle as the reservoir, and a power supply for the Pi.
The code uses only the Python standard library for the demo, so there is nothing to install to run it. MediaPipe and OpenCV are only needed for the live webcam mode. If you do not have a Pi yet, you can still build this on a laptop. The simulated mode feeds the sprayer a scripted sequence of 20 posture frames with known angles and writes the same spray log a real chair would write. That is how I tested it, and where every number in this post comes from.
Water spray only, aimed at the shoulder, never at the face or at electronics. A manual kill switch on GPIO 23 stops spraying immediately. No taser, no shock, no laser, nothing that fires at a person or a pet. The pump moves 12 ml a second and runs for 2 seconds per spray, so one spray is 24 ml: a splash, not a soaking.
How It Works
A camera, an angle, a timer, and a pump.
MediaPipe Pose finds your shoulder and hip landmarks in each webcam frame. The torso angle is the angle between the line from your hips to your shoulders and straight up, exactly as Day 24 measured it. Sit upright and your shoulders sit almost directly above your hips, so the angle is small: 7 to 15 degrees in the demo data. Slouch and your shoulders drift forwards, and the angle grows to 27 to 33 degrees. The line is 20 degrees. At or past it, you are slouching.
Then the hold timer. Crossing the line for a second does not spray you. Reaching for your coffee crosses the line, and so does leaning forwards to read a small font, and neither of those deserves water. So the timer starts when the angle first crosses 20 degrees and resets the moment you sit up. Only a slouch that lasts 10 continuous seconds tries to fire, and it tries exactly once per slouch episode.
Then the cooldown. After a spray, the chair stays dry for 30 seconds even if you slouch again. Without it, a long slouch would mean a spray every 10 seconds, and you would be soaked before your posture improved. A blocked attempt is still written in the spray log, marked as blocked, with the seconds of cooldown left. On a real Pi, sprayer.py drives the pump relay on GPIO 18 for 2 seconds. On a laptop, python3 simulate.py runs the demo, with 20 scripted frames on a virtual timeline of 103 seconds.

The Maths
Here it is, with the real numbers from the simulated demo, and nothing else. The demo checked 20 frames: 12 upright, 8 slouched. The 8 slouched frames form 3 episodes, and all three lasted past the 10-second hold:
- Episode 1: t = 10 s to 22 s, 12 seconds, angles 28 and 31 degrees. The hold crossed at t = 20 s, so it sprayed at t = 20 s.
- Episode 2: t = 57 s to 71 s, 14 seconds, angles 29, 33 and 30 degrees. The hold crossed at t = 67 s, so it sprayed at t = 67 s.
- Episode 3: t = 81 s to 98 s, 17 seconds, angles 27, 32 and 29 degrees. The hold crossed at t = 91 s, so it tried to spray at t = 91 s.
Episode 2 sprayed because 35 seconds of upright sitting passed between the two episodes, from t = 22 s to t = 57 s, which clears the 30-second cooldown. Episode 3 did not spray, because only 24 seconds had passed since the second spray: 91 − 67 = 24, and 30 − 24 = 6 seconds of cooldown were still left at t = 91 s. So the count is 3 episodes over 10 seconds, 2 sprays fired, 1 blocked by the cooldown.
The water maths is one multiplication. The pump moves 12 ml per second and runs for 2 seconds per spray, so one spray is 12 × 2 = 24 ml. Two sprays is 2 × 24 = 48 ml in total. The whole virtual timeline is 103 seconds: 60 seconds upright and 43 seconds slouched, because 12 + 14 + 17 = 43. The spray rate is 2 out of 3 episodes, or about 67 percent, and the one that got away is the cooldown doing its job, not a miss: the detector saw the slouch, the timer fired, and the pump stayed off on purpose.

Build It
Wire the pump first, while the Pi is off. Connect the relay module to GPIO 18 and the pump’s power through the relay, so the Pi only ever switches the relay, never the pump directly. Aim the nozzle at shoulder height, from the side, and point it away from the screen, the keyboard and your face. Wire the kill switch between GPIO 23 and ground. Fill the reservoir, put a towel down for the first test, and keep the Pi itself out of the splash zone.
The folder holds sprayer.py (torso angle, slouch timer, spray trigger and cooldown), simulate.py (the scripted 20-frame demo), config.py (threshold, hold, spray, cooldown and pump settings), requirements.txt (stdlib only for the demo; MediaPipe and OpenCV only for live mode), README.md, and sample_data/, with the demo spray log in JSON and CSV. Three Python files, each doing one job: settings, the brain, and the demo.
The settings live in config.py:
SLOUCH_ANGLE_DEG = 20.0
HOLD_SECONDS = 10.0
SPRAY_SECONDS = 2.0
COOLDOWN_SECONDS = 30.0
PUMP_RATE_ML_PER_S = 12.0
WATER_PER_SPRAY_ML = 24.0
PUMP_RELAY_PIN = 18
KILL_SWITCH_PIN = 23The spray decision lives in sprayer.py. It takes one frame at a time, as an interval with a start and an end, and returns "spray", "blocked" or None exactly once per slouch episode:
def update(self, slouching, start_s, end_s):
if slouching and self.slouch_start is None:
self.slouch_start = start_s
self.triggered_this_episode = False
elif not slouching and self.slouch_start is not None:
self.episodes.append((
self.slouch_start, start_s,
round(start_s - self.slouch_start, 2),
"sprayed" if self.triggered_this_episode and
self._last_outcome == "spray" else
("blocked" if self.triggered_this_episode else "too short"),
))
self.slouch_start = None
self.triggered_this_episode = False
if (slouching and self.slouch_start is not None
and not self.triggered_this_episode
and end_s - self.slouch_start >= config.HOLD_SECONDS):
self.triggered_this_episode = True
trigger_time = round(self.slouch_start + config.HOLD_SECONDS, 2)
self.last_trigger_time = trigger_time
if (self.last_spray_time is None
or trigger_time - self.last_spray_time
>= config.COOLDOWN_SECONDS):
self.last_spray_time = trigger_time
self.sprays_fired += 1
self.water_ml += config.WATER_PER_SPRAY_ML
self._last_outcome = "spray"
return "spray"
self.sprays_blocked += 1
self._last_outcome = "blocked"
return "blocked"
return NoneThe demo in simulate.py is the scripted sequence, 20 frames with a known angle and duration each:
SCRIPTED_FRAMES = [
(8, 5), # 1 upright
(12, 5), # 2 upright
(28, 6), # 3 slouch -- episode 1 starts at t=10
(31, 6), # 4 slouch -- episode 1 ends at t=22 (12 s)
(10, 8), # 5 upright
(14, 7), # 6 upright
(9, 6), # 7 upright
(11, 5), # 8 upright
(13, 9), # 9 upright -- 35 s upright since episode 1
(29, 5), # 10 slouch -- episode 2 starts at t=57
(33, 4), # 11 slouch
(30, 5), # 12 slouch -- episode 2 ends at t=71 (14 s)
(7, 3), # 13 upright
(12, 2), # 14 upright
(10, 3), # 15 upright
(15, 2), # 16 upright -- only 10 s upright since episode 2
(27, 6), # 17 slouch -- episode 3 starts at t=81
(32, 5), # 18 slouch
(29, 6), # 19 slouch -- episode 3 ends at t=98 (17 s)
(9, 5), # 20 upright
]Run the demo on any laptop, with no Pi and no hardware:
python3 simulate.pyThere is nothing to install first: requirements.txt is empty on purpose for the demo, and MediaPipe and OpenCV are only needed for the live webcam mode. To run it for real, copy the folder to the Pi, install the requirements, point the webcam at your chair, and run the live mode. Press the kill switch, or Ctrl+C, to stop it.


Expected Outcome
Here is the actual output of the simulated demo, from python3 simulate.py:
Slouch Sprayer -- simulated demo
Threshold: 20 deg | Hold: 10 s | Spray: 2 s | Cooldown: 30 s | Pump: 12 ml/s
Simulating 20 scripted frames...
Frame 1 t= 0.0- 5.0s 8 deg upright —
Frame 2 t= 5.0- 10.0s 12 deg upright —
Frame 3 t= 10.0- 16.0s 28 deg SLOUCH —
[SPRAY] Pump on for 2 s (24 ml)
Frame 4 t= 16.0- 22.0s 31 deg SLOUCH SPRAYED at t=20s
Frame 5 t= 22.0- 30.0s 10 deg upright —
Frame 6 t= 30.0- 37.0s 14 deg upright —
Frame 7 t= 37.0- 43.0s 9 deg upright —
Frame 8 t= 43.0- 48.0s 11 deg upright —
Frame 9 t= 48.0- 57.0s 13 deg upright —
Frame 10 t= 57.0- 62.0s 29 deg SLOUCH —
Frame 11 t= 62.0- 66.0s 33 deg SLOUCH —
[SPRAY] Pump on for 2 s (24 ml)
Frame 12 t= 66.0- 71.0s 30 deg SLOUCH SPRAYED at t=67s
Frame 13 t= 71.0- 74.0s 7 deg upright —
Frame 14 t= 74.0- 76.0s 12 deg upright —
Frame 15 t= 76.0- 79.0s 10 deg upright —
Frame 16 t= 79.0- 81.0s 15 deg upright —
Frame 17 t= 81.0- 87.0s 27 deg SLOUCH —
Frame 18 t= 87.0- 92.0s 32 deg SLOUCH blocked by cooldown (6.0 s left at t=91s)
Frame 19 t= 92.0- 98.0s 29 deg SLOUCH —
Frame 20 t= 98.0-103.0s 9 deg upright —
--- Spray log ---
Frames checked: 20 (12 upright, 8 slouched)
Slouch episodes over 10 s: 3 (12.0, 14.0, 17.0 s)
Sprays fired: 2
Sprays blocked by cooldown: 1
Water used: 48 ml (24 ml per spray)
Total virtual time: 103 s
Log entries: 20
Spray log written to logs/spray-log.json and logs/spray-log.csv
Demo finished in 0.00 seconds (wall clock)If your run prints the same 20, 12, 8, 3, 2, 1 and 48 ml, yours works. The spray log has 20 entries, one per frame: frames 4 and 12 are the sprays, frame 18 is the blocked attempt, and the rest are quiet. The episodes are (10–22 s, sprayed), (57–71 s, sprayed) and (81–98 s, blocked). On a real Pi, the outcome is the same shape with messier numbers. If it sprays once per long slouch and stays dry for 30 seconds after, it works. If it sprays every time you reach for your coffee, your hold time is too short. If it never sprays, check the angle first: sit up, check the reading is under 20, then slouch and check it is over.
What Broke
Two things broke while I was building this. The first was a timing bug, and it is why the sprayer takes a frame as an interval with a start and an end, instead of a single timestamp. My first version fed the sprayer the frame’s end time, so a slouch that started at t = 10 s was recorded as starting at t = 16 s, when its first frame ended. The episodes came out as 14, 12 and 16 seconds instead of 12, 14 and 17, and only 1 spray fired instead of 2, because the second episode measured 9 seconds of hold instead of 10. The demo output disagreed with the script I had written, and the script was right. So the sprayer now takes the whole interval, the slouch starts at the frame’s start time, and the trigger lands at the exact hold time: slouch start plus 10 seconds. A timestamp that means “when the frame ended” is not the same as “when the slouch started”, and using one for the other silently moves every event by a frame.
The second break was a design mistake, and it is the reason the log records blocked attempts instead of only sprays. My first version only wrote a log entry when the pump fired. That felt tidy, until I looked at the demo and realised the report said 2 sprays for 3 long slouches, with no trace of the third. A log that only records the wet events is a highlight reel, not a record. So every frame gets an entry, and a blocked attempt gets its cooldown seconds left written down next to it. The third episode is the most interesting one in the demo, precisely because nothing happened.
One honest limitation, from the same angle Day 24 has: the detector cannot tell slouching from leaning forwards on purpose. Reaching for your coffee, leaning in to read a small font, and slouching all push your shoulders forwards past 20 degrees. The 10-second hold is what saves you from most of those, because a reach lasts a second or two, but a long reach for something on a low shelf would still spray you. That is a real false positive, and the fix is a second check, like the neck angle Day 24 reports, or a longer hold for the first spray of the day. I did not add either here, because the demo is about the sprayer, not about perfect posture detection, and a reader who copies the hold time from config.py should know what it does and does not protect them from.
Download the Full Project
The full project is in the download below: sprayer.py, simulate.py, config.py, requirements.txt, README.md, and the sample spray log in JSON and CSV, from the 20-frame simulated demo. Unzip it, run python3 simulate.py, and check your output matches the one above: 20 frames, 12 upright, 8 slouched, 3 episodes over 10 seconds, 2 sprays fired, 1 blocked by the cooldown, 48 ml of water.
Premium Download
Get the complete project code
Then change one number in config.py and run it again. Set the cooldown to 5 seconds and watch the third episode spray too. Set the hold to 20 seconds and watch all three episodes stay dry. Your chair will still be judging your posture, just on your terms.
