Skip to content

Commit f8a952f

Browse files
Jeppe Odgaardcfriedt
authored andcommitted
include: drivers: sensor: add flow rate channel
Add flow rate to `enum sensor_channel` in litres per minute. The SI unit for flow rate is cubic metres per second. Due to a sensor value resolution of 1/100000 this unit is not granular enough for low flow rate sensors. Signed-off-by: Jeppe Odgaard <[email protected]>
1 parent e8e4d21 commit f8a952f

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

drivers/sensor/sensor_shell.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ static const char *const sensor_channel_name[SENSOR_CHAN_COMMON_COUNT] = {
8181
[SENSOR_CHAN_O2] = "o2",
8282
[SENSOR_CHAN_VOC] = "voc",
8383
[SENSOR_CHAN_GAS_RES] = "gas_resistance",
84+
[SENSOR_CHAN_FLOW_RATE] = "flow_rate",
8485
[SENSOR_CHAN_VOLTAGE] = "voltage",
8586
[SENSOR_CHAN_VSHUNT] = "vshunt",
8687
[SENSOR_CHAN_CURRENT] = "current",

include/zephyr/drivers/sensor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ enum sensor_channel {
130130
SENSOR_CHAN_VOC,
131131
/** Gas sensor resistance in ohms. */
132132
SENSOR_CHAN_GAS_RES,
133+
/** Flow rate in litres per minute */
134+
SENSOR_CHAN_FLOW_RATE,
133135

134136
/** Voltage, in volts **/
135137
SENSOR_CHAN_VOLTAGE,

samples/sensor/sensor_shell/pytest/test_sensor_shell.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_sensor_shell_attr_get(shell: Shell):
4141
assert any(['sensor@0(channel=co2, attr=sampling_frequency)' in line for line in lines]), 'expected response not found'
4242

4343
shell.wait_for_prompt()
44-
lines = shell.exec_command('sensor attr_get sensor@1 54 3')
44+
lines = shell.exec_command('sensor attr_get sensor@1 55 3')
4545
assert any(['sensor@1(channel=gauge_state_of_health, attr=slope_th)' in line for line in lines]), 'expected response not found'
4646

4747
logger.info('response is valid')
@@ -56,7 +56,7 @@ def test_sensor_shell_attr_set(shell: Shell):
5656
assert any([expected_line in line for line in lines]), 'expected response not found'
5757

5858
shell.wait_for_prompt()
59-
lines = shell.exec_command('sensor attr_set sensor@1 54 3 1')
59+
lines = shell.exec_command('sensor attr_set sensor@1 55 3 1')
6060
expected_line = 'sensor@1 channel=gauge_state_of_health, attr=slope_th set to value=1'
6161
assert any([expected_line in line for line in lines]), 'expected response not found'
6262

0 commit comments

Comments
 (0)