DavidAntliff / esp32-ds18b20-example

ESP32-compatible example for Maxim Integrated DS18B20 Programmable Resolution 1-Wire Digital Thermometer.
MIT License
108 stars 34 forks source link

Known devices are not recognised #3

Closed esp32x closed 6 years ago

esp32x commented 6 years ago

In this case the device with index 1 is listed and readable but not present.

Find devices:
  0 : 6b000006d86d7428
  1 : 35000006d8c37e28
  2 : 45000006d6767528
  3 : b4000006d6e70b28
Found 4 devices
Device 35000006d8c37e28 is not present

Temperature readings (degrees C): sample 1
  0: 24.4    0 errors
  1: 24.6    0 errors
  2: 24.4    0 errors
  3: 24.3    0 errors
    // Known ROM code (LSB first):
    OneWireBus_ROMCode known_device = {
        .fields.family = { 0x28 },
        .fields.serial_number = { 0x7e, 0xc3, 0xd8, 0x06, 0x00, 0x00 },
        .fields.crc = { 0x35 },
    };
DavidAntliff commented 6 years ago

Can you check the return value of owb_verify_rom()? What does it return? The code should probably check this value to ensure no error occurred.

esp32x commented 6 years ago

It returns 0.

If I change the serial_number it also returns 0.

DavidAntliff commented 6 years ago

@esp32x thanks for reporting this. I think I've fixed the problem in the esp32-owb component where only the first detected device was being considered for a known device. Please test with your set-up.

https://github.com/DavidAntliff/esp32-owb/commit/bc69da51bfa766d8023e82cd214ac61349960095

esp32x commented 6 years ago

It works :+1:

Find devices:
  0 : 6b000006d86d7428
  1 : 35000006d8c37e28
  2 : 45000006d6767528
  3 : b4000006d6e70b28
Found 4 devices
Device A (35000006d8c37e28) is present
Device B (b4000006d6e70b28) is present

Temperature readings (degrees C): sample 1
  0: 25.6    0 errors
  1: 25.6    0 errors
  2: 25.4    0 errors
  3: 25.5    0 errors
DavidAntliff commented 6 years ago

Great, thank you for testing it out.