Pressure sensor + Oled display SSD1306 32*128
Dependencies: mbed Adafruit_GFX BMP180
Revision 0:a1bf4bcd163a, committed 2019-10-09
- Comitter:
- Taraskin
- Date:
- Wed Oct 09 21:30:55 2019 +0000
- Commit message:
- BMP180 + SSD1306 32*128
Changed in this revision
diff -r 000000000000 -r a1bf4bcd163a Adafruit_GFX.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adafruit_GFX.lib Wed Oct 09 21:30:55 2019 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/kaizen/code/Adafruit_GFX/#3112550cc6a3
diff -r 000000000000 -r a1bf4bcd163a BMP180.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BMP180.lib Wed Oct 09 21:30:55 2019 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/kgills/code/BMP180/#b2219e6e444b
diff -r 000000000000 -r a1bf4bcd163a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 09 21:30:55 2019 +0000 @@ -0,0 +1,46 @@ +#include "mbed.h" +#include "Adafruit_SSD1306.h" +#include "BMP180.h" + +DigitalOut myled_R(LED1); + +I2C i2c(PB_9, PB_8); // SDA, SCL arduino pins + +Adafruit_SSD1306_I2c myOled(i2c,NC,0x78,32,128); +BMP180 bmp180(&i2c); + +int main(void) { + + while(1) { + if (bmp180.init() != 0) { + printf("Error communicating with BMP180\n"); + } else { + printf("Initialized BMP180\n"); + break; + } + wait(1); + } + + while(1) { + bmp180.startTemperature(); + wait_ms(5); // Wait for conversion to complete. + float temp; + if(bmp180.getTemperature(&temp) != 0) { + printf("Error getting temperature\n"); + continue; + } + + bmp180.startPressure(BMP180::ULTRA_LOW_POWER); + wait_ms(10); // Wait for conversion to complete + int pressure; + if(bmp180.getPressure(&pressure) != 0) { + printf("Error getting pressure\n"); + continue; + } + + myOled.printf("Temp= %f\r", temp); + myOled.display(); + wait(0.01); + + } +} \ No newline at end of file
diff -r 000000000000 -r a1bf4bcd163a mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Oct 09 21:30:55 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file