[OpenTRV-dev] Multiple DS18B20 sensors

Jeremy Poulter jeremy at bigjungle.net
Sun Mar 6 12:49:42 GMT 2016


I have just started adding the code to support multiple DS18B20 external
temperature sensors (see https://github.com/opentrv/OTRadioLink/pull/44)
but I have some queries regarding the sensor API before moving forward.

Currently an instance of the TemperatureC16_DS18B20 class is needed for
each DS18B20 sensor and at 17 bytes each this could limit the number of
sensors that can be used. The API could be changed to pass an address to
the read method dropping the memory usage down to 8 bytes (or even 7 bytes
as the first byte is always 0x28) per sensor or even just an index that
would require no additional bytes per sensor, but probably a little slower
to read the sensor. As an aside, I am not sure what determines the order on
the bus so there may be a possibility of the sensors being in a different
order per read or per power-cycle.

The obvious down side to changing the API is that you loose the nice
consistent API that all the sensors have and will have to start adding a
bunch of special cases to read the DS18B20 which I would think is probably
not a critical use case so may not warrant polluting the code base, that
being said are there other sensors that you may have multiple instances of
and thus is it worth changing the base class to support indexed/addressed
reads of a single sensor type?

The other question I have is how important would hot swapping the temp
sensors be, or is it ok to expect a power cycle after
adding/removing/changing a sensor?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opentrv.org.uk/pipermail/opentrv-dev/attachments/20160306/7312bd61/attachment.html>

More information about the OpenTRV-dev mailing list