Skip to content

Barometric Pressure Sensor TinyShield Tutorial

This sensor is a must-have in any DIY weather station or project that needs to consider weather measurements as an input.

To learn more about the TinyDuino Platform, click here


Description

The Barometric Pressure TinyShield allows you to measure barometric pressure (and determine altitude) and temperature with your TinyDuino. Based around the Bosch BMP280 sensor, this allows you to measure barometric pressure with a +/- 1hPa absolute accuracy, and temperature with a +/- 1.0C accuracy. This is great for weather applications or accurate altitude measurements in projects such as small drones and rockets.

This TinyShield uses I2C communication and incorporates level shifters and a local power supply to ensure proper and safe operation over the entire TinyDuino operating voltage range up to 5V.

To see what other TinyShields are compatible with this TinyShield, see the TinyShield Compatibility Matrix

Technical Details Bosch BMP280 Barometric Pressure Sensor Specs
  • Pressure Range: 300 -> 1100 hPa (equiv to +9000 to -500m above/below sea level)
  • Relative Accuracy: +/- 0.12 hPa, equiv to +/- 1m
  • Absolute Accuracy: +/- 1 hPa
  • Absolute Accuracy Temperature: +/- 1.0C
TinyDuino Power Requirements
  • Voltage: 3.0V - 5.5V
  • Current: 139uA (Normal Mode). Due to the low current, this board can be run using the TinyDuino coin cell option.
Pins Used
  • A5/SCL - I2C Serial Clock line
  • A4/SDA - I2C Serial Data line
Dimensions
  • 20mm x 20mm (.787 inches x .787 inches)
  • Max Height (from lower bottom TinyShield Connector to upper top TinyShield Connector): 5.11mm (0.201 inches)
  • Weight: 1 gram (.04 ounces)

Notes

  • You can also use this shield without the TinyDuino – there are 0.1" spaced connections for power, ground, and the two I2C signals along the side of the TinyShield to allow you to connect a different system.

  • Warning: Revision 4 boards have a mistake on the silkscreen, the pin marked VCC is actually SCL, the pin marked SCL is actually SDA, and the pin marked SDA is actually VCC. If you connect this up the way it is marked you will not damage the board.


Materials

A TinyZero Processor Board, and a Barometric Pressure Sensor TinyShield

Hardware

Software


Assembly (Hardware)

On top of your processor board of choice (i.e. TinyZero), stack your Barometric Pressure Sensor TinyShield. Connect your TinyDuino stack to your computer using the microUSB cable. Make sure the processor is switched on.

An assembled stack of a TinyZero, and Barometric Pressure Sensor TinyShield.


Software (Setup and Downloads)

First, open the Arduino IDE (You should already have the IDE installed if you've gone through a setup tutorial for a processor board.) Then, click the following link to download the example program zip file Barometric Pressure Sensor TinyShield Arduino Sketch. This file has the required library zipped with it, so there are no additional files to download.


The Code

Code
/*
  TinyDuino Barometric Pressure Demo

  This example code is in the public domain.

  Written 
  By 
  Modified 07 January 2019
  By Hunter Hykes

  https://TinyCircuits.com
*/

#include "BMP280.h"
#include "Wire.h"
#define P0 1013.25
BMP280 bmp;
void setup()
{
  Serial.begin(9600);
  if(!bmp.begin()){
    Serial.println("BMP init failed!");
    while(1);
  }
  else Serial.println("BMP init success!");

  bmp.setOversampling(4);

}
void loop()
{
  double T,P;
  char result = bmp.startMeasurment();

  if(result!=0){
    delay(result);
    result = bmp.getTemperatureAndPressure(T,P);

      if(result!=0)
      {
        double A = bmp.altitude(P,P0);

        Serial.print("T = \t");Serial.print(T,2); Serial.print(" degC\t");
        Serial.print("P = \t");Serial.print(P,2); Serial.print(" mBar\t");
        Serial.print("A = \t");Serial.print(A,2); Serial.println(" m");

      }
      else {
        Serial.println("Error.");
      }
  }
  else {
    Serial.println("Error.");
  }

  delay(100);
}

Upload the program using the Tools selections:

Tools selections for TinyZero (Your COM# will probably be different)

Once the upload is complete, open up the Serial Monitor (Ctrl+Shift+M) at 9600 baud and you'll be able to observe the data gathered by the sensor!

Data from the Barometric Pressure Sensor TinyShield here at TinyCircuits.


Downloads


Contact Us

If you have any questions or feedback, feel free to email us or make a post on our forum. Show us what you make by tagging @TinyCircuits on Instagram, Twitter, or Facebook so we can feature it.

Thanks for making with us!