Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By GengusKahn
#35857 The attached zip file is the modified "standard" MPU6050 Library, this requires the I2C_DEV library, this can be found on the github if needed.

https://github.com/DSSCircuits/I2C-Master-Library



The Library "Example" sketches have also been modified to use Pin 15 as Interrupt and start the wire library explicitly.

Install Processing (search Google) and run the "Teapot Demo" this will produce a 3D Wire Frame Plane controlled by the MPU/ESP.
The Plane will rotate for approx. 1 minute as the calibration is performed, after this the output will be 100% stable(at the least if your project is good)......

Map the data to TCP port rather than Serial for Remote feedback using UDP..........
You do not have the required permissions to view the files attached to this post.
User avatar
By picstart
#35879 I also worked on this a few weeks ago. The MPU6050 I am using is on a pcb board GY-87 along with a HMC5883 magnetometer and a BMP180 altimeter.
There are versions of I2Cdev that try too hard and meld SPI with I2Cdev....The library in the above post is the pleasant one that sports I2C only and avoids dependencies that can be unpleasant. Hardware interfaces are specific and require specific wiring and timing. Software that attempts to run on multiple hardware interfaces may be fine for a commercially manufactured pcb but can cause issues for breadboard development and MCU other than the typical Arduino ( in this case the ESP8266).

The HMC5883 doesn't appear to be fused into the DMP. The accelerometer and the rate change gyro's are fused. The HMC5883 is a slave to the MPU6050 and I am getting HMC5883 raw values from the MPU6050 with calls to getExternalSensorWord. The BMP180 is on the I2C bus and is independent.
The DMP code is difficult to follow and even though the magnetometer readings are in the MPU6050 registers they don't seem to be fused into the DMP calcs.

The MPU6050 code needed modifying to allow calibration of the HMC5883 during setup plus the reading of the magnetometer values in loop. Teapot needed modifying so the packet transferred could contain a heading value. I'm getting accurate headings from the magnetometer 0..180 but inaccurate readings 180..360. It might not be the magnetometer since due to a math issue with the Arduino IDE 1.6.5 release, I needed to replace libm.a with a smaller version to avoid the sqrt issue. It is possible arctan has issues in this smaller version of libm.a ( 1/2 the original size).
Which version of the IDE did you use?

I used telnet to get a wireless link to teapot can you expand upon

"Map the data to TCP port rather than Serial for Remote feedback using UDP.........."

Did you use the Arduino esp8266 as the server or as the client ..did you reject telnet as a solution?
User avatar
By reaper7
#35898 btw .... what is wrong with "official" arduino MPU6050 & I2Cdev libraries from:
https://github.com/jrowberg/i2cdevlib/tree/master/Arduino
??
For me works as expected.

only changes:
Code: Select all#include <avr/pgmspace.h>
to
Code: Select all#ifndef ESP8266
#include <avr/pgmspace.h>
#else
#include <pgmspace.h>
#endif
inside MPU6050.h, MPU6050_6Axis_MotionApps20.h, MPU6050_9Axis_MotionApps41.h

result from MPU6050_DMP6 example:
Code: Select allypr   145.32   10.33   39.51
ypr   145.32   10.34   39.52
ypr   145.33   10.34   39.54
ypr   145.32   10.34   39.55
ypr   145.31   10.36   39.56
ypr   145.31   10.35   39.56
ypr   145.31   10.32   39.56
ypr   145.31   10.30   39.55
ypr   145.33   10.30   39.56
ypr   145.35   10.29   39.58
ypr   145.37   10.29   39.60
ypr   145.37   10.30   39.60
ypr   145.37   10.31   39.60
ypr   145.35   10.31   39.58
ypr   145.34   10.30   39.57
ypr   145.34   10.30   39.56
ypr   145.35   10.31   39.56
ypr   145.36   10.31   39.57
ypr   145.37   10.30   39.59
ypr   145.39   10.29   39.60
ypr   145.42   10.28   39.62
ypr   145.42   10.27   39.63