Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAddresses additional to getAddress(uint8_t* deviceAddress, uint8_t index) #231

Open
debuglevel opened this issue Nov 2, 2022 · 1 comment

Comments

@debuglevel
Copy link

debuglevel commented Nov 2, 2022

The most usual code flow (of what I've seen so far) is to get the number of devices and then iterate over them to get their address and finally to get the temperature. But getAddress gets very slow for a number of about 15-20 sensors. It might help to request all addresses once via a new getAddresses function and just re-use them.

Of course its possible to do this on your own code, but it's always nice if a library facilitates such things and points the user to a more efficient solution :)

Pro: Should be faster. It could be even less error-prone if sensors get replaced while getAddress is run.
Contra: Devs might work with an out-of-date array of addresses; it should be therefore be well documented (e.g. "if you want to replace sensors, refresh addresses on every loop).

As I'm working with an ESP32, I also thought about the library to just save an address array itself. But as most Arduinos have a serious memory issue, that might be unwise.

@RobTillaart
Copy link
Contributor

As I'm working with an ESP32, I also thought about the library to just save an address array itself. But as most Arduinos have a serious memory issue, that might be unwise.

Memory is indeed an issue, (think UNO) two possible solutions (?)

  1. put the address array in PROGMEM => contra: only compile time possible, maybe even AVR specific
  2. use compression. The addresses of DS18B20 consist of 8 bytes from which 6 are the unique ID, the other two indicate the type and are always the same. That means that you do not need to store them, effectively a 25% compression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants