Skip to content

Commit c4bb43f

Browse files
committed
Merge pull request #41 from mvhconsult/master
Updated some comments and descriptions
2 parents 4b9fb67 + 326194e commit c4bb43f

File tree

5 files changed

+66
-47
lines changed

5 files changed

+66
-47
lines changed

examples/Multiple/Multiple.pde

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Include the libraries we need
12
#include <OneWire.h>
23
#include <DallasTemperature.h>
34

@@ -34,14 +35,14 @@ void setup(void)
3435
if (sensors.isParasitePowerMode()) Serial.println("ON");
3536
else Serial.println("OFF");
3637

37-
// assign address manually. the addresses below will beed to be changed
38-
// 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
3940
// by using either oneWire.search(deviceAddress) or individually via
4041
// sensors.getAddress(deviceAddress, index)
4142
//insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
4243
//outsideThermometer = { 0x28, 0x3F, 0x1C, 0x31, 0x2, 0x0, 0x0, 0x2 };
4344

44-
// search for devices on the bus and assign based on an index. ideally,
45+
// Search for devices on the bus and assign based on an index. Ideally,
4546
// you would do this to initially discover addresses on the bus and then
4647
// use those addresses and manually assign them (see above) once you know
4748
// the devices on your bus (and assuming they don't change).
@@ -53,8 +54,8 @@ void setup(void)
5354
// method 2: search()
5455
// search() looks for the next device. Returns 1 if a new address has been
5556
// returned. A zero might mean that the bus is shorted, there are no devices,
56-
// or you have already retrieved all of them. It might be a good idea to
57-
// check the CRC to make sure you didn't get garbage. The order is
57+
// or you have already retrieved all of them. It might be a good idea to
58+
// check the CRC to make sure you didn't get garbage. The order is
5859
// deterministic. You will always get the same devices in the same order
5960
//
6061
// Must be called before search()
@@ -73,7 +74,7 @@ void setup(void)
7374
printAddress(outsideThermometer);
7475
Serial.println();
7576

76-
// set the resolution to 9 bit
77+
// set the resolution to 9 bit per device
7778
sensors.setResolution(insideThermometer, TEMPERATURE_PRECISION);
7879
sensors.setResolution(outsideThermometer, TEMPERATURE_PRECISION);
7980

@@ -125,6 +126,9 @@ void printData(DeviceAddress deviceAddress)
125126
Serial.println();
126127
}
127128

129+
/*
130+
* Main function, calls the temperatures in a loop.
131+
*/
128132
void loop(void)
129133
{
130134
// call sensors.requestTemperatures() to issue a global temperature

examples/Simple/Simple.pde

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Include the libraries we need
12
#include <OneWire.h>
23
#include <DallasTemperature.h>
34

@@ -10,6 +11,9 @@ OneWire oneWire(ONE_WIRE_BUS);
1011
// Pass our oneWire reference to Dallas Temperature.
1112
DallasTemperature sensors(&oneWire);
1213

14+
/*
15+
* The setup function. We only start the sensors here
16+
*/
1317
void setup(void)
1418
{
1519
// start serial port
@@ -20,14 +24,18 @@ void setup(void)
2024
sensors.begin();
2125
}
2226

27+
/*
28+
* Main function, get and show the temperature
29+
*/
2330
void loop(void)
2431
{
2532
// call sensors.requestTemperatures() to issue a global temperature
2633
// request to all devices on the bus
2734
Serial.print("Requesting temperatures...");
2835
sensors.requestTemperatures(); // Send the command to get temperatures
2936
Serial.println("DONE");
30-
37+
// After we got the temperatures, we can print them here.
38+
// We use the function ByIndex, and as an example get the temperature from the first sensor only.
3139
Serial.print("Temperature for the device 1 (index 0) is: ");
3240
Serial.println(sensors.getTempCByIndex(0));
3341
}

examples/Single/Single.pde

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Include the libraries we need
12
#include <OneWire.h>
23
#include <DallasTemperature.h>
34

@@ -13,6 +14,9 @@ DallasTemperature sensors(&oneWire);
1314
// arrays to hold device address
1415
DeviceAddress insideThermometer;
1516

17+
/*
18+
* Setup function. Here we do the basics
19+
*/
1620
void setup(void)
1721
{
1822
// start serial port
@@ -31,14 +35,15 @@ void setup(void)
3135
if (sensors.isParasitePowerMode()) Serial.println("ON");
3236
else Serial.println("OFF");
3337

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
3640
// by using either oneWire.search(deviceAddress) or individually via
3741
// sensors.getAddress(deviceAddress, index)
42+
// Note that you will need to use your specific address here
3843
//insideThermometer = { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 };
3944

4045
// 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,
4247
// you would do this to initially discover addresses on the bus and then
4348
// use those addresses and manually assign them (see above) once you know
4449
// the devices on your bus (and assuming they don't change).
@@ -47,8 +52,8 @@ void setup(void)
4752
// method 2: search()
4853
// search() looks for the next device. Returns 1 if a new address has been
4954
// 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
5257
// deterministic. You will always get the same devices in the same order
5358
//
5459
// Must be called before search()
@@ -85,7 +90,9 @@ void printTemperature(DeviceAddress deviceAddress)
8590
Serial.print(" Temp F: ");
8691
Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
8792
}
88-
93+
/*
94+
* Main function. It will request the tempC from the sensors and display on Serial.
95+
*/
8996
void loop(void)
9097
{
9198
// call sensors.requestTemperatures() to issue a global temperature

examples/Tester/Tester.pde

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// Data wire is plugged into port 2 on the Arduino
55
#define ONE_WIRE_BUS 2
6-
#define TEMPERATURE_PRECISION 9
6+
#define TEMPERATURE_PRECISION 9 // Lower resolution
77

88
// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
99
OneWire oneWire(ONE_WIRE_BUS);

keywords.txt

+33-33
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
#######################################
2-
# Syntax Coloring Map For Ultrasound
2+
# Syntax Coloring Map For DallasTemperature
33
#######################################
44

55
#######################################
66
# Datatypes (KEYWORD1)
77
#######################################
8-
DallasTemperature KEYWORD1
9-
OneWire KEYWORD1
10-
AlarmHandler KEYWORD1
11-
DeviceAddress KEYWORD1
8+
DallasTemperature KEYWORD1
9+
OneWire KEYWORD1
10+
AlarmHandler KEYWORD1
11+
DeviceAddress KEYWORD1
1212

1313
#######################################
1414
# Methods and Functions (KEYWORD2)
1515
#######################################
1616

17-
setResolution KEYWORD2
18-
getResolution KEYWORD2
19-
getTempC KEYWORD2
20-
toFahrenheit KEYWORD2
21-
getTempF KEYWORD2
22-
getTempCByIndex KEYWORD2
23-
getTempFByIndex KEYWORD2
17+
setResolution KEYWORD2
18+
getResolution KEYWORD2
19+
getTempC KEYWORD2
20+
toFahrenheit KEYWORD2
21+
getTempF KEYWORD2
22+
getTempCByIndex KEYWORD2
23+
getTempFByIndex KEYWORD2
2424
setWaitForConversion KEYWORD2
2525
getWaitForConversion KEYWORD2
26-
requestTemperatures KEYWORD2
26+
requestTemperatures KEYWORD2
2727
requestTemperaturesByAddress KEYWORD2
2828
requestTemperaturesByIndex KEYWORD2
29-
isParasitePowerMode KEYWORD2
30-
begin KEYWORD2
31-
getDeviceCount KEYWORD2
32-
getAddress KEYWORD2
33-
validAddress KEYWORD2
34-
isConnected KEYWORD2
35-
readScratchPad KEYWORD2
36-
writeScratchPad KEYWORD2
37-
readPowerSupply KEYWORD2
38-
setHighAlarmTemp KEYWORD2
39-
setLowAlarmTemp KEYWORD2
40-
getHighAlarmTemp KEYWORD2
41-
getLowAlarmTemp KEYWORD2
42-
resetAlarmSearch KEYWORD2
43-
alarmSearch KEYWORD2
44-
hasAlarm KEYWORD2
45-
toCelsius KEYWORD2
46-
processAlarmss KEYWORD2
47-
setAlarmHandlers KEYWORD2
48-
defaultAlarmHandler KEYWORD2
29+
isParasitePowerMode KEYWORD2
30+
begin KEYWORD2
31+
getDeviceCount KEYWORD2
32+
getAddress KEYWORD2
33+
validAddress KEYWORD2
34+
isConnected KEYWORD2
35+
readScratchPad KEYWORD2
36+
writeScratchPad KEYWORD2
37+
readPowerSupply KEYWORD2
38+
setHighAlarmTemp KEYWORD2
39+
setLowAlarmTemp KEYWORD2
40+
getHighAlarmTemp KEYWORD2
41+
getLowAlarmTemp KEYWORD2
42+
resetAlarmSearch KEYWORD2
43+
alarmSearch KEYWORD2
44+
hasAlarm KEYWORD2
45+
toCelsius KEYWORD2
46+
processAlarmss KEYWORD2
47+
setAlarmHandlers KEYWORD2
48+
defaultAlarmHandler KEYWORD2
4949
calculateTemperature KEYWORD2
5050

5151
#######################################

0 commit comments

Comments
 (0)