HACK: Add support for ADS1115 based voltage readings #3246
+639
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Looking for feedback on the idea and way forward
With this change you can hook up (up to four) ADS1115 devices to the
I2C bus of a receiver in order to measure (each) four values and
transmit them as cell voltage. This (currently) allows for up to 16
different values each being transmitted as from a different source.
In a plane with fours 4S batteries you can transmit each cell voltage
of each of the batteries. There are different I2C ADC chips out there
that could probably do more than just 4 readings. For now I've
selected the ADS1115 because it was inexpensive (10€ for a couple of
them on a PCB) and because my current plane build only requires three
2S batteries.
Scaling of the values isn't currently done nor is there a
concrete plan for it. This is just a POC of the idea.
The way the values are currently collected isn't finalized yet. I
mainly wanted to get the reading part done in a way that isn't
blocking the core for excessive amounts of time. This currently has
the side effect of requiring multiple
timeout
calls of the code inorder to produce the first full reading of all connected cells.
As one of the next steps of my POC I wanted to add some
hardware.html-ish webui feature to configure parameters for each of
the cells sensors, e.g. scaling, sensitivity, update rate, ... Perhaps
that could even be done via lua without duplicating too much of the
logic in multiple places?!
The ADS1115 turned out to be a not-so-great choice. The measurments
seem to be fine but detecting the device requires too much "guessing"
with the reset-vector values. I'd much prefer a CHIP_ID register to
read from... Perhaps it isn't too bad since this is only during startup?
Also I'm not happy with naming of the files / "subsystem". Naming was
by far the hardest part and I decided to wait for external feedback on that.
The initial "design" was based off the barometric sensor code as that is also I2C with a a couple of devices providing ~similar features.