118 * If there is no sensor, j = 0 |
118 * If there is no sensor, j = 0 |
119 */ |
119 */ |
120 if ((counter == 255) && (j == 0)) { |
120 if ((counter == 255) && (j == 0)) { |
121 if (dht11_temperature != -1) { |
121 if (dht11_temperature != -1) { |
122 syslog(LOG_NOTICE, "dht11 sensor disappeared"); |
122 syslog(LOG_NOTICE, "dht11 sensor disappeared"); |
|
123 } else { |
|
124 syslog(LOG_NOTICE, "dht11 sensor not present"); |
123 } |
125 } |
124 dht11_temperature = -1; |
126 dht11_temperature = -1; |
125 dht11_humidity = -1; |
127 dht11_humidity = -1; |
126 dht11_valid = false; |
128 dht11_valid = false; |
127 } else { |
129 return; |
|
130 } |
128 |
131 |
129 /* |
132 /* |
130 * check we read 40 bits (8bit x 5 ) + verify checksum in the last byte |
133 * check we read 40 bits (8bit x 5 ) + verify checksum in the last byte |
131 * print it out if data is good |
134 * print it out if data is good |
132 */ |
135 */ |
133 if ((j >= 40) && (dht11_dat[4] == ((dht11_dat[0] + dht11_dat[1] + dht11_dat[2] + dht11_dat[3]) & 0xFF))) { |
136 if ((j >= 40) && (dht11_dat[4] == ((dht11_dat[0] + dht11_dat[1] + dht11_dat[2] + dht11_dat[3]) & 0xFF))) { |
134 got_correct_data = 1; |
137 got_correct_data = 1; |
135 |
138 |
136 int h = dht11_dat[0] + dht11_dat[1]; |
139 int h = dht11_dat[0] + dht11_dat[1]; |
137 int t = (dht11_dat[2] & 0x7F) + dht11_dat[3]; |
140 int t = (dht11_dat[2] & 0x7F) + dht11_dat[3]; |
138 t += dht11_t_offset; |
141 t += dht11_t_offset; |