library HTU21D results in float
Dependents: HTU21D_HELLOWORLD Major_dHome
Fork of HTU21D by
Revision 3:b2ef34462ac2, committed 2015-03-31
- Comitter:
- Guillaume31
- Date:
- Tue Mar 31 15:19:15 2015 +0000
- Parent:
- 2:4fd07be6bad8
- Commit message:
- Library for HTU21D (result in float)
Changed in this revision
HTU21D/HTU21D.cpp | Show annotated file Show diff for this revision Revisions of this file |
HTU21D/HTU21D.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 4fd07be6bad8 -r b2ef34462ac2 HTU21D/HTU21D.cpp --- a/HTU21D/HTU21D.cpp Sun Oct 19 19:27:19 2014 +0000 +++ b/HTU21D/HTU21D.cpp Tue Mar 31 15:19:15 2015 +0000 @@ -38,7 +38,7 @@ } -int HTU21D::sample_ctemp(void) { +float HTU21D::sample_ctemp(void) { char tx[1]; char rx[2]; @@ -58,27 +58,27 @@ float tempTemperature = rawTemperature / (float)65536; //2^16 = 65536 float realTemperature = -46.85 + (175.72 * tempTemperature); //From page 14 - return (int)realTemperature; + return (float)realTemperature; } -int HTU21D::sample_ftemp(void){ - int temptemp = sample_ctemp(); - int ftemp = temptemp * 1.8 + 32; +float HTU21D::sample_ftemp(void){ + float temptemp = sample_ctemp(); + float ftemp = temptemp * 1.8 + 32; return ftemp; } -int HTU21D::sample_ktemp(void){ - int temptemp = sample_ctemp(); - int ktemp = temptemp + 274; +float HTU21D::sample_ktemp(void){ + float temptemp = sample_ctemp(); + float ktemp = temptemp + 274; return ktemp; } -int HTU21D::sample_humid(void) { +float HTU21D::sample_humid(void) { char tx[1]; char rx[2]; @@ -102,7 +102,7 @@ float rh = -6 + (125 * tempRH); //From page 14 - return (int)rh; + return (float)rh; }
diff -r 4fd07be6bad8 -r b2ef34462ac2 HTU21D/HTU21D.h --- a/HTU21D/HTU21D.h Sun Oct 19 19:27:19 2014 +0000 +++ b/HTU21D/HTU21D.h Tue Mar 31 15:19:15 2015 +0000 @@ -63,16 +63,16 @@ //Samples the temperature, input void, outputs an int in celcius. - int sample_ctemp(void); + float sample_ctemp(void); //Samples the temperature, input void, outputs an int in fahrenheit. - int sample_ftemp(void); + float sample_ftemp(void); //Samples the temperature, input void, outputs an int in kelvin. - int sample_ktemp(void); + float sample_ktemp(void); //Samples the humidity, input void, outputs and int. - int sample_humid(void); + float sample_humid(void);