motamman - I posted this on the Arduino group b...
I posted this I2C MPU9250/imu Q on the Arduino group, but maybe some folks here might be able to help:
I have a device that has the following components:
1. Beetle esp32-c6 (programmatically set SDA to GPIO 20, SCL to 19. RX to 21 and TX to 22.)
2. Beitain BE880 GPS connected to RX and TX pins. I am NOT using the internal compass. (TinyGPSPlus library: https://github.com/mikalhart/TinyGPSPlus)
3. An I2C MPU9250/imu mag and accelerometer module on 0x68. (MPU9250 library: https://github.com/hideakitai/)
4. An I2C BME28/temp, pressure and humidity module on 0x76. (Adafruit BME280 library: https://github.com/adafruit/Adafruit_BME280_Library)
I am also running wifi, OTA, and Webserver.
I use data from each sensor to send deltas to a signal k server via UDP.
The BME and GPS always work fine.
Inside the void loop block, mpu.update() only returns usable data if it isn't encapsulated in a loop or a conditional statement. If it is, I get zeros.
But after about 30 minutes, the data freezes. No errors are triggered, but the data remains the same. Give it a little more time, and I get i2cWriteReadNonStop -1 errors and, occasionally, a 263 error. I tried resetting the bus, but I did not expect that to work. It didn't.
void loop() {
// Let the Watchdog know it ain't frozen
esp_task_wdt_reset();
<snip>
mpu.update();
unsigned long currentTime = millis();
if (currentTime - lastProcessTime >= processInterval) {
lastProcessTime = currentTime;
// Stagger sensor data processing
static int sensorCycle = 0;
switch(sensorCycle) {
case 0:
Serial.println("Processing I2C data...");
processCompassData(); // Process compass dat
delay(100);
sendBMP280Data(); // Process BMP280 data
break;
<snip>
}
sensorCycle = (sensorCycle + 1) % 3; // Move to the next sensor in the next loop
}
}
I have a device that has the following components:
1. Beetle esp32-c6 (programmatically set SDA to GPIO 20, SCL to 19. RX to 21 and TX to 22.)
2. Beitain BE880 GPS connected to RX and TX pins. I am NOT using the internal compass. (TinyGPSPlus library: https://github.com/mikalhart/TinyGPSPlus)
3. An I2C MPU9250/imu mag and accelerometer module on 0x68. (MPU9250 library: https://github.com/hideakitai/)
4. An I2C BME28/temp, pressure and humidity module on 0x76. (Adafruit BME280 library: https://github.com/adafruit/Adafruit_BME280_Library)
I am also running wifi, OTA, and Webserver.
I use data from each sensor to send deltas to a signal k server via UDP.
The BME and GPS always work fine.
Inside the void loop block, mpu.update() only returns usable data if it isn't encapsulated in a loop or a conditional statement. If it is, I get zeros.
But after about 30 minutes, the data freezes. No errors are triggered, but the data remains the same. Give it a little more time, and I get i2cWriteReadNonStop -1 errors and, occasionally, a 263 error. I tried resetting the bus, but I did not expect that to work. It didn't.
void loop() {
// Let the Watchdog know it ain't frozen
esp_task_wdt_reset();
<snip>
mpu.update();
unsigned long currentTime = millis();
if (currentTime - lastProcessTime >= processInterval) {
lastProcessTime = currentTime;
// Stagger sensor data processing
static int sensorCycle = 0;
switch(sensorCycle) {
case 0:
Serial.println("Processing I2C data...");
processCompassData(); // Process compass dat
delay(100);
sendBMP280Data(); // Process BMP280 data
break;
<snip>
}
sensorCycle = (sensorCycle + 1) % 3; // Move to the next sensor in the next loop
}
}