Alex Allen / HIH4030
Committer:
AlexAllen
Date:
Sat Oct 13 11:47:12 2012 +0000
Revision:
0:eabb18deaf3f
Added licence

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AlexAllen 0:eabb18deaf3f 1 /* Copyright (c) 2011 Alex Allen, MIT License
AlexAllen 0:eabb18deaf3f 2 *
AlexAllen 0:eabb18deaf3f 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
AlexAllen 0:eabb18deaf3f 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
AlexAllen 0:eabb18deaf3f 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
AlexAllen 0:eabb18deaf3f 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
AlexAllen 0:eabb18deaf3f 7 * furnished to do so, subject to the following conditions:
AlexAllen 0:eabb18deaf3f 8 *
AlexAllen 0:eabb18deaf3f 9 * The above copyright notice and this permission notice shall be included in all copies or
AlexAllen 0:eabb18deaf3f 10 * substantial portions of the Software.
AlexAllen 0:eabb18deaf3f 11 *
AlexAllen 0:eabb18deaf3f 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
AlexAllen 0:eabb18deaf3f 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
AlexAllen 0:eabb18deaf3f 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
AlexAllen 0:eabb18deaf3f 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AlexAllen 0:eabb18deaf3f 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AlexAllen 0:eabb18deaf3f 17 */
AlexAllen 0:eabb18deaf3f 18
AlexAllen 0:eabb18deaf3f 19 #include "HIH4030.h"
AlexAllen 0:eabb18deaf3f 20 #include "mbed.h"
AlexAllen 0:eabb18deaf3f 21
AlexAllen 0:eabb18deaf3f 22 float HIH4030::getH(float temp)
AlexAllen 0:eabb18deaf3f 23 {
AlexAllen 0:eabb18deaf3f 24 float sensHum, trueHum;
AlexAllen 0:eabb18deaf3f 25 float vout = 3.3 * 2.0 * read();
AlexAllen 0:eabb18deaf3f 26 float vsupply = 5.0;
AlexAllen 0:eabb18deaf3f 27
AlexAllen 0:eabb18deaf3f 28 sensHum = ( ( vout / vsupply ) + 0.16 ) / 0.0062;
AlexAllen 0:eabb18deaf3f 29 trueHum = ( 1.0546 - 0.00216 * temp ) * sensHum;
AlexAllen 0:eabb18deaf3f 30
AlexAllen 0:eabb18deaf3f 31 return trueHum;
AlexAllen 0:eabb18deaf3f 32 }