I want to use a MPU6050 sensor for my project with the adafruit-MPU6050 library.
I started to prototype it on a Uno for ease of connection, and everything works fine, but when I switch to my esp8266, the sensor is not found.
I runned an I2C scanner on my esp8266 , and non device is found, while if I run the scanner on my Uno, it is found on the expected 0x68 I2C address.
In order to check my I2C connection on the esp8266, I tested with another sensor I used previously (a GY-271 magnetometer) and it worked properly for both project file and I2C scanner.
The sensor breakout board has pullups resistors, I am powering everything from an external 5V battery.
I have no idea what to try next as I can't really find out what is at fault... So any suggestion would be very welcomed.
Connect the mpu6050 back to the Uno and check it still works.
If it does, the next step will be for you to read the forum guide so that the forum can help you figure out the problem.
No need to post your project code yet. First step, as you already know, is to get i2c scanner to detect it, and we already have that code.
But forum needs to know exactly what esp board you have and exactly what mpu board you have. Post links to the detailed specs of those and post a schematic showing how everything is wired, including power supplies.
It is powered by a 5V power bank ( "helped" by my computer USB port while I'm trying to receive serial for debug).
It's the exact same conditions which works with my other sensor over I2C
thanks @UKHeliBob
It is powered directly from the power bank (through a prototyping board).
Ground of the power, sensor and the board are connected together on the prototyping board. I just uploaded a schematic on my answer just above.
Also there's a led on the breakout board of the sensor, which is indicating that it is powered properly.
I can see from it's schematic that the mpu board (GY-521) has an onboard 3.3V regulator and it's SDA & SCL pins are pulled up to 3.3V with 2K2 resistors. 2K2 is a little bit low...
The ESP board looks very similar to the common NodeMCU board design. No schematic is provided (the schematic link on that page goes to a pinout diagram; the pinout link goes to another pinout diagram.) The schematic for other NodeMCU shows no pull-ups on the D1 & D2 pins which are the default i2c pins, if I remember.
So I think I've found the problem. I failed to mention earlier that I have a fairly long cable between my esp8266 and my sensor (3 meters) and when I just switched to shorter jumper cables it works just fine.
I still don't understand why it causes no problem with the uno though.
I've just read I2C is not recommended over long cable distances, but is there something I can do to increase the length it accepts? Should I try to increase the value of the pull up resistors?
The ESP8266 does not have an I2C peripheral and uses a crude, bit-banged function to replace it. This may explain the difference in performance with the Uno.