I'm using this example with an ESP8266 and it works fine until it hits 0*C, then it gives out weird stuff:
Temperatures samples:
4073.5625
4069.375
4068.9375
4068.75
4068.75
4068.6875
I put my one Wire in my freezer.
When you put MSB and LSB together on ESP32, it seems that (data[DATA.TEMP_MSB] << 8) (line 63)
results in the correct signed number. But on the ESP8266 it looks like it results in an unsigned number. This will turn all negative numbers into large positive ones. For example, 0xFFF8 is -0.5 degrees, but as a positive number it is 65528 and dividing by 16 gives you 4095.5.
In C example declaring int16_t raw; forces the compiler to treat the result as a signed 16-bit integer which then gives the correct result.