O Watch
Published © GPL3+

Pressure and Temperature Sensor

How to use the Barometric Pressure & Temperature Sensor (BMP280) on the O Watch.

IntermediateFull instructions provided15 minutes3,231
Pressure and Temperature Sensor

Things used in this project

Hardware components

O Watch Sensor Kit
O Watch Sensor Kit
×1

Story

Read more

Code

BMP280 Demo

Arduino
/***************************************************************************
  This is a demo of the BMP280 humidity, temperature & pressure sensor
  for the O Watch. http://theowatch.com 
  
  Made on products from http://tiny-circuits.com
  
  Derived from the BMP280 library  test program by Adafruit 
  ----> http://www.adafruit.com/products/2651

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing products
  from Adafruit!

  Original library and example written by Limor Fried & Kevin Townsend for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution

 ***************************************************************************/

#include <Adafruit_BMP280.h> //include the Adafruit BMP280 library
#include <TinyScreen.h> //required for all O Watch programs
#include <SPI.h> //required for interfacing with OLED screen
#include <Wire.h> //required for communicating with sensor board via I2C 

TinyScreen display = TinyScreen(TinyScreenPlus);

//Initialize the library using I2C 
Adafruit_BMP280 bme; // I2C is the interface used in TinyScreen+ for all sensors
  
void setup() 
{
  display.begin();
  display.setBrightness(8);
  display.setFlip(1);
  display.setCursor(5,5);
  display.setFont(liberationSans_8ptFontInfo);
  display.fontColor(TS_8b_White,TS_8b_Black);
  if (!bme.begin()) //check if you are able to read the sensor
  {  
    display.print("Not valid BMP280");
    while (1);
  }
}
  
void loop() {
    display.setCursor(5,5);
    display.print("Temp = ");
    //call library function to reach temp value and converting it to farenheit
    display.print((bme.readTemperature()*9/5+32-13)); 
    display.print(" *F");
    display.setCursor(5,25);
    display.print("Pr = ");
    //call library function to reach pressure value
    display.print(bme.readPressure()/3389.39); 
    display.print(" inHg.");
    display.setCursor(5,45);
    display.print("Alt = ");
    //call library function to calculate altitude from pressure
    display.print(bme.readAltitude(1020.8)); // this should be adjusted to your local forcase
    display.print(" m  ");
    delay(2000);
    display.clearWindow(0,0,96,64);
}

Adafruit BMP280 Library

Credits

O Watch

O Watch

9 projects • 15 followers
Make your own smartwatch. Learn 3D design and Arduino coding.

Comments