Simple temperature and humidity program example for Hexiwear featuring UART

Fork of HTU21D by Alex Lipford

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



File content as of revision 3:caccf1879f14:

 * @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):
 * <> 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
 * Honeywell HTU21D Humidity and Temperature sensor.
 * Datasheet, specs, and information:

#ifndef HTU21D_H
#define HTU21D_H

 * Includes
#include "mbed.h"

 * Defines
// Acquired from Datasheet.

#define HTU21D_I2C_ADDRESS  0x40 

#define HTU21D_EEPROM_WRITE 0x80
#define HTU21D_EEPROM_READ  0x81

 * Honeywell HTU21D digital humidity and temperature sensor.
class HTU21D {


     * Constructor.
     * @param sda mbed pin to use for SDA line of I2C interface.
     * @param scl mbed pin to use for SCL line of I2C interface.
    HTU21D(PinName sda, PinName scl);

    //Samples the temperature, input void, outputs an int in celcius.
    int sample_ctemp(void);
       //Samples the temperature, input void, outputs an int in fahrenheit.
    int sample_ftemp(void);
       //Samples the temperature, input void, outputs an int in kelvin.
    int sample_ktemp(void);
    //Samples the humidity, input void, outputs and int.
    int sample_humid(void);



    I2C* i2c_;

     * Write to EEPROM or RAM on the device.
     * @param EepromOrRam 0x80 -> Writing to EEPROM
     * @param address Address to write to.
     * @param data Data to write.
    void write(int EepromOrRam, int address, int data);

     * Read EEPROM or RAM on the device.
     * @param EepromOrRam 0x81 -> Reading from EEPROM
     * @param address Address to read from.
     * @return The contents of the memory address.
    int read(int EepromOrRam, int address);


#endif /* HTU21D_H */