-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtemperature_search.ino
61 lines (47 loc) · 1.36 KB
/
temperature_search.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// THIS SKETCH REQUIRES:
// Libraries in the standard arduino libraries folder:
//
// - OneWire library http://www.pjrc.com/teensy/td_libs_OneWire.html
// - DallasTemperature http://download.milesburton.com/Arduino/MaximTemperature
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 4
#define TEMPERATURE_PRECISION 12
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
void setup()
{
delay(1000);
Serial.begin(9600);
Serial.println("Temperature search");
Serial.println("waiting 6 seconds before printing");
delay(6000);
sensors.begin();
DeviceAddress tmp_address;
int numberOfDevices = sensors.getDeviceCount();
for(int i=0;i<numberOfDevices; i++)
{
sensors.getAddress(tmp_address, i);
printAddress(tmp_address);
Serial.println();
}
}
void loop()
{
}
void printAddress(DeviceAddress deviceAddress)
{
Serial.print("{ ");
for (uint8_t i = 0; i < 8; i++)
{
// zero pad the address if necessary
Serial.print("0x");
if (deviceAddress[i] < 16) Serial.print("0");
Serial.print(deviceAddress[i], HEX);
if (i<7) Serial.print(", ");
}
Serial.print(" }");
}