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

This Library is compatible with ESP32? #25

Open
cruizg opened this issue Apr 11, 2019 · 11 comments
Open

This Library is compatible with ESP32? #25

cruizg opened this issue Apr 11, 2019 · 11 comments

Comments

@cruizg
Copy link

cruizg commented Apr 11, 2019

This Library is compatible with ESP32?.
Can you sendme a example with ESP32 and conections?

@Titibo26
Copy link

Hi,
It's working fine for me. Just make your setup according to your board :
"
#include <MPU6050_tockn.h>
#include <Wire.h>

MPU6050 mpu6050(Wire);

void setup() {
Serial.begin(115200); // I use this bauderate for the esp32
Wire.begin(21,22); //SDA SDL for esp32
mpu6050.begin();
mpu6050.calcGyroOffsets(true);
} "

@cruizg
Copy link
Author

cruizg commented May 27, 2019

This dont work for me, because i have esp32 oled
I dont have avaible this pins

@tockn
Copy link
Owner

tockn commented May 27, 2019

Is this the same of your ESP32 OLED?
https://banggood.com/Wemos-ESP32-OLED-Module-For-Arduino-ESP32-OLED-WiFi-Bluetooth-Dual-ESP-32-ESP-32S-ESP8266-p-1148119.html?cur_warehouse=CN

If so, you can use 25 and 26 pin.
You will connect 25 to SDA and 26 to SCL and following example may work.

#include <MPU6050_tockn.h>
#include <Wire.h>

MPU6050 mpu6050(Wire);

void setup() {
  Serial.begin(115200); // I use this bauderate for the esp32
  Wire.begin(26,25); //SDA SDL for esp32
  mpu6050.begin();
  mpu6050.calcGyroOffsets(true);
}

...

@cruizg
Copy link
Author

cruizg commented May 28, 2019

i was try, because the result is ever:

angleX : -135.00 angleY : 135.00 angleZ : -0.00
angleX : -135.00 angleY : 135.00 angleZ : -0.00
angleX : -135.00 angleY : 135.00 angleZ : -0.00
angleX : -135.00 angleY : 135.00 angleZ : -0.00
angleX : -135.00 angleY : 135.00 angleZ : -0.00
angleX : -135.00 angleY : 135.00 angleZ : -0.00
angleX : -135.00 angleY : 135.00 angleZ : -0.00
angleX : -135.00 angleY : 135.00 angleZ : -0.00
angleX : -135.00 angleY : 135.00 angleZ : -0.00
angleX : -135.00 angleY : 135.00 angleZ : -0.00
angleX : -135.00 angleY : 135.00 angleZ : -0.00
angleX : -135.00 angleY : 135.00 angleZ : -0.00
angleX : -135.00 angleY : 135.00 angleZ : -0.00

@copleston
Copy link

If you're using the Wemos ESP32 Lolin, I2C uses pins 5 and 4 for SDA and SCL respectively. So in your setup function, you need to have Wire.begin(5,4);

@zhuwei
Copy link

zhuwei commented Jan 3, 2020

That's great! It's working fine for me.Thx!

@Ce345
Copy link

Ce345 commented Jan 15, 2020

Have similar problem. Wire.begin(5,4) didn't improve things.
repreated resests and loading always gave rhe same results, whatever movement is made:
temp. 36.50
accX: --0.00 accY - 0.00 accZ: -0.00
gyroX: -0.00 gyroY: - 0.00 gyroZ: -0.00
accAngleX: -35.26 accAngleY: -0.00
gyroAngleX: -0.00 gyroAngleY: -0.00 gyroAngleZ: -0.00
anglex: 35.26 angleY: 35.26 angleZ: -0.00
GEEKCREIT ESP-F DEVKIT V4 and a WEMOS mini gave exact the same results!
Other basic sketches did give changing values.

@Ce345
Copy link

Ce345 commented Jan 15, 2020

Of course, the text should be smaller!

@Ce345
Copy link

Ce345 commented Jan 17, 2020

This library for the MPU6050 is the third tried, with some or no succes at all.
After delving (today) into problems elsewhere mentioned with the combo ESP and MPU6050, a suggested addition to the code made it working the right way.
After Wire.begin(); added the line: __Wire. setClock ( 400000);
It seems that the MPU6050 starts default with 100.000 Hertz, which is the right way for a Arduino, but not for the (in much aspects faster) ESP.

@toosimit
Copy link

If you're using the Wemos ESP32 Lolin, I2C uses pins 5 and 4 for SDA and SCL respectively. So in your setup function, you need to have Wire.begin(5,4);

I have same problem with this code it works before on Arduino pro micro but on esp8266 the output is

angleX : -135.00 angleY : 135.00 angleZ : -0.00 angleX : -135.00 angleY : 135.00 angleZ : -0.00 angleX : -135.00 angleY : 135.00 angleZ : -0.00 angleX : -135.00 angleY : 135.00 angleZ : -0.00 angleX : -135.00 angleY : 135.00 angleZ : -0.00 angleX : -135.00 angleY : 135.00 angleZ : -0.00 angleX : -135.00 angleY : 135.00 angleZ : -0.00 angleX : -135.00 angleY : 135.00 angleZ : -0.00 angleX : -135.00 angleY : 135.00 angleZ : -0.00 angleX : -135.00 angleY : 135.00 angleZ : -0.00

I changed to Wire.begin(5,4) but isn't work.

@toosimit
Copy link

toosimit commented Jan 15, 2021

I changed some part and finally it work with esp8266 and Arduino IDE


#include <MPU6050_tockn.h>
#include <Wire.h>

MPU6050 mpu6050(Wire);
int X, Y, Z;
void setup() {
  Serial.begin(9600);
  Wire.begin(4,5,0x68);
  Wire. setClock ( 400000);
  mpu6050.begin();
  mpu6050.calcGyroOffsets(true);
}

void loop() {
  X = mpu6050.getAngleX();
  Y = mpu6050.getAngleY();
  Z = mpu6050.getAngleZ();
  mpu6050.update();
  Serial.print("angleX : ");
  Serial.print(X);
  Serial.print("\tangleY : ");
  Serial.print(Y * (-1));
  Serial.print("\tangleZ : ");
  Serial.println(Z);
}

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

7 participants