Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not available on rp2040 (raspberry pie Pico). #31

Open
xiezhoubin opened this issue Aug 6, 2022 · 0 comments
Open

Not available on rp2040 (raspberry pie Pico). #31

xiezhoubin opened this issue Aug 6, 2022 · 0 comments

Comments

@xiezhoubin
Copy link

Problem:
I use mpu6050 sensor and raspberry pie Pico development board. I can make sure the wiring is correct. However, the same code can run on Arduino uno and esp32, and can correctly read mpu6050 data. After the raspberry pie Pico runs, it cannot correctly read data.(Raspberry pie enables Pico to read normally using hardware IIC.)

arduino for rp2040:
https://github.com/earlephilhower/arduino-pico

Picture:
image
Raspberry pie Pico failed to read with software IIC:
image
Arduino uno successfully read with software IIC:
image

Code:

#include <SoftWire.h>
SoftWire Wire(12, 13); // Raspberry pie Pico(SDA=12,SCL=13) ,ARDUINO UNO(SDA=2,SCL=3)

const int MPU6050_addr = 0x68;
int16_t AccX, AccY, AccZ, Temp, GyroX, GyroY, GyroZ;
uint8_t swTxBuffer[32];
uint8_t swRxBuffer[32];

void setup() {
Wire.setTxBuffer(swTxBuffer, sizeof(swTxBuffer));
Wire.setRxBuffer(swRxBuffer, sizeof(swRxBuffer));
Wire.begin();
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600);
}

void loop() {
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU6050_addr, 14, true);
AccX = Wire.read() << 8 | Wire.read();
AccY = Wire.read() << 8 | Wire.read();
AccZ = Wire.read() << 8 | Wire.read();
Temp = Wire.read() << 8 | Wire.read();
GyroX = Wire.read() << 8 | Wire.read();
GyroY = Wire.read() << 8 | Wire.read();
GyroZ = Wire.read() << 8 | Wire.read();

Serial.print("AccX = ");
Serial.print(AccX);
Serial.print(" || AccY = ");
Serial.print(AccY);
Serial.print(" || AccZ = ");
Serial.print(AccZ);
Serial.print(" || GyroX = ");
Serial.print(GyroX);
Serial.print(" || GyroY = ");
Serial.print(GyroY);
Serial.print(" || GyroZ = ");
Serial.print(GyroZ);
Serial.print(" || Temp = ");
Serial.println(Temp / 340.00 + 36.53);
delay(500);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant