-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitialization.ino
More file actions
89 lines (82 loc) · 2.62 KB
/
Initialization.ino
File metadata and controls
89 lines (82 loc) · 2.62 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
void InitSensors(void) {
DeviceAddress addr[3];
// Start up the library
sensors.begin(); // IC Default 9 bit. If you have troubles consider upping it 12. Ups the delay giving the IC more time to process the temperature measurement
Serial.print(F ("Found "));
Serial.print(sensors.getDeviceCount(), DEC);
Serial.println(F (" DS18B20 devices."));
Serial.println();
oneWire.reset_search();
for (byte i = 0; i < sensors.getDeviceCount(); i++) {
sensors.getAddress(addr[i], i);
printAddress(addr[i]);
if (!memcmp(CubeThermometer, addr[i], 8)) {
Serial.println (F ("Found CubeThermometer."));
sensors.setResolution(CubeThermometer, TEMPERATURE_PRECISION);
IsFoundCubeThermometr = 1;
Serial.println();
}
if (!memcmp(DeflThermometer, addr[i], 8)) {
Serial.println (F ("Found DeflThermometer."));
sensors.setResolution(DeflThermometer, TEMPERATURE_PRECISION);
IsFoundDeflThermometr = 1;
Serial.println();
}
if (!memcmp(AlarThermometer, addr[i], 8)) {
Serial.println (F ("Found AlarThermometer."));
sensors.setResolution(AlarThermometer, TEMPERATURE_PRECISION);
IsFoundAlarThermometr = 1;
Serial.println();
}
}
if (IsFoundCubeThermometr == 0) Serial.println(F ("Critical Error. CubeThermometer not found!"));
if (IsFoundDeflThermometr == 0) Serial.println(F ("Critical Error. DeflThermometer not found!"));
if (IsFoundAlarThermometr == 0) Serial.println(F ("Warning. AlarThermometer not found!"));
}
void SearchSensors() {
byte addr[8];
if (oneWire.search(addr) != 1)
{
oneWire.reset_search();
delay(1000);
for (byte i = 0; i < 8; i++) addr[i] = 0;
return;
}
oneWire.reset();
oneWire.select(addr);
Serial.println("----------");
Serial.print(F ("Addr: "));
for (byte i = 0; i < 8; i++)
{
Serial.print("0x");
if (addr[i] < 0x10) Serial.print("0");
Serial.print(addr[i], HEX);
if (i == 8) Serial.println();
else Serial.print(", ");
}
}
void printAddress(DeviceAddress deviceAddress) {
Serial.print(F ("Addr: "));
for (uint8_t i = 0; i < 8; i++)
{
Serial.print("0x");
if (deviceAddress[i] < 0x10) Serial.print("0");
Serial.print(deviceAddress[i], HEX);
if (i == 7) Serial.println();
else Serial.print(", ");
}
}
void InitBMP(void) {
if (pressure.begin()) {
Serial.println(F ("BMP180 init success"));
IsFoundBMP180 = 1;
CurrAtmPress = GetAtmPressure();
CurrTempHkip = tempHkip();
Serial.print(F ("CurrTempHkip - "));
Serial.println(CurrTempHkip);
}
else {
Serial.println(F ("BMP180 init fail\n\n"));
//while (1); // Pause forever.
}
}