Skip to content

Conversation

@str4t0m
Copy link
Contributor

@str4t0m str4t0m commented Jul 1, 2024

Several reliability improvements to the sensor driver that make sure the configuration is applied correctly and sensor issues causing invalid read(device disconnection, bus disruption) are reported correctly.
Additionally, error handling is added to the corresponding sample.

  • drivers: sensor: ds18b20: cleanup header/includes
  • drivers: sensor: ds18b20: verify crc of scratchpad
  • drivers: sensor: ds18b20: verify scratchpad write
  • drivers: sensor: ds18b20: indicate error for missing response
  • samples: sensor: ds18b20: clearly indicate any errors

Closes #74898

@str4t0m str4t0m changed the title sensors: ds18b20: reliablilty improvements: sensors: ds18b20: reliablilty improvements Jul 1, 2024
str4t0m added 5 commits July 1, 2024 13:29
- Move the content of the header file into the source file,
and drop unnecessary includes.
- Also, drop the bus access function.

Signed-off-by: Thomas Stranger <[email protected]>
After each read of the scratchpad the crc of the data
is checked and in case of a mismatch an error is returned.

Signed-off-by: Thomas Stranger <[email protected]>
Verify that the scratchpad write was successful by
reading back the configuration.

Signed-off-by: Thomas Stranger <[email protected]>
When multiple devices are on the bus, and no slave matches
the sent rom, the master receives only ones.
This should be handled explicitly and the error reporting
should not rely on the crc mismatch of the scratchpad.

Note: Make sure that the sensor configuration is loaded to the
eeprom (copy scratchpad), otherwise the resolution will not match
the expectations in case a node looses power and recovers.
As in that case the configuration will not be applied again.
Also the sensor may still report the power on reset value
of +85°C just after the sensor powered up.

Signed-off-by: Thomas Stranger <[email protected]>
Any errors are clearly indicated and program execution
ended.

Signed-off-by: Thomas Stranger <[email protected]>
Copy link
Contributor

@Martdur Martdur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed 74898 I've done quite the same modification on my DS18B20 implementation and I can detect bad reading scratchpad so I can only agree this PR
But I've not tested this specific PR for the moment, maybe some further tests are needed.

@nashif nashif merged commit 48e2354 into zephyrproject-rtos:main Jul 9, 2024
@str4t0m str4t0m deleted the ds18b20_fix branch July 28, 2025 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Samples Samples area: Sensors Sensors platform: ADI Analog Devices, Inc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

W1 DS2484 seems to ignore W1 disconection.

6 participants