zephyr icon indicating copy to clipboard operation
zephyr copied to clipboard

RFC: Voltage divider sensor

Open aurel32 opened this issue 2 years ago • 5 comments

There is already a voltage-divider binding defined, which is only used by the boards/nrf/battery sample. Looking at the recently added stm32_vbat sensor driver, I realized it might be a good idea to implement a more generic sensor using the existing binding, that can replace the stm32_vbat sensor and big part of the battery sample. As a bonus it allows to easily measure other voltages with only 2 resistors. It is actually more versatile than existing sample and drivers as it allows to tune all ADC parameters (resolution, oversampling, gain, ...) at the expense of more entries in the device tree.

For now this is just a RFC to demonstrate the idea. I have fully tested the driver itself. I have converted the sensor/stm32_vbat_sensor sample to show the changes are minimal, but only tested compiled it, as I don't have the corresponding boards. If this driver sounds like a good idea, I can also convert the boards/nrf/battery sample.

aurel32 avatar Jul 01 '22 21:07 aurel32

API meeting:

  • @MaureenHelm @gmarull @erwango to take a look

carlescufi avatar Jul 05 '22 15:07 carlescufi

I have just pushed an updated version of this PR, following the recent changes in Zephyr. I have been able to test the stm32_vbat_sensor on a Nucleo L432KC board, which have the VBAT pin internally connected to VCC, and the value was correct.

aurel32 avatar Aug 05 '22 15:08 aurel32

Any news about that? It might be worth looking at the idea before the 3.2 is released with stm32_vbat, as this alternative sensor can just replace it and do much more.

aurel32 avatar Sep 06 '22 21:09 aurel32

@MaureenHelm Should CODEOWNERS/MAINTAINERS be updated ?

erwango avatar Sep 07 '22 13:09 erwango

@erwango how?

From recent examples, I think that CODEOWNER is still in use. So if confirmed, this file should be updated.

erwango avatar Sep 21 '22 15:09 erwango

@aurel32, are you still working on this PR? I can take over if you are too busy (I have some interest in getting this merged upstream)

talih0 avatar Oct 17 '22 18:10 talih0

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

github-actions[bot] avatar Dec 17 '22 00:12 github-actions[bot]