-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathonewire.ino
63 lines (42 loc) · 1.24 KB
/
onewire.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
61
62
/***************************************************
* This sketch is for OneWire functions.
* http://www.hobbytronics.co.uk/ds18b20-arduino
*
* Author: Brun
*
****************************************************/
#ifdef ONEWIRE
#include <DallasTemperature.h>
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
unsigned long onewire_timer = 0;
void onewire_init() {
display_bootmsg(F("Init OneWire"));
sensors.begin();
sensors.requestTemperatures(); // Send the command to get temperatures
ds18b20_temp = sensors.getTempCByIndex(0)*10;
if (sensors.getTempCByIndex(0) != -127 ) {
DEBUG_PRINTLN(F("#OneWire sensors found"));
onewire_available = true;
//delay(2000);
if ( temp_out_port == 0 ) {
temp_out_port = 1;
}
}
else {
if ( temp_out_port == 1 ) {
temp_out_port = 2;
}
}
}
void onewire_loop() {
if ( ( onewire_timer < millis() ) && onewire_available ) {
onewire_timer = millis() + ONEWIRE_TIMER;
sensors.requestTemperatures(); // Send the command to get temperatures
ds18b20_temp = sensors.getTempCByIndex(0)*10;
//if (ds18b20_temp = -127 ) {
// DEBUG_PRINTLN(F("#NO sensor found"));
//}
}
}
#endif