Skip to contentSkip to conversation

Add support for Winsen MHZ19B CO2 sensor

PATCH Applied Gyeyoung Baek 3 participants 9 messages Apr 23, 2025 – Apr 26, 2025

Subsystems (3)
lore
Share & tools
lore

Gyeyoung Baek

author maintainer
#0 lore raw

v6 cover Add support for Winsen MHZ19B CO2 sensor

v6:
- Replace magic numbers with named constants.

v5:
- Include the required headers explicitly.
- Fix coding style overall.

v4:
- Ensure buffer is aligned to the cacheline.
- Fix coding style overall.

v3:
- Add vin supply regulator.
- Drop custom ABI.
- Drop unnecessary mutex.

v2:
- Add ABI doc.
- Add complete struct to receive UART transmission successfully.
- Add undersigned as a maintainer for the WINSEN MHZ19B.
- Modify to comply with the IIO subsystem ABI as much as possible.
- Revise the coding style overall.

Gyeyoung Baek (4):
dt-bindings: add winsen to the vendor prefixes
dt-bindings: add device tree support for winsen MHZ19B CO2 sensor
iio: chemical: add support for Winsen MHZ19B CO2 sensor
MAINTAINERS: Add WINSEN MHZ19B

 .../bindings/iio/chemical/winsen,mhz19b.yaml  |  33 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |   6 +
 drivers/iio/chemical/Kconfig                  |  10 +
 drivers/iio/chemical/Makefile                 |   1 +
 drivers/iio/chemical/mhz19b.c                 | 316 ++++++++++++++++++
 6 files changed, 368 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/chemical/winsen,mhz19b.yaml
 create mode 100644 drivers/iio/chemical/mhz19b.c

--
2.34.1

author maintainer
#1 lore raw

PATCH v6 1/4 dt-bindings: Add Winsen to the vendor prefixes

Add Winsen to the vendor prefixes.

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 86f6a19b28ae..6d35549d2e4b 100644
@@ -1689,6 +1689,8 @@ patternProperties:
     description: Wingtech Technology Co., Ltd.
   "^winlink,.*":
     description: WinLink Co., Ltd
+  "^winsen,.*":
+    description: Winsen Corp.
   "^winstar,.*":
     description: Winstar Display Corp.
   "^wirelesstag,.*":

--
2.34.1

author maintainer
#2 lore raw

PATCH v6 2/4 dt-bindings: Add device tree support for Winsen MHZ19B CO2 sensor

In reply to Gyeyoung Baek

Add device tree support for Winsen MHZ19B sensor.

---
 .../bindings/iio/chemical/winsen,mhz19b.yaml  | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/chemical/winsen,mhz19b.yaml
Documentation/devicetree/bindings/iio/chemical/winsen,mhz19b.yaml new file +33 -0
new file mode 100644
index 000000000000..2a6ddb33f163
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/chemical/winsen,mhz19b.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MHZ19B CO2 sensor
+
+maintainers:
+  - Gyeyoung Baek <[email protected]>
+
+properties:
+  compatible:
+    const: winsen,mhz19b
+
+  vin-supply:
+    description: Regulator that provides power to the sensor
+
+required:
+  - compatible
+  - vin-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    serial {
+      co2-sensor {
+        compatible = "winsen,mhz19b";
+        vin-supply = <&vdd>;
+      };
+    };
+...

--
2.34.1

author maintainer
#3 lore raw

PATCH v6 3/4 iio: chemical: Add support for Winsen MHZ19B CO2 sensor

In reply to Gyeyoung Baek

Add support for Winsen MHZ19B CO2 sensor.

Datasheet: https://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf

---
 drivers/iio/chemical/Kconfig  |  10 ++
 drivers/iio/chemical/Makefile |   1 +
 drivers/iio/chemical/mhz19b.c | 316 ++++++++++++++++++++++++++++++++++
 3 files changed, 327 insertions(+)
 create mode 100644 drivers/iio/chemical/mhz19b.c
drivers/iio/chemical/Kconfig +10 -0
index 330fe0af946f..7742de3f9cdb 100644
@@ -108,6 +108,16 @@ config IAQCORE
 	  iAQ-Core Continuous/Pulsed VOC (Volatile Organic Compounds)
 	  sensors
 
+config MHZ19B
+	tristate "Winsen MHZ19B CO2 sensor"
+	depends on SERIAL_DEV_BUS
+	help
+	  Say Y here to build Serdev interface support for the Winsen
+	  MHZ19B CO2 sensor.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called mhz19b.
+
 config PMS7003
 	tristate "Plantower PMS7003 particulate matter sensor"
 	depends on SERIAL_DEV_BUS
drivers/iio/chemical/Makefile +1 -0
index 4866db06bdc9..c63daebf39ac 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_ENS160) += ens160_core.o
 obj-$(CONFIG_ENS160_I2C) += ens160_i2c.o
 obj-$(CONFIG_ENS160_SPI) += ens160_spi.o
 obj-$(CONFIG_IAQCORE)		+= ams-iaq-core.o
+obj-$(CONFIG_MHZ19B) += mhz19b.o
 obj-$(CONFIG_PMS7003) += pms7003.o
 obj-$(CONFIG_SCD30_CORE) += scd30_core.o
 obj-$(CONFIG_SCD30_I2C) += scd30_i2c.o
drivers/iio/chemical/mhz19b.c new file +316 -0

316 lines not on this page · raw message

--
2.34.1

Reviewed-by on v6 3/4
#4 lore raw

Re: [PATCH v6 3/4] iio: chemical: Add support for Winsen MHZ19B CO2 sensor

Quoted 2 lines · Gyeyoung Baek

Add support for Winsen MHZ19B CO2 sensor.

LGTM,

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#5 lore raw

Re: [PATCH v6 3/4] iio: chemical: Add support for Winsen MHZ19B CO2 sensor

Hello Andy,

Quoted 7 lines · Andy Shevchenko
Quoted 2 lines · Gyeyoung Baek

Add support for Winsen MHZ19B CO2 sensor.

LGTM,

Thank you for your reviews so far.

--
Regards,
Gyeyoung

author maintainer
#6 lore raw

PATCH v6 4/4 MAINTAINERS: Add WINSEN MHZ19B

In reply to Gyeyoung Baek

Add undersigned as a maintainer for the WINSEN MHZ19B.

---
 MAINTAINERS | 6 ++++++
 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
index 01079a189c93..4a0089db6670 100644
@@ -26015,6 +26015,12 @@ M:	David Härdeman <[email protected]>
 S:	Maintained
 F:	drivers/media/rc/winbond-cir.c
 
+WINSEN MHZ19B
+M:	Gyeyoung Baek <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/chemical/winsen,mhz19b.yaml
+F:	drivers/iio/chemical/mhz19b.c
+
 WINSYSTEMS EBC-C384 WATCHDOG DRIVER
 L:	[email protected]
 S:	Orphan

--
2.34.1

maintainer Applied
#7 lore raw
In reply to Gyeyoung Baek

On Thu, 24 Apr 2025 04:40:56 +0900
Gyeyoung Baek <[email protected]> wrote:

Applied to the togreg branch of iio.git.
I'll initially push that out for a few days as testing to let the 0-day build bot see if it can find anything we missed.

Thanks,

Jonathan

author maintainer
#8 lore raw

Hello Jonathan,

Quoted 7 lines · Jonathan Cameron

On Thu, 24 Apr 2025 04:40:56 +0900
Gyeyoung Baek <[email protected]> wrote:

Applied to the togreg branch of iio.git.
I'll initially push that out for a few days as testing to let the 0-day build bot see if it can find anything we missed.

Thank you for approving it.
I'll do my best to fix issues quickly if any arise.

--
Regards,
Gyeyoung