README.rst
1.. zephyr:code-sample:: sgp40_sht4x
2 :name: SGP40 and SHT4X digital humidity and multipixel gas sensor
3 :relevant-api: sensor_interface
4
5 Get temperature, humidity and gas sensor data from SGP40 and SHT4X sensors (polling mode).
6
7Description
8***********
9
10This sample application periodically measures the ambient temperature, humidity
11and a raw gas sensor value from an SGP40 and SHT4X device.
12The result is written to the console.
13
14You can choose to use the on-chip T/RH compensation of the SGP40
15by feeding the values measured by the SHT4X into it.
16This is enabled in the Application by default, you can turn it off
17by setting ``APP_USE_COMPENSATION=n``.
18
19The SHT4X has the option to use a heater which makes sense for specific
20environments/applications (refer to the datasheet for more information).
21To make use of the heater have a look at the Kconfig options for this application.
22
23
24References
25**********
26
27 - `SHT4X sensor <https://www.sensirion.com/en/environmental-sensors/humidity-sensors/humidity-sensor-sht4x/>`_
28 - `SGP40 sensor <https://www.sensirion.com/en/environmental-sensors/gas-sensors/sgp40/>`_
29
30Wiring
31******
32
33This sample uses the SHT4X and SGP40 sensor controlled using the I2C interface.
34Connect Supply: **VDD**, **GND** and Interface: **SDA**, **SCL**.
35The supply voltage can be in the 1.7V to 3.6V range.
36Depending on the baseboard used, the **SDA** and **SCL** lines require Pull-Up
37resistors.
38
39Building and Running
40********************
41
42This project outputs sensor data to the console. It requires a SHT4X and a SGP40
43sensor. It should work with any platform featuring a I2C peripheral
44interface. This example has an example device tree overlay
45for the :zephyr:board:`blackpill_f411ce` board.
46
47
48.. zephyr-app-commands::
49 :zephyr-app: samples/sensor/sgp40_sht4x
50 :board: blackpill_f411ce
51 :goals: build flash
52
53
54Sample Output
55=============
56
57.. code-block:: console
58
59 *** Booting Zephyr OS build v2.6.0-rc1-315-g50d8d1187138 ***
60 SHT4X: 23.64 Temp. [C] ; 30.74 RH [%] -- SGP40: 30531 Gas [a.u.]
61 [00:00:00.250,000] <dbg> SGP40.sgp40_init: SGP40: Selftest succeeded!
62 SHT4X: 23.66 Temp. [C] ; 32.16 RH [%] -- SGP40: 30541 Gas [a.u.]
63 SHT4X: 23.63 Temp. [C] ; 30.83 RH [%] -- SGP40: 30522 Gas [a.u.]
64
65The datasheet states that the raw sensor signal for the SGP40 ist proportional
66to the logarithm of the sensors resistance, hence it is labeled as [a.u.]
67(arbitrary units) in the example.
68