Library for the Sensirion SHT3X-ARP Analog Humidity & Temperature Sensor.

Dependents:   STM32_teste_5

Fork of SHT3XA by ClosedCube Limited

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SHT3XA.cpp Source File

SHT3XA.cpp

00001 /*
00002   Copyright (c) 2015 ClosedCube Limited
00003 
00004   Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00005   and associated documentation files (the "Software"), to deal in the Software without restriction,
00006   including without limitation the rights to use, copy, modify, merge, publish, distribute,
00007   sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00008   furnished to do so, subject to the following conditions:
00009 
00010   The above copyright notice and this permission notice shall be included in all copies or
00011   substantial portions of the Software.
00012 
00013   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00014   BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00015   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00016   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00017   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018  */
00019 
00020 #include "SHT3XA.h"
00021 
00022 #define SHT3XA_RH_FORMULA(x)     -12.5f+125.0f*x
00023 #define SHT3XA_TEMPC_FORMULA(x)  -66.875f+218.75f*x
00024 #define SHT3XA_TEMPF_FORMULA(x)  -88.375f+393.75f*x
00025 
00026 SHT3XA::SHT3XA(PinName pinRH,PinName pinT) : _pinRH(pinRH),_pinT(pinT)
00027 {
00028 }
00029 
00030 float SHT3XA::readRH()
00031 {
00032     return SHT3XA_RH_FORMULA(_pinRH.read());
00033 }
00034 
00035 float SHT3XA::readTempC()
00036 {
00037     return SHT3XA_TEMPC_FORMULA(_pinT.read());
00038 }
00039 
00040 float SHT3XA::readTempF()
00041 {
00042     return SHT3XA_TEMPF_FORMULA(_pinT.read());
00043 }
00044