Wemos and BMP180 readings on an OLED display simple project

In this particular example we are going to simply display temperature. pressure and altitude readings from a BMP180 sensor on an OLED display. These are all the shields used in making this a simple project to build.

Requirements

1 x Wemos Mini
1 x Wemos Dual Base
1 x OLED Shield
1 x BMP180 Shield (not an official Wemos Shield)

You can see what I assembled in the picture below, I could have stacked in one column but I wanted to see the OLED and also leave the BMP180 uncovered.

 

Code

There are 2 libraries required – you can install these via the library manager, here are links to them

https://github.com/adafruit/Adafruit-BMP085-Library
https://github.com/sparkfun/SparkFun_Micro_OLED_Arduino_Library

[codesyntax lang=”cpp”]

#include <Wire.h>
#include <Adafruit_BMP085.h>
#include <SFE_MicroOLED.h>  // Include the SFE_MicroOLED library
#define PIN_RESET 255  //
#define DC_JUMPER 0  // I2C Addres: 0 - 0x3C, 1 - 0x3D

MicroOLED oled(PIN_RESET, DC_JUMPER); // Example I2C declaration
Adafruit_BMP085 bmp;

void setup() 
{
  Serial.begin(9600);
  if (!bmp.begin()) {
  Serial.println("Could not find a valid BMP180 sensor, check wiring!");
  while (1) {}
  }
  oled.begin();
  oled.clear(ALL);  // Clear the display's memory (gets rid of artifacts)
  oled.display();  
}

void loop() 
{
  // Wait a few seconds between measurements.
  delay(2000);


  oled.clear(PAGE); 
  oled.setFontType(0); // set font type 0, please see declaration in SFE_MicroOLED.cpp
  oled.setCursor(1, 3);
  oled.print("Pressure = ");
  oled.setCursor(1, 12);
  oled.print(bmp.readPressure());
  oled.print(" Pa");
  oled.setCursor(1, 21);
  oled.print("Temp =");
  oled.setCursor(1, 30);
  oled.print(bmp.readTemperature());
  oled.print(" *C ");
  oled.display();  
  delay(2000);
  //2nd page of readings
  oled.clear(PAGE); 
  oled.setFontType(0); // set font type 0, please see declaration in SFE_MicroOLED.cpp
  oled.setCursor(1, 3);
  oled.print("Altitude = ");
  oled.setCursor(1, 12);
  oled.print(bmp.readAltitude());
  oled.print(" m");
  oled.setCursor(1, 21);
  oled.print("Sea Level=");
  oled.setCursor(1, 30);
  oled.print(bmp.readSealevelPressure());
  oled.print(" Pa");
  oled.display();  
}

[/codesyntax]

Output

I split the readings into 2, the first readings are displayed for 2 seconds. Here you can see the output

 

 

 

 

Links

You can get all the boards and shields for about $10

Mini NodeMcu 4M bytes Lua WIFI Internet of Things development board based ESP8266 by WeMos

Double Socket Dual Base Shield for WeMos D1 Mini NodeMCU ESP8266 Diy PCB D1 Expansion board

64X48 IIC I2C LCD OLED LED Dispaly Shield for Arduino Compatible WeMos D1 Mini

BMP180 Replace BMP085 Digital Barometric Pressure Sensor Module FOR WeMos D1 mini

LEAVE A REPLY

Please enter your comment!
Please enter your name here