Missing Char in I2C scanning

Hello,
I am trying to monitor 3 DS18B20 themperature sensors over the internet.

For this I am using an LoLin NodeMCU V3 and 3 of the themp sensors.

(Theres a resistor between 3.3V and data line)

From an earlier project I already know 2 addresses.
So I tried to find out address number 3.

But when I let the scanner run, it always displays me addresses with missing characters on the same location (HEX 7).

ROM = 0x28, 0xFF, 0xCC, 0x33, 0x8B, 0x16, 0x3, 0x8C

ROM = 0x28, 0xFF, 0xE2, 0x37, 0x8B, 0x16, 0x3, 0xD8

ROM = 0x28, 0xFF, 0x55, 0x45, 0x93, 0x16, 0x4, 0x85

These are the 2 I know:
0x28, 0xFF, 0xE2, 0x37, 0x8B, 0x16, 0x0B, 0xD8
0x28, 0xFF, 0xCC, 0x33, 0x8B, 0x16, 0x03, 0x8C

Any idea why this is the case?

Thank you!

Scanning code:

#include <OneWire.h>

OneWire  ds(4);  
 
byte i;
byte type_s;
byte data[12];
byte addr[8];
  
void OneWireScanner(){
  if ( !ds.search(addr)) {
    Serial.println("No more addresses.");
    Serial.println();
    ds.reset_search();
    return;
  }
  
  Serial.print("ROM = ");
  for( i = 0; i < 8; i++) {
    Serial.write(' ');
    Serial.print("0x");
    Serial.print(addr[i], HEX);
    if ( i != 7 ) {
      Serial.print(", ");
    }
  }
  
  if (OneWire::crc8(addr, 7) != addr[7]) {
      Serial.println("CRC is not valid!");
      return;
  }
  Serial.println();
 
  
  switch (addr[0]) {
    case 0x10:
      Serial.println("  Chip = DS18S20");  // or old DS1820
      type_s = 1;
      break;
    case 0x28:
      Serial.println("  Chip = DS18B20");
      type_s = 0;
      break;
    case 0x22:
      Serial.println("  Chip = DS1822");
      type_s = 0;
      break;
    default:
      Serial.println("Device is not a DS18x20 family device.");
      return;
  } 
}
 
void setup() {
   Serial.begin(115200);
}
 
void loop() {
  // put your main code here, to run repeatedly:
  OneWireScanner();
  delay(5000); }

Your code is not set up to print the leading zero in hex byte values of less than 0x10.
Add a line to do that.

Serial.print("ROM = ");
  for( i = 0; i < 8; i++) {
    Serial.write(' ');
    Serial.print("0x");
    if (address[i] < 0x10) Serial.print("0"); //add this line to print leading 0
    Serial.print(addr[i], HEX);
    if ( i != 7 ) {
      Serial.print(", ");
    }
  }

These three all have a good CRC and are therefore almost certainly valid DS18B20 addresses.

ROM =  0x28,  0xFF,  0xCC,  0x33,  0x8B,  0x16,  0x3,  0x8C
ROM =  0x28,  0xFF,  0xE2,  0x37,  0x8B,  0x16,  0x3,  0xD8
ROM =  0x28,  0xFF,  0x55,  0x45,  0x93,  0x16,  0x4,  0x85

The first of these two does not have a valid CRC and therefore can’t be a DS18B20 ROM address. The second one is OK (it’s the first one in the list above).

These are the 2 I know:
0x28, 0xFF, 0xE2, 0x37, 0x8B, 0x16, 0x0B, 0xD8 <<< not a ROM address
0x28, 0xFF, 0xCC, 0x33, 0x8B, 0x16, 0x03, 0x8C

Your code works for the two DS18B20 I have here.

Pete

Hello, thank you for your help!

I already saw from my older programm that the <10 is missing and addet it, but for me (noob in HEX Addresses and this kind of stuff) it was not clear if its right.

How do you know that the address is valid?

Strange thing was: If I putted the 2 addresses in my temp code, only 2 of 3 worked, no matter with or without correct address in it.
That confuses me…

But now, knowing the addresses are right with addet zeros, I´ll first try it on my own.