Code du capteur de température et d'humidité (Adam Wronski et Nassim Deleau)

Dependencies:   mbed HTU21D

Committer:
Adam06
Date:
Sun Apr 14 15:59:50 2019 +0000
Revision:
2:d2e0704b0c51
Parent:
1:cfb1e959c32a
Code du capteur d'humidite et de temperature

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
Adam06 2:d2e0704b0c51 30 HTU21D temphumid(PB_14, PB_13); //Temp humid sensor || SDA, SCL
alipford3 0:8c0ef32974f0 31 int sample_ftemp;
alipford3 0:8c0ef32974f0 32 int sample_ctemp;
alipford3 0:8c0ef32974f0 33 int sample_ktemp;
alipford3 0:8c0ef32974f0 34 int 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();
alipford3 0:8c0ef32974f0 42 printf("Temperature: %d F\n\r", sample_ftemp);
alipford3 0:8c0ef32974f0 43 printf("Temperature: %d C\n\r", sample_ctemp);
alipford3 0:8c0ef32974f0 44 printf("Temperature: %d K\n\r", sample_ktemp);
alipford3 0:8c0ef32974f0 45 printf("Humidity: %d %%\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 }