Simple temperature and humidity program example for Hexiwear featuring UART
Fork of HTU21D by
This project demonstrates the use of the HTU21D temperature and humidity sensor embedded in Hexiwear
Open a Hyperterminal tool on your computer and connect it to the "mbed Serial port (COMxx)" with Baud rate "9600bps"
Compile the project and copy the binary "Hexi_Humid_Temp_Example_HEXIWEAR.bin" in the DAP-LINK drive from your computer file explorer Press the K64F-RESET button on the docking station to start the program on your board
Every 500ms the value of the Temperature and Humidity will be displayed in the Hyperterminal window and the LED will blink Green
Diff: HTU21D/HTU21D.cpp
- Revision:
- 3:caccf1879f14
- Parent:
- 2:4fd07be6bad8
diff -r 4fd07be6bad8 -r caccf1879f14 HTU21D/HTU21D.cpp --- a/HTU21D/HTU21D.cpp Sun Oct 19 19:27:19 2014 +0000 +++ b/HTU21D/HTU21D.cpp Mon Oct 17 03:03:07 2016 +0000 @@ -1,31 +1,23 @@ -/** - * @author Alex Lipford - * Georgia Institute of Technology - * ECE 4180 Embeded Systems Design - * Professor Hamblen - * 10/19/2014 - * - * @section LICENSE - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * <alexlipford@gmail.com> wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. - * ---------------------------------------------------------------------------- - * - * - * @section DESCRIPTION - * - * HTU21D Humidity and Temperature sensor. - * - * Datasheet, specs, and information: - * - * https://www.sparkfun.com/products/12064 - */ +// @author Alex Lipford +// Georgia Institute of Technology +// ECE 4180 Embeded Systems Design +// Professor Hamblen +// 10/19/2014 + +// @section LICENSE +// ---------------------------------------------------------------------------- +// "THE BEER-WARE LICENSE" (Revision 42): +// <alexlipford@gmail.com> wrote this file. As long as you retain this notice you +// can do whatever you want with this stuff. If we meet some day, and you think +// this stuff is worth it, you can buy me a beer in return. +// ---------------------------------------------------------------------------- -/** - * Includes - */ +// @section DESCRIPTION +// HTU21D Humidity and Temperature sensor. +// Datasheet, specs, and information: +// https://www.sparkfun.com/products/12064 + + #include "HTU21D.h" HTU21D::HTU21D(PinName sda, PinName scl) { @@ -33,9 +25,6 @@ i2c_ = new I2C(sda, scl); //400KHz, as specified by the datasheet. i2c_->frequency(400000); - - - } int HTU21D::sample_ctemp(void) { @@ -59,7 +48,6 @@ float realTemperature = -46.85 + (175.72 * tempTemperature); //From page 14 return (int)realTemperature; - } int HTU21D::sample_ftemp(void){ @@ -74,8 +62,6 @@ int ktemp = temptemp + 274; return ktemp; - - } int HTU21D::sample_humid(void) { @@ -101,8 +87,6 @@ float tempRH = rawHumidity / (float)65536; //2^16 = 65536 float rh = -6 + (125 * tempRH); //From page 14 - return (int)rh; - }