Add a XIAO bench probe for the resistive tank level sender #111
Loading…
Reference in a new issue
No description provided.
Delete branch "tools/level-sensor-probe"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.inior CI. Tested only by building:pio run -d tools/level_sensor_probesucceeds with no warnings. Not run on hardware.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));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 computeohmsonly below that, since readings near the top of the range are non-linear.Two small things.
@ -0,0 +1,7 @@[env:xiao]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");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.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".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);With a
> 1threshold 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.Header wording fixed. The
> 1threshold is as specified, so the probe can sit at 99% or 1% when the true end stop is 100% or 0%. Left as is.8eca00f3adf576e34185f576e3418515cba69ce8af0b8919f062a6936527View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.