Skip to content

Commit c6f0a88

Browse files
Copilotdorkmo
andcommitted
Remove sensor reading (mA) field from calibration form
Co-authored-by: dorkmo <[email protected]>
1 parent 7c6f847 commit c6f0a88

File tree

1 file changed

+7
-45
lines changed

1 file changed

+7
-45
lines changed

TankAlarm-112025-Server-BluesOpta/TankAlarm-112025-Server-BluesOpta.ino

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,11 +2603,6 @@ static const char CALIBRATION_HTML[] PROGMEM = R"HTML(
26032603
<span>"</span>
26042604
</div>
26052605
</label>
2606-
<label class="field">
2607-
<span>Sensor Reading (mA) <em style="font-weight: normal; color: var(--muted);">- From telemetry</em></span>
2608-
<input type="number" id="sensorReading" step="0.01" min="4" max="20" placeholder="Auto-filled when tank selected">
2609-
<small id="sensorAutoInfo" style="color: var(--muted); margin-top: 4px; display: block;"></small>
2610-
</label>
26112606
<label class="field">
26122607
<span>Reading Timestamp</span>
26132608
<input type="datetime-local" id="readingTimestamp">
@@ -2623,9 +2618,7 @@ static const char CALIBRATION_HTML[] PROGMEM = R"HTML(
26232618
</div>
26242619
</form>
26252620
<div class="info-box">
2626-
<strong>How it works:</strong> Each calibration reading pairs a verified tank level (measured with a stick gauge, sight glass, or other method) with the raw 4-20mA sensor reading. With at least 2 data points at different levels, the system calculates a linear regression to determine the actual relationship between sensor output and tank level. This learned calibration replaces the theoretical maxValue-based calculation.
2627-
<br><br>
2628-
<strong>Raw sensor reading:</strong> The mA reading is now captured directly from the sensor and sent in telemetry. When you select a tank, it will be auto-filled from the latest telemetry. If no raw reading is available, you can enter it manually from a loop meter.
2621+
<strong>How it works:</strong> Each calibration reading pairs a verified tank level (measured with a stick gauge, sight glass, or other method) with the raw 4-20mA sensor reading from telemetry. With at least 2 data points at different levels, the system calculates a linear regression to determine the actual relationship between sensor output and tank level. This learned calibration replaces the theoretical maxValue-based calculation.
26292622
</div>
26302623
</div>
26312624
@@ -2812,40 +2805,6 @@ static const char CALIBRATION_HTML[] PROGMEM = R"HTML(
28122805
});
28132806
}
28142807
2815-
// Auto-populate sensor reading when tank is selected
2816-
function onTankSelect() {
2817-
const tankKey = document.getElementById('tankSelect').value;
2818-
const sensorInput = document.getElementById('sensorReading');
2819-
const sensorInfo = document.getElementById('sensorAutoInfo');
2820-
2821-
if (!tankKey) {
2822-
sensorInput.value = '';
2823-
if (sensorInfo) sensorInfo.textContent = '';
2824-
return;
2825-
}
2826-
2827-
// Find the tank data
2828-
const tank = tanks.find(t => `${t.client}:${t.tank}` === tankKey);
2829-
if (tank) {
2830-
// Use raw sensorMa if available from telemetry
2831-
if (tank.sensorMa && tank.sensorMa >= 4 && tank.sensorMa <= 20) {
2832-
sensorInput.value = tank.sensorMa.toFixed(2);
2833-
if (sensorInfo) {
2834-
const lastUpdateDate = tank.lastUpdate ? new Date(tank.lastUpdate * 1000).toLocaleString() : 'unknown';
2835-
sensorInfo.textContent = `From last telemetry @ ${lastUpdateDate}`;
2836-
}
2837-
} else {
2838-
sensorInput.value = '';
2839-
if (sensorInfo) {
2840-
sensorInfo.textContent = 'No raw mA reading available - enter manually';
2841-
}
2842-
}
2843-
}
2844-
}
2845-
2846-
// Attach tank select handler
2847-
document.getElementById('tankSelect').addEventListener('change', onTankSelect);
2848-
28492808
// Load calibration data
28502809
async function loadCalibrationData() {
28512810
try {
@@ -2989,7 +2948,6 @@ static const char CALIBRATION_HTML[] PROGMEM = R"HTML(
29892948
const levelInches = parseFloat(document.getElementById('levelInches').value) || 0;
29902949
const totalInches = levelFeet * 12 + levelInches;
29912950
2992-
const sensorReading = parseFloat(document.getElementById('sensorReading').value);
29932951
const timestampInput = document.getElementById('readingTimestamp').value;
29942952
const notes = document.getElementById('notes').value.trim();
29952953
@@ -2999,6 +2957,9 @@ static const char CALIBRATION_HTML[] PROGMEM = R"HTML(
29992957
return;
30002958
}
30012959
2960+
// Get the tank data to include sensorMa automatically
2961+
const tank = tanks.find(t => `${t.client}:${t.tank}` === tankKey);
2962+
30022963
// Build payload
30032964
const payload = {
30042965
clientUid: clientUid,
@@ -3007,8 +2968,9 @@ static const char CALIBRATION_HTML[] PROGMEM = R"HTML(
30072968
notes: notes
30082969
};
30092970
3010-
if (!isNaN(sensorReading) && sensorReading >= 4 && sensorReading <= 20) {
3011-
payload.sensorReading = sensorReading;
2971+
// Include sensorMa from telemetry if available
2972+
if (tank && tank.sensorMa && tank.sensorMa >= 4 && tank.sensorMa <= 20) {
2973+
payload.sensorReading = tank.sensorMa;
30122974
}
30132975
30142976
if (timestampInput) {

0 commit comments

Comments
 (0)