Hi, in fact I bought them on Amazon. But could a counterfeit sensor give a right temperature and wrong CRC? The reading seems okay, just touching it with the finger causes it to rise immediately and then go down again when I release it.
This is the relevant part of the code:
if (Read_bit())
{
if (ds18b20_start())
{
Write_byte(0xCC); // Send skip ROM command
Write_byte(0xBE); // Send read command
for (int i = 0; i < 9; i++)
{
scratchPad[i] = Read_byte();
}
Serial.print("Scratchpad: ");
for (int i = 0; i < 9; i++)
{
Serial.print(scratchPad[i]);
Serial.print(" ");
}
Serial.println();
//bool test = crc8(scratchPad, 8) == scratchPad[8];
Serial.print("Calc CRC: ");
Serial.println(crc8(scratchPad, 8));
}
temp = ReadSensor() / 16.0;
Serial.print("Temp: ");
Serial.print(temp);
Serial.println(" ºC.");
Serial.println();
}