-
Notifications
You must be signed in to change notification settings - Fork 0
/
Humidity.ino
68 lines (56 loc) · 1.47 KB
/
Humidity.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
63
64
65
66
67
//This file contains subroutines for the humidity sensor.
void HumSetup(){
//nothing happens here
}
float HumReadTemp(){
//note this isn't working yet, no traffic on the I2C1 bus
int HumTemp1 = 0;
int HumTemp2 = 0;
int HumTemp3 = 0;
Serial.println("temp sub");
Wire1.beginTransmission(HumAddr);
Wire1.write(0xE3);
delay(5);
Wire1.requestFrom(HumAddr, 3);
//while (!Wire1.available()) {
// if (htu_tmo++ > HTU_TIMEOUT)
// break;
// else
// delay(1);
//}
HumTemp1 = Wire1.read();
HumTemp2 = Wire1.read();
HumTemp3 = Wire1.read();
//}
Serial.println("read complete");
int Stemp = (HumTemp1 << 8) | HumTemp2;
float temp = -46.85 + (175.72 * Stemp / ((float) (unsigned int) 0x10000));
return temp;
// See data sheet for this formula
}
float HumReadHum(){
//note this also isn't working yet, no traffic on the I2C1 bus
int HumHum1 = 0;
int HumHum2 = 0;
int HumHum3 = 0;
Serial.println("hum sub");
Wire1.beginTransmission(HumAddr);
Wire1.write(0xE5);
delay(5);
Wire1.requestFrom(HumAddr, 3);
//while (!Wire1.available()) {
// if (htu_tmo++ > HTU_TIMEOUT)
// break;
// else
// delay(1);
//}
HumHum1 = Wire1.read();
HumHum2 = Wire1.read();
HumHum3 = Wire1.read();
//}
Serial.println("read complete");
int SHumTemp = (HumHum1 << 8) | HumHum2;
float temp = -6.0 + (125.0 * SHumTemp / ((float) (unsigned int) 0x10000));
return temp;
// See data sheet for this formula
}