GY-63_MS5611/libraries/DS18B20_RT/examples/DS18B20_getAddress/DS18B20_getAddress.ino

56 lines
933 B
Arduino
Raw Normal View History

2021-01-29 06:31:58 -05:00
//
// FILE: DS18B20_getAddress.ino
// AUTHOR: Rob Tillaart
// PURPOSE: DS18B20 lib getAddress demo
2021-12-17 05:59:45 -05:00
// URL: https://github.com/RobTillaart/DS18B20_RT
2021-01-29 06:31:58 -05:00
#include <OneWire.h>
#include <DS18B20.h>
2021-12-17 05:59:45 -05:00
#define ONE_WIRE_BUS 2
2021-01-29 06:31:58 -05:00
OneWire oneWire(ONE_WIRE_BUS);
DS18B20 sensor(&oneWire);
DeviceAddress da;
2021-12-17 05:59:45 -05:00
2021-01-29 06:31:58 -05:00
void setup()
{
Serial.begin(115200);
Serial.println(__FILE__);
Serial.print("DS18B20 Library version: ");
Serial.println(DS18B20_LIB_VERSION);
Serial.print("\ngetAddress: ");
Serial.println(sensor.getAddress(da));
2021-12-17 05:59:45 -05:00
2021-01-29 06:31:58 -05:00
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()
{
}
2021-12-17 05:59:45 -05:00
// -- END OF FILE --