HTU21D-F with board Nucleo_F411RE results in float

Dependencies:   HTU21D mbed MD25 TextLCD

Fork of HTU21D-F_Nucleo_F411RE by Guillaume GARBAY

Committer:
Guillaume31
Date:
Tue Mar 31 15:21:09 2015 +0000
Revision:
2:c00e194f9ed5
Parent:
1:cfb1e959c32a
Child:
3:56643150d07d
results in float

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alipford3 0:8c0ef32974f0 1 /** Sample program to read temperature and humidity
alipford3 0:8c0ef32974f0 2 *
alipford3 0:8c0ef32974f0 3 * @author Alex Lipford
alipford3 0:8c0ef32974f0 4 * Georgia Institute of Technology
alipford3 0:8c0ef32974f0 5 * ECE 4180 Embeded Systems Design
alipford3 0:8c0ef32974f0 6 * Professor Hamblen
alipford3 0:8c0ef32974f0 7 * 10/19/2014
alipford3 0:8c0ef32974f0 8 *
alipford3 0:8c0ef32974f0 9 * @section LICENSE
alipford3 0:8c0ef32974f0 10 * ----------------------------------------------------------------------------
alipford3 0:8c0ef32974f0 11 * "THE BEER-WARE LICENSE" (Revision 42):
alipford3 0:8c0ef32974f0 12 * <alexlipford@gmail.com> wrote this file. As long as you retain this notice you
alipford3 0:8c0ef32974f0 13 * can do whatever you want with this stuff. If we meet some day, and you think
alipford3 0:8c0ef32974f0 14 * this stuff is worth it, you can buy me a beer in return.
alipford3 0:8c0ef32974f0 15 * ----------------------------------------------------------------------------
alipford3 0:8c0ef32974f0 16 *
alipford3 0:8c0ef32974f0 17 *
alipford3 0:8c0ef32974f0 18 * @section DESCRIPTION
alipford3 0:8c0ef32974f0 19 *
alipford3 0:8c0ef32974f0 20 * Honeywell HTU21D Humidity and Temperature sensor.
alipford3 0:8c0ef32974f0 21 *
alipford3 0:8c0ef32974f0 22 * Datasheet, specs, and information:
alipford3 0:8c0ef32974f0 23 *
alipford3 0:8c0ef32974f0 24 * https://www.sparkfun.com/products/12064
alipford3 0:8c0ef32974f0 25 */
alipford3 0:8c0ef32974f0 26
alipford3 0:8c0ef32974f0 27 #include "mbed.h"
alipford3 0:8c0ef32974f0 28 #include "HTU21D.h"
alipford3 0:8c0ef32974f0 29
Guillaume31 1:cfb1e959c32a 30 HTU21D temphumid(D14, D15); //Temp humid sensor || SDA, SCL
Guillaume31 2:c00e194f9ed5 31 float sample_ftemp;
Guillaume31 2:c00e194f9ed5 32 float sample_ctemp;
Guillaume31 2:c00e194f9ed5 33 float sample_ktemp;
Guillaume31 2:c00e194f9ed5 34 float sample_humid;
alipford3 0:8c0ef32974f0 35
alipford3 0:8c0ef32974f0 36 int main() {
alipford3 0:8c0ef32974f0 37 while(1) {
alipford3 0:8c0ef32974f0 38 sample_ftemp = temphumid.sample_ftemp();
alipford3 0:8c0ef32974f0 39 sample_ctemp = temphumid.sample_ctemp();
alipford3 0:8c0ef32974f0 40 sample_ktemp = temphumid.sample_ktemp();
alipford3 0:8c0ef32974f0 41 sample_humid = temphumid.sample_humid();
Guillaume31 2:c00e194f9ed5 42 printf("Temperature: %.2f F\n\r", sample_ftemp);
Guillaume31 2:c00e194f9ed5 43 printf("Temperature: %.2f C\n\r", sample_ctemp);
Guillaume31 2:c00e194f9ed5 44 printf("Temperature: %.2f K\n\r", sample_ktemp);
Guillaume31 2:c00e194f9ed5 45 printf("Humidity: %.2f %%\n\r", sample_humid);
alipford3 0:8c0ef32974f0 46 printf("\n\r");
Guillaume31 1:cfb1e959c32a 47 wait(5);
alipford3 0:8c0ef32974f0 48 }
alipford3 0:8c0ef32974f0 49 }