Skip to content

Commit 1ec00d3

Browse files
committed
added CRC check
1 parent 6e758b3 commit 1ec00d3

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

sketches/oneWireSearch/oneWireSearch.ino

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: oneWireSearch.ino
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.03
4+
// VERSION: 0.1.04
55
// PURPOSE: scan for 1-Wire devices + code snippet generator
66
// DATE: 2015-june-30
77
// URL: http://forum.arduino.cc/index.php?topic=333923
@@ -14,8 +14,9 @@
1414
// 0.1.01 first published version
1515
// 0.1.02 small output changes
1616
// 0.1.03 added more explicit range
17+
// 0.1.04 added CRC check
1718

18-
// UNO 3..20
19+
// UNO 2..20
1920
// MEGA and others have different range
2021
const int startPin = 2;
2122
const int endPin = 20;
@@ -61,7 +62,16 @@ uint8_t findDevices(int pin)
6162
Serial.print(address[i], HEX);
6263
if (i < 7) Serial.print(", ");
6364
}
64-
Serial.println(" },");
65+
Serial.print(" },");
66+
// CHECK CRC
67+
if (ow.crc8(address, 7) == address[7])
68+
{
69+
Serial.println("\t\t// CRC OK");
70+
}
71+
else
72+
{
73+
Serial.println("\t\t// CRC FAILED");
74+
}
6575
} while (ow.search(address));
6676

6777
Serial.println("};");

0 commit comments

Comments
 (0)