GY-63_MS5611/libraries/DS18B20_INT/examples/DS18B20_getAddress/DS18B20_getAddress.ino
2021-12-17 11:26:25 +01:00

57 lines
897 B
C++

//
// FILE: DS18B20_getAddress.ino
// AUTHOR: Rob Tillaart
// PURPOSE: DS18B20 lib getAddress demo
#include <OneWire.h>
#include <DS18B20_INT.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DS18B20_INT sensor(&oneWire);
DeviceAddress da;
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("DS18B20_INT_LIB_VERSION: ");
Serial.println(DS18B20_INT_LIB_VERSION);
Serial.print("\ngetAddress: ");
Serial.println(sensor.getAddress(da));
sensor.begin();
Serial.print("\ngetAddress: ");
Serial.println(sensor.getAddress(da));
if (!sensor.getAddress(da))
{
Serial.println("No address found!");
return;
}
Serial.print("Address: ");
for (uint8_t i = 0; i < 8; i++)
{
if (da[i] < 0x10) Serial.print('0');
Serial.print(da[i], HEX);
}
Serial.println();
}
void loop()
{
}
// -- END OF FILE --