- Sun Jan 15, 2017 11:18 am
#61052
I did recieve a new BME280 from china.
My sketch is still not working, so i expect it is not the BMW280 itself.
Does soembody nows a working sketch for BME280?
I'm using the adafruit BME280 library and the next programm:
Code: Select all// Do not remove the include below
#include "BME_test.h"
#include <Adafruit_BME280.h>
/***************************************************************************
This is a library for the BME280 humidity, temperature & pressure sensor
Designed specifically to work with the Adafruit BME280 Breakout
----> http://www.adafruit.com/products/2650
These sensors use I2C or SPI to communicate, 2 or 4 pins are required
to interface.
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
***************************************************************************/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
//#define BME_SCK 13
//#define BME_MISO 12
//#define BME_MOSI 11
//#define BME_CS 10
#define SDAPIN 04
#define SCLPIN 05
//#define SEALEVELPRESSURE_HPA (1013.25)
float SEALEVELPRESSURE_HPA;
Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK);
void setup() {
Serial.begin(115200);
//Wire.begin(SDAPIN, SCLPIN); //sda, scl
//Wire.begin();
Serial.println(F("BME280 test"));
if (!bme.begin()) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
}
void loop() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
SEALEVELPRESSURE_HPA = bme.readPressure() / 100.0F;
Serial.print("Approx. Altitude = ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
delay(2000);
}
SCL is connect to pin 2 (D1, GPI05)
SCA is connected to pin 3(D2, GPI04)
The error is That the BME is not found
I did use BMP180 before. These did work fine.
Please advise