Skip to contentSkip to conversation

hwmon: Add AHT10 Temperature and Humidity Sensor Driver

PATCH Applied Johannes Cornelis Draaijer (datdenkikniet) 2 participants 2 messages Jan 7, 2021 – Jan 23, 2021

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

PATCH v3 1/1 hwmon: Add AHT10 Temperature and Humidity Sensor Driver

This patch adds a hwmon driver for the AHT10 Temperature and Humidity sensor. It has a maximum sample rate, as the datasheet states that the chip may heat up if it is sampled more than once every two seconds.

Has been tested a to work on a raspberrypi0w

Changes from v2:
Add reference to documentation to index.rst
Properly align defines
Clamp value instead of returning error
Adjust return values
Remove unnecessary print, check and comment

Major changes from initial patch:
Removed devicetree/of references
Removed aht10_reset, aht10_remove
Add documentation
Switch to hwmon channels, attributes and info More appropriate usage of mutex
Return standard error codes
Add checking statements for errors that are returned Other code improvements as suggested

---
 Documentation/hwmon/aht10.rst |  46 +++++
 Documentation/hwmon/index.rst |   1 +
 drivers/hwmon/Kconfig         |  10 +
 drivers/hwmon/Makefile        |   1 +
 drivers/hwmon/aht10.c         | 347 ++++++++++++++++++++++++++++++++++
 5 files changed, 405 insertions(+)
 create mode 100644 Documentation/hwmon/aht10.rst
 create mode 100644 drivers/hwmon/aht10.c
Documentation/hwmon/aht10.rst new file +46 -0
new file mode 100644
index 000000000000..482262ca117c
@@ -0,0 +1,46 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+Kernel driver aht10
+=====================
+
+Supported chips:
+
+  * Aosong AHT10
+
+    Prefix: 'aht10'
+
+    Addresses scanned: None
+
+    Datasheet:
+
+      Chinese: http://www.aosong.com/userfiles/files/media/AHT10%E4%BA%A7%E5%93%81%E6%89%8B%E5%86%8C%20A3%2020201210.pdf
+      English: https://server4.eca.ir/eshop/AHT10/Aosong_AHT10_en_draft_0c.pdf
+
+Author: Johannes Cornelis Draaijer <[email protected]>
+
+
+Description
+-----------
+
+The AHT10 is a Temperature and Humidity sensor
+
+The address of this i2c device may only be 0x38
+
+Usage Notes
+-----------
+
+This driver does not probe for AHT10 devices, as there is no reliable
+way to determine if an i2c chip is or isn't an AHT10. The device has
+to be instantiated explicitly with the address 0x38. See
+Documentation/i2c/instantiating-devices.rst for details.
+
+Sysfs entries
+-------------
+
+=============== ============================================
+temp1_input     Measured temperature in millidegrees Celcius
+humidity1_input Measured humidity in %H
+update_interval The minimum interval for polling the sensor,
+                in milliseconds. Writable. Must be at
+                least 2000.
+=============== ============================================
Documentation/hwmon/index.rst +1 -0
index 55ff4b7c5349..4a9507d177a0 100644
@@ -38,6 +38,7 @@ Hardware Monitoring Kernel Drivers
    adt7462
    adt7470
    adt7475
+   aht10
    amc6821
    amd_energy
    asb100
drivers/hwmon/Kconfig +10 -0
index 288ae9f63588..96bad243d729 100644
@@ -257,6 +257,16 @@ config SENSORS_ADT7475
 	  This driver can also be built as a module. If so, the module
 	  will be called adt7475.
 
+config SENSORS_AHT10
+	tristate "Aosong AHT10"
+	depends on I2C
+	help
+	  If you say yes here, you get support for the Aosong AHT10
+	  temperature and humidity sensors
+
+	  This driver can also be built as a module. If so, the module
+	  will be called aht10.
+
 config SENSORS_AS370
 	tristate "Synaptics AS370 SoC hardware monitoring driver"
 	help
drivers/hwmon/Makefile +1 -0
index 3e32c21f5efe..6cb44d54e628 100644
@@ -45,6 +45,7 @@ obj-$(CONFIG_SENSORS_ADT7411)	+= adt7411.o
 obj-$(CONFIG_SENSORS_ADT7462)	+= adt7462.o
 obj-$(CONFIG_SENSORS_ADT7470)	+= adt7470.o
 obj-$(CONFIG_SENSORS_ADT7475)	+= adt7475.o
+obj-$(CONFIG_SENSORS_AHT10)	+= aht10.o
 obj-$(CONFIG_SENSORS_AMD_ENERGY) += amd_energy.o
 obj-$(CONFIG_SENSORS_APPLESMC)	+= applesmc.o
 obj-$(CONFIG_SENSORS_ARM_SCMI)	+= scmi-hwmon.o
drivers/hwmon/aht10.c new file +347 -0

347 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 24 lines · Johannes Cornelis Draaijer (datdenkikniet)

This patch adds a hwmon driver for the AHT10 Temperature and Humidity sensor. It has a maximum sample rate, as the datasheet states that the chip may heat up if it is sampled more than once every two seconds.

Has been tested a to work on a raspberrypi0w

Changes from v2:
Add reference to documentation to index.rst
Properly align defines
Clamp value instead of returning error
Adjust return values
Remove unnecessary print, check and comment

Major changes from initial patch:
Removed devicetree/of references
Removed aht10_reset, aht10_remove
Add documentation
Switch to hwmon channels, attributes and info More appropriate usage of mutex
Return standard error codes
Add checking statements for errors that are returned Other code improvements as suggested

Quoted 1 line

Applied.

Thanks,
Guenter