Measure Surrounding Air Pressure Using Grove Beginner Kit

Do you know what is the pressure or altitude of your surrounding?

Introduction

Grove Air Pressure Sensor(BMP280) is a breakout board for Bosch BMP280 high-precision and low-power digital barometer. This module can be used to measure temperature and atmospheric pressure accurately. As the atmospheric pressure changes with altitude, it can also measure the approximate altitude of a place.

Video

This video shows how to measure surrounding air pressure using Grove Beginner Kit.

Hardware Preparation

This is the list of items used in the video.

Sample Program

This is the sample code for this tutorial using Arduino IDE.

#include "Seeed_BMP280.h"
#include <Wire.h>
#include <Arduino.h>
#include <U8x8lib.h>
U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);
BMP280 bmp280;
void setup() {
Serial.begin(9600);
u8x8.setBusClock(100000); // If you breakout other modules, please enable this line
u8x8.begin();
u8x8.setPowerSave(0);
u8x8.setFlipMode(1);
if (!bmp280.init()) {
Serial.println("Device not connected or broken!");
}
}
void loop() {
float pressure;
u8x8.setFont(u8x8_font_chroma48medium8_r);
u8x8.setCursor(0, 0);
u8x8.print("P:");
u8x8.print(pressure = bmp280.getPressure());
u8x8.print("Pa");
u8x8.setCursor(0, 30);
u8x8.print("A:");
u8x8.print(bmp280.calcAltitude(pressure));
u8x8.print("m");
u8x8.refreshDisplay();
delay(200);
//float pressure;
//get and print temperatures
Serial.print("Temp: ");
Serial.print(bmp280.getTemperature());
Serial.println("C"); // The unit for Celsius because original arduino don't support speical symbols
//get and print atmospheric pressure data
Serial.print("Pressure: ");
Serial.print(pressure = bmp280.getPressure());
Serial.println("Pa");
//get and print altitude data
Serial.print("Altitude: ");
Serial.print(bmp280.calcAltitude(pressure));
Serial.println("m");
Serial.println("\n");//add a line between output of different times.
delay(1000);
}

view raw
Barometer_grove.ino
hosted with ❤ by GitHub

Thank You

References:

Thanks for reading this tutorial. If you have any technical inquiries, please post at Cytron Technical Forum.

Please be reminded, this tutorial is prepared for you to try and learn.
You are encouraged to improve the code for better application.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Program micro:bit V2 Using MicroPython On Raspberry Pi
Basic Comparison Between MicroPython and Arduino
The Octolapse V0.4.1 With Raspberry Pi Camera
Getting Started With Node-RED Using Raspberry Pi
How Raspberry Pi Has Changed the World
Scroll to Top