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.
Diff: BMP180Wrapper.cpp
- Revision:
- 1:02f543f15108
- Child:
- 2:e28e685938f1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/BMP180Wrapper.cpp Tue May 26 17:33:13 2020 +0000
@@ -0,0 +1,58 @@
+/**
+ * Bosch BMP180 Digital Pressure Sensor
+ */
+
+#include <BMP180Wrapper.h>
+
+BMP180Wrapper::BMP180Wrapper( DevI2C* i2c ) : bmp180(i2c)
+{
+}
+
+int BMP180Wrapper::init( void* init )
+{
+ while ( 1 )
+ {
+ if ( bmp180.init() != 0 )
+ {
+ printf( "Error communicating with BMP180\n" );
+ }
+ else
+ {
+ printf( "Initialized BMP180\n" );
+ break;
+ }
+ wait( 1 );
+ }
+ return ( 0 );
+}
+
+int BMP180Wrapper::read_id( uint8_t* id )
+{
+ *id = 0x55;
+ return ( 0 );
+}
+
+int BMP180Wrapper::get_humidity( float* pfData )
+{
+ *pfData = 0.0f;
+ bmp180.startPressure(BMP180::ULTRA_LOW_POWER);
+ wait_ms(10); // Wait for conversion to complete
+ int pressure;
+ if(bmp180.getPressure(&pressure) == 0)
+ {
+ *pfData = pressure / 1000.0f;
+ }
+ return ( 0 );
+}
+
+int BMP180Wrapper::get_temperature( float* pfData )
+{
+ bmp180.startTemperature();
+ wait_ms( 5 ); // Wait for conversion to complete
+ return ( bmp180.getTemperature( pfData ) );
+}
+
+int BMP180Wrapper::enable( void )
+{
+ return ( 0 );
+}