Has anyone managed to get the RP2040Connect to work with the MPU6050? I have a medical application that currently runs on a Pi Pico and reads out two GY-521/MPU6050 sensors all night.I want to go wireless and the Connect is appealing because of its internal MPU.
I've tested it on a breadboard with no components apart from the processor, the sensor and an LED on one processor pin. It starts out reading the GY-521 OK but after a random time that varies between a few seconds and a couple of minutes it freezes. If I disconnect SDA it comes back to life.
I guess the sensor is holding SDA low, because I see articles about that on the Web, not relating to the Connect though, and not giving a fix.
I've now replaced the Connect by an ESP32-C3 and it works fine. No internal MPU though.
All suggestions welcome. I've already tried changing the I2C clock speed, and moving from Adafruit_MPU6050 to MPU6050_light. Neither fixed it.
Why bother with a dirt cheap clone or counterfeit of a long obsolete sensor like the MPU-6050?
Buy a modern 6DOF sensor like the ISM330 from a reputable seller, and you can be confident that if wired properly, it will work, as well as significantly outperform the original.
Well, to be frank, i did not know about it. But it is about ten times the price of MPU6050. Thats a bit beyond my budget. Is there nothing inbetween?
But also, ive used the 6050 with several processors without problems. I think the Connect I2C bus protocol isn't right somehow.
If you want help with your specific problem, please follow the forum rules and post the required information.
See the "How to get the best out of this forum" post for a summary of what is expected.
Here is a sketch that demonstrates the problem. I am using a small breadboard with only the RP2040 CONNECT and a single MPU6050 on it, no other components. Power is via USB.
//#define WIFICONNECT // connect to wifi only
#define LED_PIN 13 // nano internal led - clashes with SPI !
#include "Wire.h"
#include <WiFi.h>
#define MPU6050_I2C_ADDRESS1 0x68
#include <Adafruit_MPU6050.h>
Adafruit_MPU6050 mpu1;
sensors_event_t a1, g1, t1;
#ifdef WIFICONNECT
const char* ssid = "yourssid";
const char* password = "yourpassword";
#endif
int LEDflash = 0;
void setup()
{
Serial.begin(115200);
while ( !Serial ) delay(100); // wait for native usb
pinMode (LED_PIN, OUTPUT);
Wire.begin();
// initialise MPU6050 s
if (!mpu1.begin(MPU6050_I2C_ADDRESS1)) {
#ifdef DEBUG
Serial.println(F("Failed to find mpu1"));
#endif
while(1);
}
#ifdef DEBUG
Serial.println(F("mpu1 found"));
#endif
mpu1.setAccelerometerRange(MPU6050_RANGE_4_G);
mpu1.setGyroRange(MPU6050_RANGE_250_DEG);
mpu1.setFilterBandwidth(MPU6050_BAND_21_HZ);
#ifdef WIFICONNECT
digitalWrite(LED_PIN, HIGH); // turn the LED on
WiFi.begin(ssid, password);
// Wait for connection
int tries = 0;
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
++tries;
if (tries > 20) {
Serial.println(F("Failed to connect to wifi"));
while (1);
}
}
Serial.println("Connected to wifi");
digitalWrite(LED_PIN, LOW); // turn the LED off
#endif
}
void loop() {
// read sensor
while (!mpu1.getEvent(&a1, &g1, &t1));
Serial.print("mpu1 gotevent ");
Serial.print(millis());
Serial.print(" ");
Serial.println(a1.acceleration.x);
delay(10);
LEDflash = 1 - LEDflash;
digitalWrite(LED_PIN, LEDflash);
}
The sketch just reads the MPU6050 in a loop and shows one of the returned values. If you run this with #define WIFICONNECT commented out, it loops forever displaying the data. If you uncomment #define WIFICONNECT, the setup includes the code to connect to a Wifi network. However, the sketch does not attempt to send or receive on the Wifi. After a period between a few seconds and a minute or two the processor freezes. If you disconnect SDA it comes back to life.
A secondary issue. After you upload, on reboot the processor cannot connect to wifi. Unplug power and replug and it connects without a problem.