Sensor channels


Marc Reilly
 


Hi,

Firstly, let me say that I've been playing around with Zephyr and its been really great - well done!

I'm wondering:
1. how sensor devices with multiple channels can be supported?
2. Is there a procedure for adding new channels to enum sensor_channel?

For example, a power monitoring circuit where the sensor can provide 4 different values:
- supply voltage
- shunt voltage (ie the v drop across the measuring shunt resistance)
- current
- power

In this case, (1) is relevant as there are two voltage readings that the sensor supplies, and for (2) there is no channel for power/watts (which would be easy enough to add).

I note that there are already "SENSOR_CHAN_AMBIENT_TEMP" and "SENSOR_CHAN_DIE_TEMP" to discern different temperature channels, so to keep in spirit with that perhaps for the above example could just add "SENSOR_CHAN_SUPPLY_VOLTAGE" and "SENSOR_CHAN_SHUNT_VOLTAGE".
My instincts say that this could invite too many different specific channels and it becomes unclear which one should be used for what. On the other hand, the code using a sensor is specific to the sensor already, so prior knowledge of what channels are to be used is required. Also note there is enough room for another 4 billion or so, so its not as though we'd be unable to support new ones as needed.

That said, I think I can envisage use cases where a device has multiple channels of the same type, and perhaps it would be simpler to be able to number them off in some more generic manner. (eg add a "sub channel" index to relevant functions, or reserve some bits in the enumeration for extra channels.)

Cheers
Marc



Join devel@lists.zephyrproject.org to automatically receive all group messages.