Chat freely about anything...

User avatar
By Juanan
#90319 Hello. I am developing a project in which I have encountered some problems. I am using an esp01 and a bme280 to measure the temperature of different rooms and send this information to a screen via udp.
My problem is in the module composed of the esp01 and the temperature sensor. After a time correctly measuring the temperature, the sensor begins to send erroneous data (indicating -147 in temperature and 100 in humidity). I have modified the code so that after taking the measurement the sensor turns off and does not turn on again until the next loop, but the result is the same. Currently I don't know how I can solve this error.
I attach my code and the image of the connections I am using.


Code: Select all#include <Wire.h>
#include <ESP8266WiFi.h>
#include <WiFiUDP.h>
#include <SPI.h>
#include <Adafruit_BME280.h>

#include "config.h"
#include "UDP.hpp"
#include "ESP8266_Utils.hpp"
#include "ESP8266_Utils_UDP.hpp"

#define pin_bme 3
Adafruit_BME280 bme;
int sensor[] = {0, 0};

void setup()
  pinMode(pin_bme, OUTPUT);
  digitalWrite(pin_bme, LOW);

void loop()
  digitalWrite(pin_bme, HIGH);
  Wire.begin(0, 2);
  sensor[0] = bme.readTemperature();
  sensor[1] = bme.readHumidity();

  String packet = (String)sensor[0] + "." + (String)sensor[1];

  digitalWrite(pin_bme, LOW);

User avatar
By QuickFix
#90330 From this website on
A sensor returns an unexpected value or NaN. This problem may present itself as either transient or permanent and can be caused by a poor connection to ground or 3V3. To find the problem, move one of the connections to another equivalent pin or just reconnect both wires to a different set of ground and 3V3 pins. If you're using breadboard patch leads and the fault persists then it could be the leads themselves. If you replace the patch leads throw the old ones away or they will come back to haunt you.

You might want to check that. :idea:
User avatar
By Juanan
#90333 Hi QuickFix, thx for the reply.
I will try to change all my wires and post the result as soon as i can.
User avatar
By eriksl
#90344 I once had a batch of bogus ones. They gave all sorts of erronous readings (continuously, not varying with temperature or humidity). I complained and got others and they worked like a charm, using the same code and the same hardware. So you might be victim of the same bogus ones.

Also be aware often BMP280's are sold are BME280's. They are completely identical, but only the BME280 has humidity support. The BMP280 will not give an error, but it will return bogus values. Only in the chip ID you can see which one it is.