
A sample program to read the temperature and humidity from the HTU21D sensor.
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /** Sample program to read temperature and humidity 00002 * 00003 * @author Alex Lipford 00004 * Georgia Institute of Technology 00005 * ECE 4180 Embeded Systems Design 00006 * Professor Hamblen 00007 * 10/19/2014 00008 * 00009 * @section LICENSE 00010 * ---------------------------------------------------------------------------- 00011 * "THE BEER-WARE LICENSE" (Revision 42): 00012 * <alexlipford@gmail.com> wrote this file. As long as you retain this notice you 00013 * can do whatever you want with this stuff. If we meet some day, and you think 00014 * this stuff is worth it, you can buy me a beer in return. 00015 * ---------------------------------------------------------------------------- 00016 * 00017 * 00018 * @section DESCRIPTION 00019 * 00020 * Honeywell HTU21D Humidity and Temperature sensor. 00021 * 00022 * Datasheet, specs, and information: 00023 * 00024 * https://www.sparkfun.com/products/12064 00025 */ 00026 00027 #include "mbed.h" 00028 #include "HTU21D.h" 00029 00030 HTU21D temphumid(p9, p10); //Temp humid sensor || SDA, SCL 00031 int sample_ftemp; 00032 int sample_ctemp; 00033 int sample_ktemp; 00034 int sample_humid; 00035 00036 int main() { 00037 while(1) { 00038 sample_ftemp = temphumid.sample_ftemp(); 00039 sample_ctemp = temphumid.sample_ctemp(); 00040 sample_ktemp = temphumid.sample_ktemp(); 00041 sample_humid = temphumid.sample_humid(); 00042 printf("Temperature: %d F\n\r", sample_ftemp); 00043 printf("Temperature: %d C\n\r", sample_ctemp); 00044 printf("Temperature: %d K\n\r", sample_ktemp); 00045 printf("Humidity: %d %%\n\r", sample_humid); 00046 printf("\n\r"); 00047 } 00048 }
Generated on Fri Jul 15 2022 03:59:41 by
