Git Product home page Git Product logo

Comments (11)

toosimit avatar toosimit commented on September 6, 2024 1

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);
}

from mpu6050_tockn.

Titibo26 avatar Titibo26 commented on September 6, 2024

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);
} "

from mpu6050_tockn.

cruizg avatar cruizg commented on September 6, 2024

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

from mpu6050_tockn.

tockn avatar tockn commented on September 6, 2024

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);
}

...

from mpu6050_tockn.

cruizg avatar cruizg commented on September 6, 2024

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

from mpu6050_tockn.

copleston avatar copleston commented on September 6, 2024

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);

from mpu6050_tockn.

zhuwei avatar zhuwei commented on September 6, 2024

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

from mpu6050_tockn.

Ce345 avatar Ce345 commented on September 6, 2024

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.

from mpu6050_tockn.

Ce345 avatar Ce345 commented on September 6, 2024

Of course, the text should be smaller!

from mpu6050_tockn.

Ce345 avatar Ce345 commented on September 6, 2024

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.

from mpu6050_tockn.

toosimit avatar toosimit commented on September 6, 2024

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.

from mpu6050_tockn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.