Skip to content
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

102 lines (75 sloc) 2.66 KB
This is a library for the BME280 humidity, temperature & pressure sensor
Designed specifically to work with the Adafruit BME280 Breakout
These sensors use I2C or SPI to communicate, 2 or 4 pins are required
to interface. The device's I2C address is either 0x76 or 0x77.
Adafruit invests time and resources providing this open source code,
please support Adafruit andopen-source hardware by purchasing products
from Adafruit!
Written by Limor Fried & Kevin Townsend for Adafruit Industries.
BSD license, all text above must be included in any redistribution
/* IMPORTANT MOD-BME280 work on 3.3V only, make sure you switch OLIMEXINO/ARDUINO to 3.3V power
* or you may damage your sensor
* connection to OLIMEXINO-32U4 or OLIMEXINO-328 via UEXT cable - just plug the cable to UEXT connector
* connection to breadboard:
* MOD.BME280 VCC -> 3.3V
* MOD.BME280 SDA -> D2
* MOD.BME280 SCL -> D3
#include <Wire.h>
#include <SPI.h>
#include "Adafruit_BME280.h"
#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
unsigned long delayTime;
void setup() {
pinMode(8,OUTPUT); //enable UEXT port power supply
delay (10); //wait MOD-BME280 to achieve stabile power
while (!Serial);
Serial.println(F("BME280 test"));
bool status;
// default settings
// (you can also pass in a Wire library object like &Wire2)
status = bme.begin(0x76);
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
Serial.println("-- Default Test --");
delayTime = 1000;
delay(100); // let sensor boot up
void loop() {
void printValues() {
Serial.print("Temperature = ");
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Approx. Altitude = ");
Serial.println(" m");
Serial.print("Humidity = ");
Serial.println(" %");
You can’t perform that action at this time.