Add a XIAO bench probe for the resistive tank level sender #111

Open
Claude wants to merge 10 commits from tools/level-sensor-probe into main
Collaborator

Standalone bench tool under tools/level_sensor_probe/, shaped like the Autoterm sniffer. It averages the ADC on a fixed-resistor divider and prints mV, sender ohms and a percentage over serial, so the sender can be characterised before the water node exists.

Not in the root platformio.ini or CI. Tested only by building: pio run -d tools/level_sensor_probe succeeds with no warnings. Not run on hardware.

Standalone bench tool under `tools/level_sensor_probe/`, shaped like the Autoterm sniffer. It averages the ADC on a fixed-resistor divider and prints mV, sender ohms and a percentage over serial, so the sender can be characterised before the water node exists. Not in the root `platformio.ini` or CI. Tested only by building: `pio run -d tools/level_sensor_probe` succeeds with no warnings. Not run on hardware.
Add a XIAO bench probe for the resistive tank level sender
Some checks failed
Build and test / release (pull_request) Has been cancelled
Build and test / build (pull_request) Has been cancelled
a0c604ff08
Claude left a comment

Open-circuit detection will not fire on the C3.

Open-circuit detection will not fire on the C3.
@ -0,0 +30,4 @@
void loop() {
const int32_t mv = averageMv();
if (mv >= supplyMv - openCircuitMarginMv) {
Serial.printf("%lu %ld open\n", millis(), static_cast<long>(mv));
Author
Collaborator

mv >= supplyMv - 20 (3280 mV) can never be true. The C3 ADC at the Arduino default 11 dB attenuation saturates at about 2.5 V, so a floating sender reads about 2500 mV. It then falls into the else branch and prints roughly 690 ohms and 100%, i.e. looks full. Test against a threshold the ADC can reach, e.g. the reading for fullOhms plus margin (about 1.6 to 2.0 V). Also compute ohms only below that, since readings near the top of the range are non-linear.

`mv >= supplyMv - 20` (3280 mV) can never be true. The C3 ADC at the Arduino default 11 dB attenuation saturates at about 2.5 V, so a floating sender reads about 2500 mV. It then falls into the else branch and prints roughly 690 ohms and 100%, i.e. looks full. Test against a threshold the ADC can reach, e.g. the reading for fullOhms plus margin (about 1.6 to 2.0 V). Also compute `ohms` only below that, since readings near the top of the range are non-linear.
Detect an open sender against the ADC ceiling, not the supply
All checks were successful
Build and test / build (pull_request) Successful in 1m35s
Build and test / release (pull_request) Has been skipped
22d695a739
Document the tank level sender wiring
All checks were successful
Build and test / build (pull_request) Successful in 1m29s
Build and test / release (pull_request) Has been skipped
97e2d26a15
Print the probe reading only when it changes
Some checks failed
Build and test / release (pull_request) Has been cancelled
Build and test / build (pull_request) Has been cancelled
2ab0c876af
Claude left a comment

Two small things.

Two small things.
@ -0,0 +1,7 @@
[env:xiao]
Author
Collaborator

tools/level_sensor_probe/.gitignore (ignores .pio) is untracked and not in this PR. Nothing else ignores that build dir, so a build leaves it as untracked noise. Commit the file.

`tools/level_sensor_probe/.gitignore` (ignores `.pio`) is untracked and not in this PR. Nothing else ignores that build dir, so a build leaves it as untracked noise. Commit the file.
@ -0,0 +28,4 @@
void setup() {
Serial.begin(115200);
Serial.println("# ms mV ohms pct");
Author
Collaborator

The data lines are now tab-separated but the header here (# ms mV ohms pct) and the format comment on line 3 still show spaces. Use tabs in the header so it lines up with the columns.

The data lines are now tab-separated but the header here (`# ms mV ohms pct`) and the format comment on line 3 still show spaces. Use tabs in the header so it lines up with the columns.
Tab-separate the probe header and ignore its build directory
Some checks failed
Build and test / release (pull_request) Has been cancelled
Build and test / build (pull_request) Has been cancelled
4a16eda547
Print the probe reading when the percentage moves by more than 1
Some checks failed
Build and test / release (pull_request) Has been cancelled
Build and test / build (pull_request) Has been cancelled
0cb8fd90b1
Claude left a comment

Two small issues.

Two small issues.
@ -0,0 +1,49 @@
// Bench probe for a 0 to 190 ohm tank level sender. 3V3 to a fixed resistor to the junction,
// sender from the junction to GND, ADC on the junction at A1 (GPIO3, ADC1; D0 strapping, D3 ADC2).
// Output: one line per change, "<ms>\t<mV>\t<ohms>\t<pct>%", or "<ms>\t<mV>\topen".
Author
Collaborator

Header says "one line per change", but a change of 1% or less is now silent. Reword to "one line when the percentage moves by more than 1, or the sender opens or closes".

Header says "one line per change", but a change of 1% or less is now silent. Reword to "one line when the percentage moves by more than 1, or the sender opens or closes".
@ -0,0 +36,4 @@
const int32_t mv = averageMv();
const bool open = mv >= adcSaturationMv - openCircuitMarginMv;
const int32_t ohms = fixedOhms * mv / (supplyMv - mv);
const int32_t pct = open ? openPct : constrain((ohms - emptyOhms) * 100 / (fullOhms - emptyOhms), 0, 100);
Author
Collaborator

With a > 1 threshold the probe can never print the last step to an end stop. From a printed 99, a true 100 is a difference of 1, so the line stays at 99%. Same at 1 and 0. Compare with >=, or always print when pct hits 0 or 100.

With a `> 1` threshold the probe can never print the last step to an end stop. From a printed 99, a true 100 is a difference of 1, so the line stays at 99%. Same at 1 and 0. Compare with `>=`, or always print when pct hits 0 or 100.
Author
Collaborator

Header wording fixed. The > 1 threshold is as specified, so the probe can sit at 99% or 1% when the true end stop is 100% or 0%. Left as is.

Header wording fixed. The `> 1` threshold is as specified, so the probe can sit at 99% or 1% when the true end stop is 100% or 0%. Left as is.
Reword the probe header for the percentage change rule
All checks were successful
Build and test / build (pull_request) Successful in 1m32s
Build and test / release (pull_request) Has been skipped
15cba69ce8
Print the probe percentage to the nearest 10
Some checks failed
Build and test / release (pull_request) Has been cancelled
Build and test / build (pull_request) Has been cancelled
aabba8904d
Note the rounded percentage in the probe header
Some checks failed
Build and test / release (pull_request) Has been cancelled
Build and test / build (pull_request) Has been cancelled
8eca00f3ad
rob force-pushed tools/level-sensor-probe from 8eca00f3ad
Some checks failed
Build and test / release (pull_request) Has been cancelled
Build and test / build (pull_request) Has been cancelled
to f576e34185
All checks were successful
Build and test / build (pull_request) Successful in 1m30s
Build and test / release (pull_request) Has been skipped
2026-10-12 20:14:31 +00:00
Compare
rob force-pushed tools/level-sensor-probe from f576e34185
All checks were successful
Build and test / build (pull_request) Successful in 1m30s
Build and test / release (pull_request) Has been skipped
to 15cba69ce8
All checks were successful
Build and test / build (pull_request) Successful in 1m32s
Build and test / release (pull_request) Has been skipped
2026-10-12 20:21:27 +00:00
Compare
Correct the probe level with the sender's measured curve
Some checks failed
Build and test / release (pull_request) Has been cancelled
Build and test / build (pull_request) Has been cancelled
af0b8919f0
rob force-pushed tools/level-sensor-probe from af0b8919f0
Some checks failed
Build and test / release (pull_request) Has been cancelled
Build and test / build (pull_request) Has been cancelled
to 62a6936527
All checks were successful
Build and test / build (pull_request) Successful in 1m54s
Build and test / release (pull_request) Has been skipped
2026-10-12 20:31:15 +00:00
Compare
Estimate the level from the middle of each sender band
All checks were successful
Build and test / build (pull_request) Successful in 1m30s
Build and test / release (pull_request) Has been skipped
82b345991e
Anchor the end sender readings to the float stops
All checks were successful
Build and test / build (pull_request) Successful in 1m28s
Build and test / release (pull_request) Has been skipped
303ebf6df9
All checks were successful
Build and test / build (pull_request) Successful in 1m28s
Required
Details
Build and test / release (pull_request) Has been skipped
Required
Details
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin "tools/level-sensor-probe:tools/level-sensor-probe"
git switch "tools/level-sensor-probe"
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rob/CampervanControlSystems!111
No description provided.