Skip to contentSkip to conversation

hwmon: (sht3x) read out sensor serial number

PATCH Applied Stefan Gloor 2 participants 3 messages Jan 31, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover hwmon: (sht3x) read out sensor serial number

The temperature/humidity sensors of the STS3x/SHT3x family are calibrated and factory-programmed with a unique serial number. For some sensors, this serial number can be used to obtain a calibration certificate via an API provided by the manufacturer (Sensirion). Expose the serial number via debugfs.

A "sht3x" debugfs directory is created when loading the driver. Within this parent directory, another directory is created for each sensor instantiation which contains the serial number.
The sensor-specific directories are managed by devres, such that they are cleaned up upon deinstantation or if hwmon registration fails. The top-level directory is removed when the driver is unloaded.

Changelog
=========

v3 -> v4:
- Remove debugfs entry with devm_add_action_or_reset()

v2 -> v3:
- Remove #ifdef for debugfs
- Add debugfs cleanup
- Do not expose serial number if read fails

v1 -> v2:
- Change from sysfs to debugfs
- Add documentation improvements

Stefan Gloor (1):
hwmon: (sht3x) read out sensor serial number

 Documentation/hwmon/sht3x.rst | 11 ++++++
 drivers/hwmon/sht3x.c         | 66 ++++++++++++++++++++++++++++++++++-
 2 files changed, 76 insertions(+), 1 deletion(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH v4 1/1 hwmon: (sht3x) read out sensor serial number

The temperature/humidity sensors of the STS3x/SHT3x family are calibrated and factory-programmed with a unique serial number. For some sensors, this serial number can be used to obtain a calibration certificate via an API provided by the manufacturer (Sensirion). Expose the serial number via debugfs.

Tested with: 2x STS31, 1x STS32, 1x SHT31

---
 Documentation/hwmon/sht3x.rst | 11 ++++++
 drivers/hwmon/sht3x.c         | 66 ++++++++++++++++++++++++++++++++++-
 2 files changed, 76 insertions(+), 1 deletion(-)
Documentation/hwmon/sht3x.rst +11 -0
index 957c854f5d08..9585fa7c5a5d 100644
@@ -65,6 +65,10 @@ When the temperature and humidity readings move back between the hysteresis
 values, the alert bit is set to 0 and the alert pin on the sensor is set to
 low.
 
+The serial number exposed to debugfs allows for unique identification of the
+sensors. For sts32, sts33 and sht33, the manufacturer provides calibration
+certificates through an API.
+
 sysfs-Interface
 ---------------
 
@@ -99,3 +103,10 @@ repeatability:      write or read repeatability, higher repeatability means
                         - 1: medium repeatability
                         - 2: high repeatability
 =================== ============================================================
+
+debugfs-Interface
+-----------------
+
+=================== ============================================================
+serial_number:      unique serial number of the sensor in decimal
+=================== ============================================================
drivers/hwmon/sht3x.c +65 -1

108 lines not on this page · raw message

Signature · 1 line
2.41.0
maintainer Applied
#2 lore raw
Quoted 9 lines · Stefan Gloor

The temperature/humidity sensors of the STS3x/SHT3x family are calibrated and factory-programmed with a unique serial number. For some sensors, this serial number can be used to obtain a calibration certificate via an API provided by the manufacturer (Sensirion). Expose the serial number via debugfs.

Tested with: 2x STS31, 1x STS32, 1x SHT31

Applied.

Thanks,
Guenter