You are probably helping someone who built PoolWind and has a problem, or
someone trying the demo (on a Windows PC) before building. These
notes give you the background the author’s own development sessions built
up, so you don’t have to rediscover it. Read the relevant guide in docs/
too; it is written for the builder and is the authority on how things are
meant to be set up.
LICENSE.md). The author does not provide support. Don’t suggest the
user contact him, and don’t open GitHub issues or Discussions posts for
them unless they ask. Discussions (linked in the README) is where builders
help each other.poolwind.py or a settings file, make a dated copy of it.
Keep changes small and tell the user exactly what changed.poolwind.py; the
previous one is kept as poolwind.py.previous. Local changes to the
program are lost on update, so note them for the user. The settings
and calibration files are never overwritten.PoolWind drives a real swimming current. A mistake can put someone in a jet faster than they can handle.
'Demo': True line, with a real valve, or any script using
GPIO 17, 18 or 27)
without the user’s go-ahead, and only when they confirm nobody is in
the pool. For code and screen problems, use the demo ('Demo': True)
or desk testing (setup guide, section 8): simulated valve, recorded video.'Demo' is built in as True only on a computer without the
Pi’s relay and sensor libraries (lgpio is None: the Windows demo), and
False on the Pi: since 2026-11-02 a Pi install controls the pool from
its first start, and the shipped defaults file has no 'Demo' line. A
demo is the sample video, the pool screen and a simulated jet, no relay
connected, whatever else the files say (App._read_defaults_file);
'Demo': True in the main defaults file (not a USB stick) is a
developer option on the Pi, and anything but False there means a demo.
Keep the PC side a demo always. Without the voltage sensor, the Pi
stops at start with a box (check the board, i2cdetect -y 1).pace_voltage) are the jet’s limits (App._safety_limits,
since v15.6; an old SafetyVoltageLimits line is ignored): the last row
is the hard ceiling on jet speed, whatever any pace setting says. Never
add rows above it to fix some other problem, and never remove the checks
that enforce it. The limits and jet steps always come from the pool’s
table, never from a swimmer’s table on a USB stick.pump_pin_check reads it
at start with the Pi’s pull-up and pull-down; a floating pin (R6/R3 not
fitted) stops PoolWind and the calibration with a box. PumpSwitch
presses On/Off until the line follows, watching it for up to
PUMP_SETTLE_S (5 s) after each press before deciding (since v15.12: a
line read once at 0.5 s was sometimes still high while the pump stopped,
and the second press turned it back on; poolwind_pump_log.txt records
the times): on, one press (the button goes back if it didn’t start);
off, pressed again for up to 30 s, then
pump_manual_off_box asks for the other remote, with nothing sent to
the pool while it’s open (_remote_locked; the pool turns its pump
off after 30 minutes without a signal), and no more automatic pump moves
after (_pump_hands_off). The pump monitor (_pump_monitor_tick)
pauses the swim (Suspend) while the pump is off and resumes it when it’s
back, and with no swimmer for 5 minutes turns the pump off and closes
PoolWind after a 30 s “Keep swimming” box. Closing with the pump on
shows “Pump still running” (Shut Down / Exit) after the window has gone;
a new start clears it (clear_pump_running_box, SIGTERM via a pid
file). Keep all of these.initial_voltage_winddown, a box with
the voltage) at start and close (App.shutdown), when OnOff is pressed,
before it presses the pump relay (switch_pump), and when leaving the
pool screen for the calibration or Swim Plot (Set Swim Area leaves the
swim running: the new corners count once saved). Since v15.10 it stops
at the swimmer’s slowest zone (to_swimmer), as leaving the swim zone
does; only before turning the pump on (pump_on=True) does it go to
the jet’s lowest step. It never drives up. Turning the pump off, the box’s
Stop pump now button stops it so the pump turns off at once, for
emergencies; it can never start the pump. Any
change you make must keep these, along with the relay watchdog
(RELAY_WATCHDOG_S): if the loop stalls, it lets go of UP and DN.SAFETY.md covers the electrical side (GFCI, certified supplies, the
Pace cable ground). Point the user to it rather than improvising
electrical advice.software/poolwind.py: the whole program (one file, PySide6 + OpenCV).software/poolwind_defaults.txt: swimmer settings for anyone without a
USB stick. software/poolwind_calibration.txt: the pool’s calibration (the
shipped one is the author’s pool, an example only).install.sh: sets up a fresh Raspberry Pi OS and copies the program to
~/PoolWind/ (poolwind.py, poolwind_defaults.txt,
poolwind_calibration.txt, install.log), and downloads the sample video
PoolWind_demo.mp4 (desk tests; a 'Demo': True run) from the latest GitHub Release of the repository it
was cloned from (with gh for a private one; a failed download
doesn’t stop the install). Desktop icons: PoolWind, Monitor
Toggle, and Claude (~/.local/bin/poolwind_claude.sh: a tmux
session poolwind-claude shared by the icon and SSH from a PC (ssh -t
user@host .local/bin/poolwind_claude.sh); the first time it installs
Claude Code and runs claude auth login --claudeai; then it opens Claude
in this download folder, continuing the last conversation; the
author’s own: with a USB stick that has a PoolWind_Claude folder it
keeps ~/.claude/projects in step with PoolWind_Claude/projects (in
at start, out every 5 minutes and at /exit; folder.txt there names
the folder Claude starts in), and PoolWind never offers to format such a
stick). It also switches the desktop to X11,
turns on I2C and RealVNC, adds the user to the gpio, i2c and video
groups, and allows the four sudo commands used to set up USB sticks.install_windows.bat: the demo on a Windows PC. Installs Python 3.13
with winget if needed, the tested packages with pip (no Pi hardware
libraries), PoolWind into %USERPROFILE%\PoolWind with the sample video,
then opens the demo tour (user manual 9) in the browser and starts
PoolWind.bat (-X utf8). No desktop icon, and the script deletes
itself at the end (not when poolwind.py is next to it): downloading
it again is how to watch the demo again (it skips pip when the libraries load,
and downloads the video again). The video is hidden (attrib +h).
PoolWind.bat is written to %TEMP% and started with cmd /c (so its
window closes), and when PoolWind closes it deletes the whole PoolWind
folder (Bill, 2026-10-24). With
poolwind.py next to the script, it installs the files from its own
folder instead of downloading. Logs to install.log there. Kept CRLF by
.gitattributes.docs/: build guide, setup and calibration guide, user manual.
hardware/: interface board (Fritzing file, Gerbers), parts list.
tools/outdoor_test/: the swimmer tracker prototype and the script that
compares it with PoolWind’s detection on recordings (“Outdoor pools”,
below).ast.literal_eval, and
must sit next to the program and start with its name. They are layered:
the built-in values (BUILT_IN_DEFAULTS near the top of poolwind.py),
then poolwind_defaults.txt, then the swimmer’s USB stick
(poolwind_ind_defaults.txt at the stick’s root). The calibration file
is separate and read once at start. 'Demo' is applied last and
overrides the device settings.'video file, start (sec), corners' (built in: PoolWind_demo.mp4,
0, the sample’s swim-area corners). A developer points it at another
recording in the defaults file. In video mode, Set Swim Area saves the
corners into that line (App.save_video_corners), never into the
calibration file. A missing file gives a message and the camera.CSV Vault
folder, or to ~/PoolWind/CSV Vault without a stick.
A demo writes to ~/PoolWind/Demo Vault instead, emptied at every start
(so it begins at 0) and kept at close for Swim Plot; it leaves USB sticks
alone.poolwind.py runs on Windows as a demo: the Pi libraries
(lgpio, board, adafruit_ina260) are optional, and without them a
real valve falls back to the simulated jet with a message.i2cdetect -y 1 should show it, normally at 0x40).App: settings, relays (UP_relay, DN_relay, relay_off), the jet
drive (_hold_drive), logging (accrue_log_disp), buttons (Hold, Suspend,
OnOff), USB stick handling, settings hot-reload.QtMainWindow.qt_update_loop: the main loop. It reads a frame, finds the
swimmer, updates the position, runs the controller and drives the relays.MyVideoCapture: the camera. MJPG 1280x720 at 30 fps, read by a grabber
thread (_grabber). getImages shrinks the frame to 640x480, turns it
upright, then straightens the swim area to 480x640 with the calibration
file’s swimAreaPoints. The jet is at the top of that picture.F_mask): distance in HSV from the picture’s average
color, a threshold, then the best-scoring blob of at least Sensitivity
pixels (5000). Small objects such as a ping-pong ball are deliberately
ignored. get_auto_CoM and BodyCoMCorrection turn the blob into a
position from 0 (back) to 1000 (front), allowing for the swimmer’s reach
(swimmersHeight, usableSwimLength; the old name usablePoolLength
is still read).SwimController: _zone_steps divides the pool into equal zones, one per
jet step: the pace table’s rows (rows within 0.01 V count once) that lie
inside the swimmer’s zone limits ('zoneMin, Max', 1-based step numbers)
and the table’s ends (the calibration’s old '# zones or auto' line is
gone since v15.7 and ignored). _index_for_CoM maps the position
to a zone, and so to a target jet step. The pool is controlled by jet
steps; Pace is for display and the swim log only. In a demo, and while
Swimmer limits runs, the zones open to the whole table
(App.zone_limits).DRIFT_SCALE (1.67).pace_voltage in the
calibration file. With a swimmer’s stick in, the Paces come from their
own poolwind_ind_calibration.txt on the stick (App._load_swimmer,
made from the pool’s the first time; read onto the pool’s jet steps if a
scan moved them), only the Paces, never the voltages. No welcome screen
(dropped 2026-10-30): Pace correction’s Copy Pool Default puts the pool’s
table into the swimmer’s pending one. App.watch_stick switches swimmer when a
stick is plugged in or pulled while running (switch_swimmer).
Pace correction’s pending changes (PacesPending) live in whichever file
is in use; Make permanent writes it. Log rows carry the jet’s voltage and
the table’s Pace (columns 10-11) so Swim Plot and the calendar show old
swims in today’s table (redo_in_today).SimulatedValve: the jet for desk tests and the demo. SwimPlotWindow:
swim review with synchronized video. USBDriveSetupDialog: new swimmer
sticks. SwimmerLimitsPanel and PaceCorrectionPanel: the small boxes
over the pool screen (menu). QtMainWindow.check_camera_moved: the
camera check a few seconds after start, against
poolwind_calibration_camera.png.v15.11-shelved).CalibrateWindow, the voltage scan, Pace Entry with its
Edit / Scan / Finish screens, PingPong) is a section of the same file: menu Calibrate pool…
(real valve only; greyed with a stick in and the builder’s password
first, both skipped with developerMode), or python3 poolwind.py
--calibrate (calibration_main; refuses in a Demo). No calibration
simulation since 2026-10-31: always the real jet (Bill: the valve moves
with the pump off).settings_file_error), a misspelled setting name or a wrong word
for a choice setting (CHOICE_SETTINGS; RETIRED_SETTINGS are still
ignored), no voltage sensor, the pump sensing line not connected (R6/R3
not fitted, or a Pace cable without contact 5), or as a last resort “Unknown problem while
starting” with the error. Swimmers’ settings (zones, height, training
video, logRate 5-15) are set in Swimmer limits (save_swimmer_settings),
so they rarely need a file edited.cd ~/PoolWind && python3 poolwind.py. On Windows, in
PowerShell: cd $HOME\PoolWind then py -X utf8 poolwind.py.~/PoolWind/install.log records every install step
and its output.UpdateCheck, since v15.8): at start, in a thread,
PoolWind asks the GitHub API for the latest Release of the repository in
~/PoolWind/poolwind_source.txt (written by install.sh: folder= the
download folder, repo=); a newer tag than poolwind_version() gives a
box when nobody is swimming. Update now runs git pull && bash
install.sh in that folder in a terminal and closes PoolWind; Later
writes the tag to poolwind_update_later.txt (install.sh deletes it).
No internet, no Release or a private repository: no box.'developerMode': True plus a
simulated valve and/or a recorded video, so nothing at the pool moves.'paceTrace': True in the defaults file writes pace_trace_*.csv in the
temp folder next to the program, one row per loop: voltage, paces, position, swimmer found,
target step, relay. It’s switched live and grows about 15 MB an hour.recordRawVideo (defaults file, works only with 'developerMode':
True) records the camera’s uncorrected video for replaying a problem.v4l2-ctl -d /dev/video0 --list-formats-ext lists the
sizes and frame rates it offers; v4l2-ctl -d /dev/video0 --list-ctrls
lists exposure and other controls.groups includes gpio, i2c and video
(they apply after a restart).vidSrc.set(...) lines in MyVideoCapture.__init__ and
re-set the swim area. YUYV at large sizes is too slow (often 5-10 fps).CAP_PROP_BUFFERSIZE 1 (set in MyVideoCapture.__init__) halves the
rate. Removing that line gives 30 fps; the grabber thread keeps frames
fresh anyway. The extra cost is about 6% of one core. Check with a
short timing loop around vidSrc.read().middleSwimZone %). The zone highlight and the
developer readouts show what PoolWind sees.'Demo' line other
than False in poolwind_defaults.txt (a developer option): remove it.PoolWind_demo.mp4), or a
'video file, start (sec), corners' line names a missing file.
PoolWind then uses the camera. Running the install script again retries
the download.install_windows.bat: expected for an unsigned script (setup guide,
section 13): More info → Run anyway.'Demo': True line, that the voltage is read at all (a reading near 0 V
means the Pace cable is unplugged, or, on some pools, the pump is off), that the remote
works by hand, and the relay wiring (build guide, section 9, first
power-up checks).~ is easily read as -; the setup
guide’s commands avoid ~ for this reason. If bash install.sh says
“No such file or directory”, the user isn’t in the downloaded folder:
open it in the File Manager and press F4 for a terminal there.python3 poolwind.py --calibrate; setup guide
5.3) scans the user’s jet steps and rewrites the table.V with developerMode on: a ramp, not a jump
about once a second). The plan, worked out with the author (a day or two
of work; test it in simulation first, then at the pool with nobody in it):
CalibrateWindow._scan_tick, state scan_up): on a
ramp, keep UP held until the builder presses Stop, then Use as top,
or the voltage stops rising (NO_STEP_S); build the table from the
bottom and top voltages in equal steps (jetStepVolts and
pace_voltage, Paces from pace_curve as now). Make the number of
steps a calibration setting, 30 to start (the author’s suggestion):
40 zones would be about 4 inches each in the pool, the author’s 26
steps give about 6._step_up, state up) hold
UP until they see a voltage jump, which never comes on a ramp: drive
to the next row’s voltage instead, as _drive_to / _drive_tick
already do (they let go within half a step of the target).App._hold_drive) holds UP or DN until
findClosestPlateauIndex reaches the desired step. On a ramp the jet
keeps moving after the relay lets go (the radio remote’s delay), so it
can overshoot narrow steps and hunt up and down. Add a deadband: let go
a little before the target (learn the overshoot from the ramp rate),
and don’t start a correction for less than about one step._apply_pool_scale (step_v,
jump_v) and the scan’s CONT_* check (turn it off for this pool).sim_update) moves whole steps; add a ramp mode.
Everything else uses only the table’s voltages and should work as it is:
zones, Swimmer limits, Pace correction, the zone highlight, OnOff’s
wind-down and Swim Plot.PoolWind was developed under a tent roof with daylight coming through (and lamps at night). Nobody has swum with it outdoors yet. In November 2026 the author asked Claude to look at the outdoor case, and the analysis below is the starting point for anyone whose pool is outdoors. If the detection needs changing for your pool, make the change in your own copy, test it as described here, and please share it in Discussions.
How the swimmer is found (QtMainWindow.F_mask, then get_auto_CoM):
each pixel’s HSV distance from the whole frame’s average colour,
a fixed threshold (110), then blobs of at least Sensitivity (5000 px)
and at most 20 % of the picture. The blob is chosen by a score: nearness
to the centre line, size, and nearness to the last frame’s blob. The
largest blob’s thin centre strip (1 % of the width) gives the CoM. After
that: up to 3 missed frames are held (DROPOUT_HOLD_FRAMES), a stillness
check (stillMotion, stillSeconds) decides when a still blob stops
counting as a swimmer, and an EMA smooths the CoM. So each frame is judged
almost on its own; little of the swimmer’s behaviour is used.
What was tested (offline, on six of the author’s raw camera
recordings, 30 s each at 15 fps; PoolWind’s own F_mask and
get_auto_CoM against a tracker prototype; distractors painted onto the
frames). “Wrong place”: the CoM more than a tenth of the pool from where
PoolWind put it on the clean video.
| Painted in | Current detection: wrong place | Tracker: wrong place |
|---|---|---|
| Nothing | 0 % | 0 % |
| A still, swimmer-sized shadow over the swim zone | 0 % | 0 % |
| Bright glare patches coming and going | 1.4 % | 3.3 % |
| Dappled light (through trees) drifting across the pool | 0.2 % | 0 % |
| 25 single leaves (about 4 x 2 in) drifting through, many across the swimmer | 0.0 % | 0.0 % |
| Swimmer-sized clumps (leaves, a toy) drifting through | 29 % | 15 % (plus 10 % not found) |
What that says:
Sensitivity, and touching the
swimmer it changes the blob by about 1 %.If an outdoor pool has trouble, start here:
'recordRawVideo': True (with 'developerMode': True)
records the camera’s full picture. Swim in the conditions that fail.
Play it back at a desk with the 'video file, start (sec), corners'
setting (setup guide, section 8) to see what PoolWind does.F_mask and get_auto_CoM on the
recording’s frames outside PoolWind (tools/outdoor_test/compare.py
does: it imports them from poolwind.py; the frame is the camera
picture resized to 640x480, turned upright, then straightened with the
swim area’s corners to 480x640, as MyVideoCapture.getImages does).
Mark where they go wrong.tools/outdoor_test/ (tracker.py; compare.py runs it
and PoolWind’s own detection side by side on recordings, with the
painted distractors, and saves pictures of the frames where they
disagree; its README says how). It tracks one swimmer from frame to
frame instead of picking a blob in each frame: