My BME280 has the following signal signatures at the edge connectors.
Vcc ----> 5V
GND ----> GND
SCL ----> A5 (UNO)
SDA ----> A4 (UNO)
CSB
SD0
The I2C scanner program finds the device at 0x77. The header file contains the same address. I am using Adafruit_BME280.h Library. The CSB and SD0 pins are left unconnected as I am not finding any documentation for this small board.
I have run the test program (by default it is in BME I2C Mode) from the IDE. The following message has appeared on the Serial Monitor.
BME280 test
Couldn't find a valid BME280 sensor, check wiring!
Is there anything to do with those two (CSB, SD0) unconnected pins?
The other two are only used if you use the SPI interface, which you don't seem to use. Wiring sounds OK. For SPI wiring and how to set the sensor to SPI mode, check the documentation of your specific breakout board.
Do you have pull-up resistors on SDA and SCL? (this may or may not be on your breakout module - if not, you have to add external ones - 10k is usually fine). It may be that your Arduino's internal pull-ups are used, which are out of spec for I2C, but could be enough for the scanner to find the device, but not good enough to do more communication with it.
Is that a 5V or 3.3V Arduino? If 5V you need level shifting (again this may or may not be on board of the module).
You can find a link to the Bosch BME280 sensor datasheet on Adafruit's BME280 breakout product web page, under "documents". Table 35 and Figure 17 of the datasheet provide complete I2C connection guidance.
I ordered the I2C version board that includes a 5V regulator and level shifter from eBay seller in China. What was delivered instead, was a 3.3V version (no on-board voltage regulator or shifter). This 3.3v board does work well on a 3.3v Arduino. The board tested good on both I2C and SPI connections using Adafruit's BME280 library.
Since the board is configured for I2C hex address 0x76, Adafruit's example sketch "bme280test.ino" needs to be modified as follows: Change in setup(), line: bme.begin();, change to: bme.begin(0x76);.
The breakout board I have has 10K pullup resistors, where as the datasheet recommends 4.7K pullups. The board also has a 10K resistor pulling SDO to GND, so according to the datasheet, I2C address is set to hex address 0x76.
I have been able to collect the following information relating to the BME280 sensor, and I tried in all possible connections. It is not working; probably, it is broken; I will collect another one and will try.
No regulator there - you will need to add level shifters and connect the sensor to the 3.3V power of the Arduino.
The connection diagram shown is bad: this sensor is not 5V tolerant, the SDA and SCL lines will be pulled to +5V and that may damage the sensor, even though the resistors may help preventing that from actually happening (the maximum possible current is highly limited) it's overall simply not a good idea.
SPI is worse, that will almost certainly damage the sensor as SPI is actually driven high, not gently pulled high through a resistor.
I don't have the level sifter; so, I have operated the BME280 using 3.3V Arduino -- Arduino DUE. The Serial Monitor is reporting the same error message -- Could not find valid sensor. Check wiring!
As I have played a lot with the sensor and the UNO in terms of changing connections and supplies, it is possible that the sensor has gone out of order in the mean time. The next one (once received), I will check it first using DUE.
I had some luck with my Uno R3 just using 3.3V Gnd and scl/sda pins. sensor is the same as OP has shown.
GolamMostafa:
I have been able to collect the following information relating to the BME280 sensor, and I tried in all possible connections. It is not working; probably, it is broken; I will collect another one and will try.
Thank you all for showing interest in my affairs.
This worked for me with no extra libraries, but still no humidity.
// Distributed with a free-will license.
// Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
// BME280
// This code is designed to work with the BME280_I2CS I2C Mini Module available from ControlEverything.com.
// https://www.controleverything.com/content/Humidity?sku=BME280_I2CS#tabs-0-product_tabset-2
#include<Wire.h>
// BME280 I2C address is 0x76(108)
#define Addr 0x76
void setup()
{
// Initialise I2C communication as MASTER
Wire.begin();
// Initialise Serial communication, set baud rate = 9600
Serial.begin(9600);
}
void loop()
{
unsigned int b1[24];
unsigned int data[8];
unsigned int dig_H1 = 0;
for(int i = 0; i < 24; i++)
{
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Select data register
Wire.write((136+i));
// Stop I2C Transmission
Wire.endTransmission();
// Request 1 byte of data
Wire.requestFrom(Addr, 1);
// Read 24 bytes of data
if(Wire.available() == 1)
{
b1[i] = Wire.read();
}
}
// Convert the data
// temp coefficients
unsigned int dig_T1 = (b1[0] & 0xff) + ((b1[1] & 0xff) * 256);
int dig_T2 = b1[2] + (b1[3] * 256);
int dig_T3 = b1[4] + (b1[5] * 256);
// pressure coefficients
unsigned int dig_P1 = (b1[6] & 0xff) + ((b1[7] & 0xff ) * 256);
int dig_P2 = b1[8] + (b1[9] * 256);
int dig_P3 = b1[10] + (b1[11] * 256);
int dig_P4 = b1[12] + (b1[13] * 256);
int dig_P5 = b1[14] + (b1[15] * 256);
int dig_P6 = b1[16] + (b1[17] * 256);
int dig_P7 = b1[18] + (b1[19] * 256);
int dig_P8 = b1[20] + (b1[21] * 256);
int dig_P9 = b1[22] + (b1[23] * 256);
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Select data register
Wire.write(161);
// Stop I2C Transmission
Wire.endTransmission();
// Request 1 byte of data
Wire.requestFrom(Addr, 1);
// Read 1 byte of data
if(Wire.available() == 1)
{
dig_H1 = Wire.read();
}
for(int i = 0; i < 7; i++)
{
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Select data register
Wire.write((225+i));
// Stop I2C Transmission
Wire.endTransmission();
// Request 1 byte of data
Wire.requestFrom(Addr, 1);
// Read 7 bytes of data
if(Wire.available() == 1)
{
b1[i] = Wire.read();
}
}
// Convert the data
// humidity coefficients
int dig_H2 = b1[0] + (b1[1] * 256);
unsigned int dig_H3 = b1[2] & 0xFF ;
int dig_H4 = (b1[3] * 16) + (b1[4] & 0xF);
int dig_H5 = (b1[4] / 16) + (b1[5] * 16);
int dig_H6 = b1[6];
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Select control humidity register
Wire.write(0xF2);
// Humidity over sampling rate = 1
Wire.write(0x01);
// Stop I2C Transmission
Wire.endTransmission();
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Select control measurement register
Wire.write(0xF4);
// Normal mode, temp and pressure over sampling rate = 1
Wire.write(0x27);
// Stop I2C Transmission
Wire.endTransmission();
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Select config register
Wire.write(0xF5);
// Stand_by time = 1000ms
Wire.write(0xA0);
// Stop I2C Transmission
Wire.endTransmission();
for(int i = 0; i < 8; i++)
{
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Select data register
Wire.write((247+i));
// Stop I2C Transmission
Wire.endTransmission();
// Request 1 byte of data
Wire.requestFrom(Addr, 1);
// Read 8 bytes of data
if(Wire.available() == 1)
{
data[i] = Wire.read();
}
}
// Convert pressure and temperature data to 19-bits
long adc_p = (((long)(data[0] & 0xFF) * 65536) + ((long)(data[1] & 0xFF) * 256) + (long)(data[2] & 0xF0)) / 16;
long adc_t = (((long)(data[3] & 0xFF) * 65536) + ((long)(data[4] & 0xFF) * 256) + (long)(data[5] & 0xF0)) / 16;
// Convert the humidity data
long adc_h = ((long)(data[6] & 0xFF) * 256 + (long)(data[7] & 0xFF));
// Temperature offset calculations
double var1 = (((double)adc_t) / 16384.0 - ((double)dig_T1) / 1024.0) * ((double)dig_T2);
double var2 = ((((double)adc_t) / 131072.0 - ((double)dig_T1) / 8192.0) *
(((double)adc_t)/131072.0 - ((double)dig_T1)/8192.0)) * ((double)dig_T3);
double t_fine = (long)(var1 + var2);
double cTemp = (var1 + var2) / 5120.0;
double fTemp = cTemp * 1.8 + 32;
// Pressure offset calculations
var1 = ((double)t_fine / 2.0) - 64000.0;
var2 = var1 * var1 * ((double)dig_P6) / 32768.0;
var2 = var2 + var1 * ((double)dig_P5) * 2.0;
var2 = (var2 / 4.0) + (((double)dig_P4) * 65536.0);
var1 = (((double) dig_P3) * var1 * var1 / 524288.0 + ((double) dig_P2) * var1) / 524288.0;
var1 = (1.0 + var1 / 32768.0) * ((double)dig_P1);
double p = 1048576.0 - (double)adc_p;
p = (p - (var2 / 4096.0)) * 6250.0 / var1;
var1 = ((double) dig_P9) * p * p / 2147483648.0;
var2 = p * ((double) dig_P8) / 32768.0;
double pressure = (p + (var1 + var2 + ((double)dig_P7)) / 16.0) / 100;
// Humidity offset calculations
double var_H = (((double)t_fine) - 76800.0);
var_H = (adc_h - (dig_H4 * 64.0 + dig_H5 / 16384.0 * var_H)) * (dig_H2 / 65536.0 * (1.0 + dig_H6 / 67108864.0 * var_H * (1.0 + dig_H3 / 67108864.0 * var_H)));
double humidity = var_H * (1.0 - dig_H1 * var_H / 524288.0);
if(humidity > 100.0)
{
humidity = 100.0;
}
else if(humidity < 0.0)
{
humidity = 0.0;
}
// Output data to serial monitor
Serial.print("Temperature in Celsius : ");
Serial.print(cTemp);
Serial.println(" C");
Serial.print("Temperature in Fahrenheit : ");
Serial.print(fTemp);
Serial.println(" F");
Serial.print("Pressure : ");
Serial.print(pressure);
Serial.println(" hPa");
Serial.print("Relative Humidity : ");
Serial.print(humidity);
Serial.println(" RH");
delay(1000);
}