-3

What is the problem and why do we need to do this?

I recently purchased an MPU6050 breakout board. I tried it with my Arduino Uno, and with my Raspberry Pi 3.

It gives this weird output with Raspberry (without any motion / in stable condition)!

InvenSense MPU-6050
Rpi start 2018
Output range : 68, error = 0
control ratio : 0, error = 0

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1944, 368, 15608
temperature: 30.576 degrees Celsius
gyro x,y,z : -34, -204, -247, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1952, 364, 15304
temperature: 30.435 degrees Celsius
gyro x,y,z : -38, -216, -274, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1864, 388, 15356
temperature: 30.482 degrees Celsius
gyro x,y,z : -34, -233, -278, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1888, 324, 15260
temperature: 30.576 degrees Celsius
gyro x,y,z : -14, -220, -261, 

Similarly, I have tried with Arduino, and it's working fine.

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1, 4, 1
temperature: 30.4 degrees Celsius
gyro x,y,z : -3, -15, -7, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1, 4, 1
temperature: 30.4 degrees Celsius
gyro x,y,z : -3, -15, -7, 

MPU-6050
Read accel, temp and gyro, error = 0
accel x,y,z: 1, 4, 1
temperature: 30.5 degrees Celsius
gyro x,y,z : -3, -15, -7,

Now, I got a proper reading from Arduino. Here is the problem!

I don't know how to sent proper data from Arduino to pi (USB Serial communication).

  • Off-topic. Please post problematic code, if you have any. This is not a code-writing service. – dda Apr 10 '18 at 12:06
  • You can suggest the way, code is not required – Calvin Richard Apr 10 '18 at 12:33
  • There are only three functions you could use - Serial.print(), Serial.println(), and Serial.write(). It doesn't take that much effort to determine what each actually does. – Jerwin Prabu Apr 10 '18 at 12:36
  • 2
    @CalvinRichard code is definitely required. If you don't have a problematic piece of code to solve, SO is not the right place. – dda Apr 10 '18 at 12:37
  • https://stackoverflow.com/help/how-to-ask https://stackoverflow.com/help/mcve – dda Apr 10 '18 at 12:38
  • 2
    SO where we help solve programming problems, so the code is always required, and in your case is essential, if not your question falls on the off-topic *why is not this code working?*, and therefore must be closed – eyllanesc Apr 10 '18 at 14:20

2 Answers2

0

It seems to work better on your Raspberry than your arduino actually.

On your Arduino output, the values of accelerometer are practically 0, which doesn't make sense because you always have an acceleration due to earth gravity pull, even if your board isn't moving at all.

Same for the gyroscope, the initial position will be at power up and then if you move it, values will change and later even if it is static, it would keep these position.

From the output you provided, the Raspberry seem to provide correct data while the Arduino seems to have issue.

It seems the issue comes from your Arduino. Given arduino has much less processing power, I would suggest to look into your arduino setup.

One reason could be the lack of pullup resistor on the I2C bus.

Damien
  • 1,492
  • 10
  • 32
0

Once you know that the ports are ready to read or write, you can use the read() or write() methods. Alternatively, the readLine() and readAll() convenience methods can also be invoked.

If not all the data is read at once, the remaining data will be available for later as new incoming data is appended to the QSerialPort's internal read buffer. You can limit the size of the read buffer using setReadBufferSize().

create a signal and slot. // do your stuff

// This is the answer for your question. read data from qt like this (given below).

if(serial -> canReadLine())
{
    QString str = serial -> readAll();

    int var = str.toInt(); // convert into int

    // Read data and print or use progressBar to print data
}
Jerwin Prabu
  • 336
  • 1
  • 3
  • 16
  • If I want to use a progress bar, how can I set the value for that? Is there any command available for that? Any example for creating SIGNAL? – Calvin Richard Apr 16 '18 at 11:02
  • This is very basic @CalvinRichard `ui -> progressBar -> setValue(variable);` You have to use this only, you no need to create anything. Check http://doc.qt.io/archives/qt-4.8/signalsandslots.html for creating signal and slot. If you are asking everything without doing anything, this is not the right place. – Jerwin Prabu Apr 16 '18 at 11:10