Rev 2837 Rev 2907
Line 16... Line 16...
16 /////////////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////////////
17   17  
18 //#define sht_data_pin PIN_D0 18 //#define sht_data_pin PIN_D0
19 //#define sht_clk_pin PIN_D1 19 //#define sht_clk_pin PIN_D1
20   20  
21 #include <math.h> 21 //#include <math.h>
22   22  
23   23  
24 #define noACK 0 24 #define noACK 0
25 #define ACK 1 25 #define ACK 1
26 //adr command r/w 26 //adr command r/w
Line 203... Line 203...
203 return error; //error>=1 in case of no response form the sensor 203 return error; //error>=1 in case of no response form the sensor
204 } 204 }
205   205  
206 //***** Function to measure SHT75 temperature ***** 206 //***** Function to measure SHT75 temperature *****
207   207  
208 int16 sht_measuretemp (void) 208 int16 sht_measuretemp ()
209 { 209 {
210 int1 ack; 210 int1 ack;
211 int16 iobyte; 211 int16 iobyte;
212   212  
213 sht_comstart(); //alert SHT75 213 sht_comstart(); //alert SHT75
Line 219... Line 219...
219 } 219 }
220   220  
221   221  
222 //***** Function to measure SHT75 RH ***** 222 //***** Function to measure SHT75 RH *****
223   223  
224 int16 sht_measurehumid (void) 224 int16 sht_measurehumid ()
225 { 225 {
226 int1 ack; 226 int1 ack;
227 int16 iobyte; 227 int16 iobyte;
228   228  
229 sht_comstart(); //alert SHT75 229 sht_comstart(); //alert SHT75
Line 240... Line 240...
240 void calculate_data (int16 temp, int16 humid, float & tc, float & rhlin, float & rhtrue) 240 void calculate_data (int16 temp, int16 humid, float & tc, float & rhlin, float & rhtrue)
241 { 241 {
242 const float C1=-2.0468; // for 12 Bit RH 242 const float C1=-2.0468; // for 12 Bit RH
243 const float C2=+0.0367; // for 12 Bit RH 243 const float C2=+0.0367; // for 12 Bit RH
244 const float C3=-0.0000015955; // for 12 Bit RH 244 const float C3=-0.0000015955; // for 12 Bit RH
245 const float T1=+0.01; // for 12 Bit RH 245 // const float T1=+0.01; // for 12 Bit RH
246 const float T2=+0.00008; // for 12 Bit RH 246 // const float T2=+0.00008; // for 12 Bit RH
247 float rh; 247 float rh;
248   248  
249 //calculate temperature reading 249 //calculate temperature reading
250 tc = ((float) temp * 0.01) - 40.0; 250 tc = ((float) temp * 0.01) - 40.0;
251   251  
Line 283... Line 283...
283 sht_comreset(); //reset SHT75 283 sht_comreset(); //reset SHT75
284 delay_ms(20); //delay for power-up 284 delay_ms(20); //delay for power-up
285 } 285 }
286   286  
287 //-------------------------------------------------------------------- 287 //--------------------------------------------------------------------
288 float calc_dewpoint(float h,float t) 288 //float calc_dewpoint(float h,float t)
289 //-------------------------------------------------------------------- 289 //--------------------------------------------------------------------
290 // calculates dew point 290 // calculates dew point
291 // input: humidity [%RH], temperature [K] 291 // input: humidity [%RH], temperature [K]
292 // output: dew point [K] 292 // output: dew point [K]
293 { float k,dew_point ; 293 //{ float k,dew_point ;
294 294 //
295 k = (log10(h)-2)/0.4343 + (17.62*t)/(243.12+t); 295 // k = (log10(h)-2)/0.4343 + (17.62*t)/(243.12+t);
296 dew_point = 243.12*k/(17.62-k); 296 // dew_point = 243.12*k/(17.62-k);
297 return dew_point; 297 // return dew_point;
298 } 298 //}
299   299