Introduction

Water-quality sensors in smart small appliances are usually not "plug-and-play" analog devices; they are a measurement chain composed of an interface ASIC, a probe, temperature compensation, main-control firmware and calibration data. When upgrading the main-control firmware, erasing or overwriting the calibration partition may cause TDS/conductivity readings to drift, temperature compensation errors and even whole-unit rework. Therefore, firmware upgrade is not only about updating code; calibration data must also be managed as an independent, protected asset. Using AtomBit's BA121 and BA234 interface ASICs as the integration background, this article discusses calibration data protection methods for smart water appliances.

Why the upgrade process is a high-risk operation for calibration data

In smart water appliances, the water-quality sensor chain usually includes: probe → interface ASIC (such as BA121/BA234) → main-control MCU → display/cloud. The main-control MCU may store application-related calibration data, such as zero point, slope, temperature compensation coefficients and filter life baseline. Common risks during firmware upgrade include:

  • The upgrade tool mistakenly erases the entire Flash, including the calibration data area;
  • Data structure changes in the new firmware cause parsing of old calibration data to fail;
  • Power loss or communication interruption during the upgrade leaves calibration data incomplete;
  • Without version matching, the new algorithm uses incompatible old calibration parameters.

Especially for OEM/ODM customers, the same hardware may run firmware from different brands; if the upgrade package is not bound to device identity, customer A's calibration may be written to customer B's units, causing batch problems.

What calibration data should contain: format and version

Calibration data is not a string of arbitrarily stored calibration values; it should be designed as a structured, verifiable and migratable data block. It is recommended to include at least the following fields:

FieldDescriptionMustRemarks
Device serial number/IDBound to device identity for traceabilityYesUnique and immutable
Calibration version numberDecoupled from firmware version, increments independentlyYesFacilitates compatibility determination
Calibration time and production line workstationFacilitates auditing and tracebackYesCan be linked to the production database
Sensor type and configurationSuch as single-channel conductivity, dual probe, NTC temperature compensationYesMatches the ASIC type
Raw calibration pointsFor example, the raw ADC/digital output corresponding to a standard conductivity solutionYesAt least two points
Fitting coefficientsSlope/intercept or polynomial coefficients calculated from the calibration pointsYesCorresponds to the algorithm version
Temperature compensation parametersNTC B value, reference temperature, compensation coefficients, etc.Depends on the solutionBA121/BA234 automatic compensation, but the main controller still needs to hold some parameters
Checksum/CRCEnsure data integrityYesPrevent silent propagation of corruption

Take BA121 as an example: it provides automatic temperature correction, single-channel conductivity measurement and bipolar probe drive. However, system-level calibration data should not rely solely on the ASIC's internal logic; the host controller should instead hold a manageable calibration block. BA234 provides UART digital output and automatic NTC temperature compensation, which simplifies host reading, but it likewise requires the host to store the application-related calibration parameters.

The format should explicitly specify byte order, field length and data units. For the version strategy, it is recommended to use "calibration data version + firmware compatibility range" rather than relying on the firmware version number. For example, new firmware can declare a compatible calibration data version range; if a version falls outside the range, the upgrade is rejected or recalibration is triggered. The compatibility matrix can be maintained in production-line or upgrade tools, as shown below:

Calibration data versionFirmware version compatibility rangeHandling policy
v1FW 1.0–1.3Normal upgrade
v2FW 1.2 and aboveNormal upgrade
Unknown/incompatible—Reject the upgrade or calibrate first

The above matrix is only an engineering suggestion example and does not represent the default configuration of AtomBit products.

Device identity and production traceability

During the production phase, each device should be written with a unique serial number, and the serial number should be bound to the calibration data. During the upgrade process, the firmware package or upgrade server should verify the device identity to avoid using incorrect calibration data. For OEM customers, it is recommended to use an independent device identity namespace to prevent serial number conflicts between different brands.

Production traceability should at least record:

Traceability fieldDescription
Serial numberDevice unique identifier
Calibration data versionCalibration version at the time of writing
Probe batch/ASIC batchHardware batch information
Calibration solution batch and concentrationReference solution information used for calibration
Production line station, operator, timeProduction environment information
Factory test resultsPost-calibration verification readings

Not all of this information is necessarily stored in the device Flash, but it should be stored in the production database and associated with the device identity. If a firmware upgrade fails, the original calibration data can be recovered from the production database via the serial number.

Partitioning and backup strategy

It is recommended to divide the MCU non-volatile storage into:

  • Bootloader area
  • Application area A/B (dual-bank OTA)
  • Calibration data area
  • Backup calibration data area
  • Device identity area
  • Upgrade status log area

During upgrade, the boot area must not be erased; the calibration data area is logically read-only during upgrade and must not be written by the application upgrade process. If calibration data must be updated, it should be done through a separate calibration configuration process, not overwritten along with the firmware package.

Backup strategy: before upgrade, copy the current calibration data to the backup area and calculate the CRC. After the upgrade is complete, verify that the new firmware starts successfully, then mark the backup area as valid. If an anomaly is detected in the calibration data, it can be restored from the backup area. For low-resource MCUs without a backup area, at minimum the calibration data should be uploaded to the production tool or cloud before upgrade as a basis for recovery.

Pre-upgrade verification and rollback

The upgrade package should include:

  • Target device model/identity range
  • List of compatible calibration data versions
  • Firmware integrity check
  • Pre-upgrade check script (optional)
BA121 Product image
BA121 — Product appearance reference; for the specific version and configuration, refer to the corresponding product documentation.

Pre-upgrade check steps:

  1. Read the device identity and match it with the upgrade package target;
  2. Read the current calibration data version and confirm it is in the compatibility list;
  3. Back up the current calibration data;
  4. Check the stability of the power supply and communication link;
  5. Perform the upgrade.

Rollback trigger conditions:

  • After the upgrade, the device fails to start normally or sensor readings are abnormal;
  • Calibration data verification fails;
  • The new firmware version is incompatible with the calibration data version.

The rollback operation should revert to the previous stable firmware version and restore the backed-up calibration data. Note that after rollback, functional verification must be performed again, especially for TDS/conductivity readings, temperature compensation and filter management logic.

Upgrade failure recovery path

Upgrade failure scenarios include:

  • Power loss/power-down
  • Communication interruption
  • Flash write error
  • Calibration data accidentally erased

Recovery path design:

  • The Bootloader checks the upgrade status flag; if it is in "upgrading" and not completed, it automatically rolls back;
  • If calibration data is lost, restore from the backup area; if there is no local backup, restore from the production database by serial number;
  • If the firmware and calibration versions do not match, block application startup and prompt for recalibration.

For UART-output ASICs such as BA234, the main controller can quickly determine whether the sensor chain is normal by reading the output value and comparing it with a known standard solution. However, this simple verification cannot be treated as complete calibration; it can only serve as initial screening in production or after-sales.

Integration into production line verification

Production line verification should include:

  • Calibration data write and read integrity test;
  • Simulated power-loss during upgrade test;
  • Readout consistency test after upgrade;
  • Calibration data version compatibility test;
  • OTA upgrade end-to-end test.

For OEM/ODM projects, it is recommended to clarify with AtomBit during the customization stages of structure, wiring harness, interface and application calibration: which parameters are automatically handled by the ASIC (such as BA121 temperature correction and BA234 NTC compensation), and which are stored by the main controller and protected during upgrades. This can reduce problems caused by upgrades.

Limitations and Boundaries

This article discusses firmware upgrades and calibration data protection for water-quality sensors in smart small appliances. Readings from household water-quality sensors are used for device feedback and trend indication and cannot replace laboratory analysis. For example, household conductivity/TDS readings are affected by temperature, bubbles, probe contamination and other factors, and can only serve as filter life reminders and taste references. After upgrading firmware, device functionality should be re-verified, but this cannot be used to infer whether water quality is safe. If water contamination is suspected, drinking should be suspended, a reliable water source used, and the water supply or health authority contacted for testing.

FAQ

Q1: Must calibration data be placed in a separate partition of the MCU? It is recommended. Even if the ASIC internally handles part of the processing logic, system-level calibration data should still be stored separately and protected by the upgrade process.

Q2: Can the upgrade package also update calibration data along the way? It is not recommended to mix this into a regular firmware upgrade. Calibration data updates should follow a separate, controlled process, with the version and operator recorded.

Q3: Is calibration data definitely corrupted after a power loss? Not necessarily, but a power loss while erasing or writing Flash during the upgrade process may cause incomplete data or data loss. Power-loss protection and recovery mechanisms should be designed.

Q4: How can I determine whether the sensor readings are normal after an upgrade? You can use a standard solution of known conductivity for an initial screening and compare it with records made before the upgrade. However, this cannot replace full production-line calibration.

Q5: What should OEM/ODM customers pay attention to? They need to define their own device identity namespace, calibration data version compatibility rules and recovery process to avoid data cross-talk between different brands.

Conclusion

Water-quality sensor firmware upgrades are not merely a code replacement; they are a systems engineering effort involving calibration data versions, device identity, backup, rollback and production traceability. Smart water appliance R&D teams should treat calibration data as a protected asset from early in the design phase and, in line with the system integration characteristics of interface ASICs such as AtomBit BA121 and BA234, establish clear upgrade and recovery processes to reduce mass-production and after-sales risks.