# ESP8266 not working with MPU 6050 over wire library and I2C

I'm trying to use this version of ESP8266 to access MPU 6050. However, it's not working.

https://www.amazon.com/gp/product/B07HF44GBT/ref=ppx_yo_dt_b_asin_title_o07_s00?ie=UTF8&psc=1 i.e. NodeMCU CP2102 ESP-12E

The code worked with nano very fine. However, when I tried to scan the I2C device, it's said I2C device not found.

I have tried

  Wire.begin(D2, D1);


and

  Wire.begin(4, 5);


i.e. to change the pin to GIOP 4 5 in case if the default was not working. I have also tried to put a large capacitor between the power lines, still not working.

Why ESP8266 does not work with MPU 6050?(Serial and wire together)

Updates 2: I watched the video and did what G6EJD suggested, i.e. restarted the IDE and everything. Now it's reading data. However, the data reading was somehow incorrect by a large factor. For example, at flat the device is reading

42.63/-38.37/7.82


for angle x,angle y,and angular speed z with complementary filter applied and steady at flat surface. It worked for nano but not for ESP 8266.

Also, I tried to adjust the circuit like the spectrum dandavis suggested. I tried resistor range from 4.7 k to 10, even directly connect to the power source. The attempts also included 100 $\mu$F capacitor and power board to stabilize the noise. Both pull up and pull down has been attempted as well as changing boards. However, none of those were working and the issue persisted. The pull up resistor did not seem to be response to what the device was reading.

Update 3: The power consumption has been ruled out and a pair of 100k resistor was also attempted. Not working.

• how long are the leads? do you use pullup resistors? – dandavis Feb 19 '20 at 21:07
• @dandavis the wire is about 10cm each, what's a pull up resistors? – ShoutOutAndCalculate Feb 19 '20 at 21:26
• @dandavis It didn't work even if I put in the resistor. – ShoutOutAndCalculate Feb 19 '20 at 22:53
• @dandavis I tried to adjust the circuit like the spectrum you suggested. I tried resistor range from 4.7 k to 10, even directly connect to the power source. The attempts also included 100 $\mu$F capacitor and power board to stabilize the noise. Both pull up and pull down has been attempted as well as changing boards. However, none of those were working and the issue persisted. – ShoutOutAndCalculate Feb 20 '20 at 6:18

I've been struggling with getting anything with the MPU6050's to work with either a D1 Mini or an older NodeMCU v1. I'm using D1/D2. I've used the i2cdevlib MPU6050 library as well as the Electronic Cats' version. I've used an assortment of sketches and even tried code which uses just Wire (no MPU6050 specific libs).

• The best I've been able to get is the Electronic Cats MPU6050 library, without DMP, where at least it thinks the MPU6050 has been connected to, but it just puts out 0's as raw values.
• The second "best", maybe, was some code that just used plain Wire, but except for Wire.endTransmission() returning success (and I had to slow loop() down for that), its numbers are gibberish (either 0's, or Z will just increment. Nothing is affected by the movement of the board itself).

The DMP versions always fail to initialize the DMP. I've tried 8.2k and 4.1k pullups on D1 and D2.

It works fine on an atmega32u4-based Pro Micro 16.

try to use

Wire.begin(0x68);


  Wire.begin(D2, D1);