yasuyuki onodera / Mbed 2 deprecated mbed_HDC1000

Dependencies:   AQM0802 HDC1000 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 //**********************
00002 // Hygrometer and Thermometer for mbed
00003 //
00004 // LPC1768 flash=512KB, ADC=12bits
00005 // LPC11U35 flash=64KB, ADC=10bits
00006 // Nucleo ADC=12bits
00007 //
00008 // (C)Copyright 2015 All rights reserved by Y.Onodera
00009 // http://einstlab.web.fc2.com
00010 //**********************
00011 #include "mbed.h"
00012 #include "AQM0802.h"
00013 #include "HDC1000.h"
00014 
00015 #if defined(TARGET_LPC1768)
00016 I2C i2c(p28,p27);
00017 #endif
00018 // for TG-LPC11U35-501
00019 #if defined(TARGET_LPC11U35_501)
00020 I2C i2c(P0_5,P0_4);
00021 #endif
00022 // for Nucleo
00023 #if defined(TARGET_NUCLEO_F401RE)
00024 I2C i2c(D14,D15);
00025 #endif
00026 
00027 AQM0802 lcd(i2c);
00028 HDC1000 hdc1000(i2c);
00029 
00030 int main() {
00031     
00032     char msg[10];
00033     float h;
00034     float t;
00035       
00036     while(1) {
00037 
00038         h = hdc1000.humidity();
00039         h = h/0x10000*100;
00040         sprintf(msg,"%4.1f%% ",h);
00041         lcd.locate(0,0);
00042         lcd.print(msg);
00043 
00044         t = hdc1000.temperature();
00045         t = t/0x10000*165-40;
00046         sprintf(msg,"%4.1fC ",t);
00047         lcd.locate(0,1);
00048         lcd.print(msg);
00049 
00050         wait(1);
00051     }
00052 
00053 }