zephyr
zephyr copied to clipboard
RFC: Voltage divider sensor
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.
API meeting:
- @MaureenHelm @gmarull @erwango to take a look
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.
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.
@MaureenHelm Should CODEOWNERS/MAINTAINERS be updated ?
@erwango how?
From recent examples, I think that CODEOWNER is still in use. So if confirmed, this file should be updated.
@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)
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.