1
+ // Include the libraries we need
1
2
#include < OneWire . h>
2
3
#include < DallasTemperature . h>
3
4
@@ -13,6 +14,9 @@ DallasTemperature sensors(&oneWire);
13
14
// arrays to hold device address
14
15
DeviceAddress insideThermometer;
15
16
17
+ /*
18
+ * Setup function. Here we do the basics
19
+ */
16
20
void setup (void )
17
21
{
18
22
// start serial port
@@ -31,14 +35,15 @@ void setup(void)
31
35
if (sensors. isParasitePowerMode()) Serial . println(" ON" );
32
36
else Serial . println(" OFF" );
33
37
34
- // assign address manually. the addresses below will beed to be changed
35
- // to valid device addresses on your bus. device address can be retrieved
38
+ // Assign address manually. The addresses below will beed to be changed
39
+ // to valid device addresses on your bus. Device address can be retrieved
36
40
// by using either oneWire.search(deviceAddress) or individually via
37
41
// sensors.getAddress(deviceAddress, index)
42
+ // Note that you will need to use your specific address here
38
43
// insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
39
44
40
45
// Method 1:
41
- // search for devices on the bus and assign based on an index. ideally ,
46
+ // Search for devices on the bus and assign based on an index. Ideally ,
42
47
// you would do this to initially discover addresses on the bus and then
43
48
// use those addresses and manually assign them (see above) once you know
44
49
// the devices on your bus (and assuming they don't change).
@@ -47,8 +52,8 @@ void setup(void)
47
52
// method 2: search()
48
53
// search() looks for the next device. Returns 1 if a new address has been
49
54
// returned. A zero might mean that the bus is shorted, there are no devices,
50
- // or you have already retrieved all of them. It might be a good idea to
51
- // check the CRC to make sure you didn't get garbage. The order is
55
+ // or you have already retrieved all of them. It might be a good idea to
56
+ // check the CRC to make sure you didn't get garbage. The order is
52
57
// deterministic. You will always get the same devices in the same order
53
58
//
54
59
// Must be called before search()
@@ -85,7 +90,9 @@ void printTemperature(DeviceAddress deviceAddress)
85
90
Serial . print(" Temp F: " );
86
91
Serial . println(DallasTemperature :: toFahrenheit(tempC)); // Converts tempC to Fahrenheit
87
92
}
88
-
93
+ /*
94
+ * Main function. It will request the tempC from the sensors and display on Serial.
95
+ */
89
96
void loop (void )
90
97
{
91
98
// call sensors.requestTemperatures() to issue a global temperature
0 commit comments