Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
PeMod_BMP180.cpp
00001 #include "SysConfig.h" 00002 00003 #define BMP180_ADDR (0x40<<1) //BMP180 address 00004 #define BMP180_CMD_TMP_NH (0xF3) //Non-hold temp trigger command 00005 #define BMP180_CMD_RH_NH (0xF5) //Non-hold temp trigger command 00006 00007 #define i2c_bmp180 i2c_sen 00008 //#define uart_db uart_pc 00009 00010 int BMP180_Init(void) 00011 { 00012 return 0; 00013 } 00014 00015 float BMP180_ReadTemp(void) 00016 { 00017 char cmd = BMP180_CMD_TMP_NH, data[3]; 00018 float temp; 00019 00020 i2c_bmp180.write(BMP180_ADDR, &cmd, 1, 1); 00021 wait_us(20); 00022 i2c_bmp180.stop(); 00023 00024 wait_ms(100); 00025 i2c_bmp180.read(BMP180_ADDR, data, 3); 00026 #if defined uart_db 00027 uart_db.printf("\n\rBMP180 return 0x%02X 0x%02X 0x%02X\n\r", data[0], data[1], data[2]); 00028 #endif 00029 temp = (256.0 * data[0] + data[1]) * 175.72 / (0x1 << 16) - 46.85; 00030 return temp; 00031 } 00032 00033 float BMP180_ReadRh(void) 00034 { 00035 char cmd = BMP180_CMD_RH_NH, data[3]; 00036 float rh; 00037 00038 i2c_bmp180.write(BMP180_ADDR, &cmd, 1, 1); 00039 wait_us(20); 00040 i2c_bmp180.stop(); 00041 00042 wait_ms(100); 00043 i2c_bmp180.read(BMP180_ADDR, data, 3); 00044 #if defined uart_db 00045 uart_db.printf("\n\rBMP180 return 0x%02X 0x%02X 0x%02X\n\r", data[0], data[1], data[2]); 00046 #endif 00047 rh = (256.0 * data[0] + data[1]) * 125 / (0x1 << 16) - 6; 00048 return rh; 00049 }
Generated on Fri Jul 15 2022 14:37:21 by
1.7.2