Arduino Test | Adafruit BME280 Humidity + Barometric Pressure + ...
Maybe your like
- Overview
- Pinouts
- Assembly
- Arduino Test
- Python & CircuitPython Test
- Python Docs
- WipperSnapper
- F.A.Q.
- Downloads
- Single page
- Feedback? Corrections?
- Text View
-
Adafruit BME280 I2C or SPI Temperature Humidity Pressure Sensor Out of Stock
Arduino Test
You can easily wire this breakout to any microcontroller, we'll be using an Arduino. For another kind of microcontroller, as long as you have 4 available pins it is possible to 'bit-bang SPI' or you can use two I2C pins, but usually those pins are fixed in hardware. Just check out the library, then port the code.
I2C WiringUse this wiring if you want to connect via I2C interface
- Connect Vin to the power supply, 3-5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
- Connect GND to common power/data ground
- Connect the SCK pin to the I2C clock SCL pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A5, on a Mega it is also known as digital 21 and on a Leonardo/Micro, digital 3
- Connect the SDI pin to the I2C data SDA pin on your Arduino. On an UNO & '328 based Arduino, this is also known as A4, on a Mega it is also known as digital 20 and on a Leonardo/Micro, digital 2
By default, the i2c address is 0x77. If you add a jumper from SDO to GND, the address will change to 0x76.
In you are having intermittent issues with I2C on the original non-STEMMA version of the board, try also jumpering CS to Vin.
SPI WiringSince this is a SPI-capable sensor, we can use hardware or 'software' SPI. To make wiring identical on all Arduinos, we'll begin with 'software' SPI. The following pins should be used:
- Connect Vin to the power supply, 3V or 5V is fine. Use the same voltage that the microcontroller logic is based off of. For most Arduinos, that is 5V
- Connect GND to common power/data ground
- Connect the SCK pin to Digital #13 but any pin can be used later
- Connect the SDO pin to Digital #12 but any pin can be used later
- Connect the SDI pin to Digital #11 but any pin can be used later
- Connect the CS pin Digital #10 but any pin can be used later
Later on, once we get it working, we can adjust the library to use hardware SPI if you desire, or change the pins to other
Install Adafruit_BME280 libraryTo begin reading sensor data, you will need to install the Adafruit_BME280 library (code on our github repository). It is available from the Arduino library manager so we recommend using that.
From the IDE open up the library manager...
And type in adafruit bme280 to locate the library. Click Install
Also add the Adafruit Unified Sensor library
We also have a great tutorial on Arduino library installation at:http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use
Load DemoOpen up File->Examples->Adafruit_BME280->bmp280test and upload to your Arduino wired up to the sensor
Depending on whether you are using I2C or SPI, change the pin names and comment or uncomment the following lines.
Download File Copy Code #define BME_SCK 13 #define BME_MISO 12 #define BME_MOSI 11 #define BME_CS 10 Adafruit_BME280 bme; // I2C //Adafruit_BME280 bme(BME_CS); // hardware SPI //Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); #define BME_SCK 13 #define BME_MISO 12 #define BME_MOSI 11 #define BME_CS 10 Adafruit_BME280 bme; // I2C //Adafruit_BME280 bme(BME_CS); // hardware SPI //Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK);Once uploaded to your Arduino, open up the serial console at 9600 baud speed to see data being printed out
Temperature is calculated in degrees C, you can convert this to F by using the classic F = C * 9/5 + 32 equation.Pressure is returned in the SI units of Pascals. 100 Pascals = 1 hPa = 1 millibar. Often times barometric pressure is reported in millibar or inches-mercury. For future reference 1 pascal =0.000295333727 inches of mercury, or 1 inch Hg = 3386.39 Pascal. So if you take the pascal value of say 100734 and divide by 3386.39 you'll get 29.72 inches-Hg.You can also calculate Altitude. However, you can only really do a good accurate job of calculating altitude if you know the hPa pressure at sea level for your location and day! The sensor is quite precise but if you do not have the data updated for the current day then it can be difficult to get more accurate than 10 meters.
Library ReferenceYou can start out by creating a BME280 object with either software SPI (where all four pins can be any I/O) using
Download File Copy Code Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK);Or you can use hardware SPI. With hardware SPI you must use the hardware SPI pins for your Arduino - and each arduino type has different pins! Check the SPI reference to see what pins to use.In this case, you can use any CS pin, but the other three pins are fixed
Download File Copy Code Adafruit_BME280 bme(BME_CS); // hardware SPI Adafruit_BME280 bme(BME_CS); // hardware SPIor I2C using the default I2C bus, no pins are assigned
Download File Copy Code Adafruit_BME280 bme; // I2C Adafruit_BME280 bme; // I2COnce started, you can initialize the sensor with
Download File Copy Code if (!bme.begin()) { Serial.println("Could not find a valid BME280 sensor, check wiring!"); while (1); } if (!bme.begin()) { Serial.println("Could not find a valid BME280 sensor, check wiring!"); while (1); }begin() will return True if the sensor was found, and False if not. If you get a False value back, check your wiring!
Reading humidity, temperature and pressure is easy, just call:
Download File Copy Code bme.readTemperature() bme.readPressure() bme.readHumidity() bme.readTemperature() bme.readPressure() bme.readHumidity()Temperature is always a floating point, in Centigrade. Pressure is a 32 bit integer with the pressure in Pascals. You may need to convert to a different value to match it with your weather report. Humidity is in % Relative Humidity
It's also possible to turn the BME280 into an altimeter. If you know the pressure at sea level, the library can calculate the current barometric pressure into altitude
Download File Copy Code bmp.readAltitude(seaLevelPressure) bmp.readAltitude(seaLevelPressure)However, you can only really do a good accurate job of calculating altitude if you know the hPa pressure at sea level for your location and day! The sensor is quite precise but if you do not have the data updated for the current day then it can be difficult to get more accurate than 10 meters.Pass in the current sea level pressure in hPa - so the value will be somewhere around ~1000. You can also test with the generic 1013.25 value.
Page last edited March 08, 2024
Text editor powered by tinymce.
Assembly Python & CircuitPython Test Related Guides CircuitPython Libraries on Linux and the 96Boards... By M. LeBlanc-Williams intermediate Adding a Single Board Computer to Blinka By M. LeBlanc-Williams intermediate CircuitPython Libraries with the Binho Nova... By Francis Guevarra beginner Your browser does not support the video tag. This links to the guide Textable Sensor with FONA and CircuitPython. Textable Sensor with FONA and CircuitPython By Brent Rubell beginner CircuitPython Libraries on MicroPython using the... By M. LeBlanc-Williams beginner Your browser does not support the video tag. This links to the guide PyPortal IoT Weather Station. PyPortal IoT Weather Station By Brent Rubell beginner CircuitPython Libraries on Linux and ODROID C2 By M. LeBlanc-Williams intermediate CircuitPython Libraries on Linux and the NVIDIA... By M. LeBlanc-Williams intermediate Working with Multiple Same Address I2C Devices By Carter Nelson beginner I2C Addresses and Troublesome Chips By lady ada beginner Adafruit IO Environmental Monitor for Feather or... By Brent Rubell intermediate IoT Air Quality Sensor with Adafruit IO By Brent Rubell beginner Air Quality Sensor 3D Printed Enclosure By Ruiz Brothers intermediate Multi-Sensor IoT Environmental Sensor Box With... By Dave Astels intermediate DIY Trinkey No-Soldering USB Air Quality Monitor By Carter Nelson beginnerCreate Wishlist
× Title Description Close Search SearchCategories
Tag » Arduino Adafruit_bme280.h
-
Adafruit BME280 Library - Arduino Reference
-
Adafruit/Adafruit_BME280_Library: Arduino Library For BME280 ...
-
Adafruit_BME280_Library/Adafruit_BME280.h At Master - GitHub
-
Adafruit BME280 Library - Arduino Library List
-
Adafruit BME280 Library: Adafruit_BME280 Class Reference
-
Guide For BME280 Sensor With Arduino (Pressure, Temperature ...
-
ESP8266 With BME280 Using Arduino IDE (Pressure, Temperature ...
-
Adafruit/Adafruit BME280 Library - PlatformIO Registry
-
Particle Adafruit_BME280
-
How To Hookup BME280 Sensor To Arduino Using I2C
-
BME280 - Mongoose OS Documentation
-
Tuto BME280 : Code Arduino, Librairie, Branchement I2C / SPI
-
Interface BME280 Temperature, Humidity & Pressure Sensor With ...
CircuitPython Libraries on Linux and the 96Boards... By
Adding a Single Board Computer to Blinka By
CircuitPython Libraries with the Binho Nova... By
CircuitPython Libraries on MicroPython using the... By
CircuitPython Libraries on Linux and ODROID C2 By
CircuitPython Libraries on Linux and the NVIDIA... By
I2C Addresses and Troublesome Chips By
Adafruit IO Environmental Monitor for Feather or... By
IoT Air Quality Sensor with Adafruit IO By
Air Quality Sensor 3D Printed Enclosure By
Multi-Sensor IoT Environmental Sensor Box With... By