Skip to content

Commit ade7827

Browse files
committed
Add DS1990A example sketch
1 parent 612c464 commit ade7827

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ The OWI library has been developed to support the implementation of
1111
## Example Sketches
1212

1313
* [DS18B20](./examples/DS18B20)
14+
* [DS1990A](./examples/DS1990A)
1415
* [Scanner](./examples/Scanner)

examples/DS1990A/DS1990A.ino

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include "OWI.h"
2+
#include "GPIO.h"
3+
#include "Software/OWI.h"
4+
5+
// Table with valid keys (64 bit 1-Wire rom code, 8 bytes per entry)
6+
const uint8_t KEY[] PROGMEM = {
7+
0x01, 0x23, 0x81, 0xa3, 0x09, 0x00, 0x00, 0x7b,
8+
0x01, 0x29, 0x01, 0x27, 0x09, 0x00, 0x00, 0xa8,
9+
0x01, 0x26, 0xd9, 0x3e, 0x09, 0x00, 0x00, 0x47
10+
};
11+
12+
// One-Wire bus manager
13+
Software::OWI<BOARD::D7> owi;
14+
15+
// Use built-in LED to signal
16+
GPIO<BOARD::D13> led;
17+
18+
void setup()
19+
{
20+
led.output();
21+
led = LOW;
22+
}
23+
24+
void loop()
25+
{
26+
// Attempt to read key every seconds
27+
uint8_t rom[owi.ROM_MAX] = { 0 };
28+
delay(1000);
29+
if (!owi.read_rom(rom)) return;
30+
31+
// Check if it is an authorized key. One long blink if found
32+
for (uint8_t i = 0; i < sizeof(KEY); i += OWI::ROM_MAX) {
33+
if (!memcmp_P(rom, &KEY[i], owi.ROM_MAX)) {
34+
led = HIGH;
35+
delay(1000);
36+
led = LOW;
37+
return;
38+
}
39+
}
40+
41+
// Three short blinks if not found
42+
for (uint8_t i = 0; i < 3; i++) {
43+
delay(250);
44+
led = HIGH;
45+
delay(250);
46+
led = LOW;
47+
}
48+
}

0 commit comments

Comments
 (0)