#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define I2C_SDA 11 //GPIO 11 --> A5
#define I2C_SCL 12 //GPIO 12 --> A4
#define SEALEVELPRESSURE_HPA (1013.25)
TwoWire I2CBME = TwoWire(0);
Adafruit_BME280 bme; // I2C
unsigned long delayTime;
void setup() {
Serial.begin(9600);
while(!Serial); // time to get serial running
Serial.println(F("BME280 test"));
unsigned status;
I2CBME.begin(I2C_SDA, I2C_SCL, 100000);
status = bme.begin(0x76, &I2CBME);
// You can also pass in a Wire library object like &Wire2
// status = bme.begin(0x76, &Wire2)
if (!status) {
Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
Serial.print(" ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
Serial.print(" ID of 0x60 represents a BME 280.\n");
Serial.print(" ID of 0x61 represents a BME 680.\n");
//while (1) delay(10);
}
Serial.println("-- Default Test --");
delayTime = 1000;
Serial.println();
}
void loop() {
printValues();
delay(delayTime);
}
void printValues() {
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" °C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Approx. Altitude = ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
}
In the Arduino IDE I used the Setting: Pin numbering "By GPIO Number". I need this seeting cause of the second part of my project which is a connection to a wireshark e paper display via SPI which is already working fine. So I like to continue with this setting. Means at the end I like to have the e paper display working together with the BME280. So I tried to test the BME280 in a seperate check with this code.
Fault behaviour: The BME280 is not been detected. The status variable returns a fault value and serial Monitor displays: "Could not find a valid BME280 sensor, check wiring, address, sensor ID!"
Is this a know problem?
Thanks for helping me.
Best regards Mascho
Posting an annotated schematic would be very helpful. Be sure to include the GPIO numbers as well as the pin numbers you are using. This will make it much easier to understand your setup and provide accurate assistance.
I checked the A4 and A5 Pins with an Oszi and can see there is some communication. Nevertheless the BME280 will not be recognized and a continous communication e.g. for temp reading will not take place.
I also checked with second Nano ESP32 and second BME280. No effect.
Did you check the i2c address with an address scanner?
Is your BMP280 a 5V device or a 3.3V device? You may have damaged it when a 3.3V devices is exposed to 5V control signals (my BMP280 /UNO works good this combination isprogrammed via a BMP280.h library - I suggest to test alternative libraries! ).
success, Photoncatcher
The i2c scanner reports:
12:02:50.306 -> Scanning for I2C devices ...
12:02:50.306 -> I2C device found at address 0x5A
12:02:50.352 -> I2C device found at address 0x76
5A is the CCS811
76 the BME280 but still getting no datas back
I tested now 3 of the BME280 with my Nano ESP32. No way, all are not running.
Then I took my old Uno Board and same result as with the Nano ESP32. The I2C scanner will detect the ASIC but a further communication is not possible.
I feel the ASICs are damaged for some reason. Will buy some new one and then check again.
Will close the topic for now and will reopen once new ASICs are tested.
Thank you all for your help and your inputs for supporting me.
Best regards
Mascho