Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

BME280 fails(-128) after random amount of time ESP32

Hello! I am using the latest mos and ESP32.
I also use MJS for my project mainly. I am using I2C ports 21 scl /22 sda, 0x76 as address and things work just fine for 20-30 minutes sometimes it works for hours, after that it starts returning -128 both for temperature and humidity.
Right now my code that handles BME is like this:

load('api_bme280.js')
let sensor = BME280.createI2C(0x76);
let TEMP = 0;
let HUM = 0;

function updateSensorReadings() {
  let t = bmeSensor.readTemp();
  let h = bmeSensor.readHumid();
  print("Got sensor data: ", t, h);
  if (!isNaN(h)) {
    HUM = floor(h);
  }
  if (!isNaN(t)) {
    TEMP = floor(t);
  }

}

Timer.set(
  10000 /* milliseconds */,
  Timer.REPEAT,
  function() {
      updateSensorReadings();
  },
  null
);

What I tried:

changing sensors
changing bme280 libs (tried the arduino one from adafruit),
tried to instantiate the sensor object right before querying the temperature and humidity and freeing the instance (.free()) after each read
tried to check the source code and from that I can only assume that during use the ESP32 will lose sight of the sensor which will trigger the null_ptr/bme_error return (-128).
I use the BME280 board, so I tried to run it in 3.3v and 5v, same results.
Tried another different sensor (DHT22) and it worked fine, no problems.
Tried Different ESP32 (mine local and from a client that is showing the same problem)

Can anyone point me in the right direction? have you have encountered this problem?
Thank you!

Comments

Sign In or Register to comment.