金属探头防水效果很好,直接插到热水也没事,室温27°
温水35
用的库代码,十分方便
/* Check if connected device is DS18B20 */
if (TM_DS18B20_Is(DS_ROM)) {
/* Everything is done */
if (TM_DS18B20_AllDone(&OW)) {
/* Read temperature from device */
if (TM_DS18B20_Read(&OW, DS_ROM, &temp)) {
/* Temp read OK, CRC is OK */
/* Start again on all sensors */
TM_DS18B20_StartAll(&OW);
sprintf(tmpbuffer, "temp:%0.1f", temp);
printf("tmp=%0.1f\r\n",temp);
TM_SSD1306_GotoXY(0, 25);
TM_SSD1306_Puts(tmpbuffer, &TM_Font_7x10, SSD1306_COLOR_WHITE);
/* Check temperature */
if (temp > 30) {
TM_DISCO_LedOn(LED_GREEN);
} else {
TM_DISCO_LedOff(LED_GREEN);
}
} else {
/* CRC failed, hardware problems on data line */
}
金属探头防水效果很好,直接插到热水也没事,室温27°
温水35
用的库代码,十分方便
/* Check if connected device is DS18B20 */
if (TM_DS18B20_Is(DS_ROM)) {
/* Everything is done */
if (TM_DS18B20_AllDone(&OW)) {
/* Read temperature from device */
if (TM_DS18B20_Read(&OW, DS_ROM, &temp)) {
/* Temp read OK, CRC is OK */
/* Start again on all sensors */
TM_DS18B20_StartAll(&OW);
sprintf(tmpbuffer, "temp:%0.1f", temp);
printf("tmp=%0.1f\r\n",temp);
TM_SSD1306_GotoXY(0, 25);
TM_SSD1306_Puts(tmpbuffer, &TM_Font_7x10, SSD1306_COLOR_WHITE);
/* Check temperature */
if (temp > 30) {
TM_DISCO_LedOn(LED_GREEN);
} else {
TM_DISCO_LedOff(LED_GREEN);
}
} else {
/* CRC failed, hardware problems on data line */
}