Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By metalphreak
#43515 The Sparkfun code is using a 64bit integer when reading temp. The ESP8266 is a 32-bit CPU core. There may be some weird rounding errors depending on how the Xtensa compiler is handling 64bit variables compared to the Atmel compiler.

Like I said, make sure the code is reading back the same raw values and calibration values for both the ESP8266 and the Arduino, then you can know for sure if it's the code that converts it to a degree C value.

Or just add this and run the function on both, if it doesn't return the same thing, then its the conversion code.

Code: Select allfloat BME280::readTest( void )
{

   int32_t adc_T = 0x00AB1234; //fixed test value

   //By datasheet, calibrate
   int64_t var1, var2;

   var1 = ((((adc_T>>3) - ((int32_t)calibration.dig_T1<<1))) * ((int32_t)calibration.dig_T2)) >> 11;
   var2 = (((((adc_T>>4) - ((int32_t)calibration.dig_T1)) * ((adc_T>>4) - ((int32_t)calibration.dig_T1))) >> 12) *
   ((int32_t)calibration.dig_T3)) >> 14;
   t_fine = var1 + var2;
   float output = (t_fine * 5 + 128) >> 8;

   output = output / 100;
   
   return output;
}
User avatar
By duffmanm
#48680
RKieboom wrote:I added another BME280 with another I2C address. My output at the moment is:

HTU21: Temp=22.06 Hum=30.91
SHT31: Temp=21.82 Hum=31.05
BME280: Temp=22.66 Hum=33.75 Pres=103272.67
BME280/2: Temp=22.60 Hum=33.47 Pres=103227.92
HDC1008: Temp=21.80 Hum=25.82
MCP9808: Temp=22.31

The temperature is now getting close to the real temperature. I didn't do anything to accomplish this!
Humidity is still higher than the HTU/SHT, but I don't have a reference, so maybe they are off.

To recap, I installed the latest Adafruit library (I am using BME Adafruit breakouts by the way), added two pull-up resistors of 2K2 to both SDA and SCL. I am powering the ESP from my laptop through USB at the moment. I don't use Wifi in my sketch, just printing the values.

Why it is getting better? :o



Hi RKieboom!

I have been testing like you the BME280 sensor and have had large variations compared to DHT22, SHT21 and BMP180. These three sensors marked similar values, however the BME280 marks always more or less 1 °C more of temperature and about 10% less moisture.
I tried using the library as comets Adafruit but the Serial gives me the error "Could not find a valid BME280 sensor, check wiring!"
I am using the "Wemos D1" board which is based on the ESP8266, and in my case instead of using the breakout of Adafruit, is one purchased in Aliexpress.

I would greatly appreciate if you could help me.
Thank you very much.
User avatar
By RKieboom
#48707
duffmanm wrote:
RKieboom wrote:I added another BME280 with another I2C address. My output at the moment is:

HTU21: Temp=22.06 Hum=30.91
SHT31: Temp=21.82 Hum=31.05
BME280: Temp=22.66 Hum=33.75 Pres=103272.67
BME280/2: Temp=22.60 Hum=33.47 Pres=103227.92
HDC1008: Temp=21.80 Hum=25.82
MCP9808: Temp=22.31

The temperature is now getting close to the real temperature. I didn't do anything to accomplish this!
Humidity is still higher than the HTU/SHT, but I don't have a reference, so maybe they are off.

To recap, I installed the latest Adafruit library (I am using BME Adafruit breakouts by the way), added two pull-up resistors of 2K2 to both SDA and SCL. I am powering the ESP from my laptop through USB at the moment. I don't use Wifi in my sketch, just printing the values.

Why it is getting better? :o



Hi RKieboom!

I have been testing like you the BME280 sensor and have had large variations compared to DHT22, SHT21 and BMP180. These three sensors marked similar values, however the BME280 marks always more or less 1 °C more of temperature and about 10% less moisture.
I tried using the library as comets Adafruit but the Serial gives me the error "Could not find a valid BME280 sensor, check wiring!"
I am using the "Wemos D1" board which is based on the ESP8266, and in my case instead of using the breakout of Adafruit, is one purchased in Aliexpress.

I would greatly appreciate if you could help me.
Thank you very much.


Hi duffmanm,

It should work. I purchased some BME280's in china and they turned out to be BMP280's.
You could try checking it with BMP280 settings.
Another check could be connecting it to a regular Arduino and check if the sensor functions correctly.

Regards
User avatar
By duffmanm
#48857
RKieboom wrote:
duffmanm wrote:
RKieboom wrote:I added another BME280 with another I2C address. My output at the moment is:

HTU21: Temp=22.06 Hum=30.91
SHT31: Temp=21.82 Hum=31.05
BME280: Temp=22.66 Hum=33.75 Pres=103272.67
BME280/2: Temp=22.60 Hum=33.47 Pres=103227.92
HDC1008: Temp=21.80 Hum=25.82
MCP9808: Temp=22.31

The temperature is now getting close to the real temperature. I didn't do anything to accomplish this!
Humidity is still higher than the HTU/SHT, but I don't have a reference, so maybe they are off.

To recap, I installed the latest Adafruit library (I am using BME Adafruit breakouts by the way), added two pull-up resistors of 2K2 to both SDA and SCL. I am powering the ESP from my laptop through USB at the moment. I don't use Wifi in my sketch, just printing the values.

Why it is getting better? :o



Hi RKieboom!

I have been testing like you the BME280 sensor and have had large variations compared to DHT22, SHT21 and BMP180. These three sensors marked similar values, however the BME280 marks always more or less 1 °C more of temperature and about 10% less moisture.
I tried using the library as comets Adafruit but the Serial gives me the error "Could not find a valid BME280 sensor, check wiring!"
I am using the "Wemos D1" board which is based on the ESP8266, and in my case instead of using the breakout of Adafruit, is one purchased in Aliexpress.

I would greatly appreciate if you could help me.
Thank you very much.


Hi duffmanm,

It should work. I purchased some BME280's in china and they turned out to be BMP280's.
You could try checking it with BMP280 settings.
Another check could be connecting it to a regular Arduino and check if the sensor functions correctly.

Regards






Hello again!
After investigating the web https://forum.arduino.cc/index.php?topic=400394.0 I discovered that the error was I2C address. As I said here, I had to modify the library Adafruit because my BME280 seems to be having direction 76 (not the 77 that have preset the library Adafruit).

However, BME280 still shows the same imprecision values of temperature and humidity (about 1 ° C and 10%).

DHT22 24.40;60.80;25.76;53.17;101658.95;
SHT21 24.78;60.94;
bme280 25.76;53.17;101658.95

Any recommendation?
Thank you