← index #2093Issue #3218
Related · high · value 0.930
QUERY · ISSUE

RFC: Sensor driver interface

openby pfalconopened 2016-05-21updated 2025-10-01
rfc

As one of the latest KS stretch goals, we need to implement suite of drivers for number of sensors, and it would be nice to come up with a general sensor driver model to follow.

Requirements:

  1. A general, baseline interface (userstory: "I have a hundred of sensors, how do I use them in similar manner of any MicroPython port", not: "My project is centered around capabilities of a particular sensor, how do I expose them?")
  2. The general requirement is avoiding memory allocations to perform sensor reading
  3. One of the biggest contention points is usage of floating-point vs fixed points numbers, and if the latter, then how. Given that floating-point support is optional, and may lead to memory allocation, would be strongly nice to support (allocation-free) fixed point.
  4. Should be general enough for any sensor (including sensors which measure several values).
  5. There should be balance between efficiency tricks and pythonic ease of use.
CANDIDATE · ISSUE

RFC sensor API: updates?

closedby hoihuopened 2017-07-17updated 2024-07-05

sorry for not appending to #2093 but I'm unable to comment there (Gihub shows "You can't comment at this time") - for whatever reason that is.

I would like to update my SenseHAT drivers to the machine API. I'm currently working on the first one (HTS221, temp&humidity sensor) and started to implemented some functionality as described by @dpgeorge.

However I'm unsure if the driver API is stable...RFC #2093 has been silent for a while now and I haven't seen any driver popping up in the forum or elsewhere that follow the proposed guidelines.

So a couple of questions to hopefully revive this discussion:

  • Is the sensor API now fixed as per propsal made by @dpgeorge?
  • Are there "reference" drivers available that fulfill the proposal so they can be used as a guideline for driver developers?
  • Do we need to agree on a set of get_xx accessor methods for SensorBase? Are they going to be provided by the main repository?

If interested, I can provide a draft version of my WIP driver that I think comes close the the API (as a discussion base).

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied