LinkNode_BMP180 by derron
Dependencies: BLE_API BMP180 mbed nRF51822
Fork of LinkNode_BMP180 by
main.cpp
00001 #include <stdio.h> 00002 #include "mbed.h" 00003 #include "BMP180.h" 00004 00005 Serial pc(P0_23,P0_25); 00006 DigitalOut led(P0_20); 00007 I2C i2c(P0_17, P0_18); 00008 BMP180 bmp180(&i2c); 00009 00010 int main(void) 00011 { 00012 led=0; 00013 while(1) 00014 { 00015 if (bmp180.init() != 0) 00016 { 00017 printf("Error communicating with BMP180\n"); 00018 wait(1); 00019 } 00020 else 00021 { 00022 printf("Initialized BMP180\n"); 00023 break; 00024 } 00025 wait(1); 00026 } 00027 00028 while(1) 00029 { 00030 bmp180.startTemperature(); 00031 wait_ms(5); // Wait for conversion to complete 00032 float temp; 00033 if(bmp180.getTemperature(&temp) != 0) 00034 { 00035 printf("Error getting temperature\n"); 00036 continue; 00037 } 00038 bmp180.startPressure(BMP180::ULTRA_LOW_POWER); 00039 wait_ms(10); // Wait for conversion to complete 00040 int pressure; 00041 if(bmp180.getPressure(&pressure) != 0) 00042 { 00043 printf("Error getting pressure\n"); 00044 continue; 00045 } 00046 00047 printf("Pressure = %d Pa Temperature = %f C\n", pressure, temp); 00048 wait(1); 00049 } 00050 }
Generated on Sat Aug 13 2022 11:25:19 by 1.7.2