I've got a Wemos D1 mini and a GY-521 accelerometer (MPU6050).
I have connected SCL to D1 (GPIO5) and SDA to D2 (GPIO4).
My GY-521's LED is ON, my D1's LED is also ON.
Here's what I get when trying to scan:
>>> from machine import I2C, Pin
>>> i2c = I2C(scl=Pin(5), sda=Pin(4))
>>> i2c.scan()
[]
I have no idea what can go wrong here and am quite stuck 
If anyone has an insight, this would be very helpful! 
Thank you all
Please see a picture of my circuit attached.
In order,
Blue: gy.VCC to d1.5V
Red: gy.GND to ground
White: gy.SCL to d1.D1 (gpio5)
Yellow: gy.SDA to d1.D2 (gpio4)
Green: d1.GND to ground
(here gy refers to the accelerometer, d1 to the esp8266)
What am I doing wrong?
Please indulge: I'm new to electronics, this is my first project, I start from scratch.
The I2C connections absolutely require pullup resistors, typically 4.7K to 3.3V only, for the MPU-6050.
If the Wemos D1 mini is a 5V system (I'm not familiar with it), there will be a problem.
jremington:
The I2C connections absolutely require pullup resistors, typically 4.7K to 3.3V only.
If the Wemos D1 mini is a 5V system (I'm not familiar with it), there will be a problem.
I think it's a 3.3V system, but it's ok with receiving a 5V current (through usb).
I'v tried connecting gy.VCC <-> d1.3V3 (instead of gy.VCC <-> d1.5V) but it doesn't change the output of i2c.scan()...
You will have to check if pullup resistors are present, either on the MPU-6050 board or on the D1. I2C won't work without them.
Ok guys I made progress.
I directly linked d1.GND and gy.GND, as sycatcher2k suggested (thanks!).
Here's where I'm at
>>> from machine import I2C, Pin
>>> i2c = I2C(scl=Pin(5), sda=Pin(4))
>>> i2c.scan()
[81]
>>> i2c.start()
>>> i2c.writeto(0x51, bytearray([107, 0]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 19] ENODEV
>>> i2c.scan()
[]
>>> i2c.stop()
>>> i2c.scan()
[81]
I'm attempting to write at addr 0x51 (hexadecimal value of 81) but it fails.
According to the error message, this command is not understand by your software:
i2c.writeto(0x51, bytearray([107, 0]))
Check the documentation for proper construction.
I don't think the ENODOV error means a problem in the code
(I'm using micropython btw)
I noticed something odd
>>> i2c.scan()
[81]
>>> i2c.scan()
[]
>>> i2c.scan()
[]
>>> i2c.scan()
[81, 82]
>>> i2c.scan()
[81]
>>> i2c.scan()
[]
>>> i2c.scan()
[]
>>> i2c.scan()
[]
>>> i2c.scan()
[]
>>> i2c.scan()
[]
>>> i2c.scan()
[81]
>>> i2c.scan()
[]
>>> i2c.scan()
[81]
>>> i2c.scan()
[]
When successively scanning, sometimes it sees nothing... Something's wrong here I guess?
You edited your post. The error message currently in reply #6 is different than the error message to which I responded.
Good luck with your project.
jremington:
You edited your post. The error message currently in reply #6 is different than the error message to which I responded.
Good luck with your project.
Ah yes, sorry you're right, it was just an error from my REPL session that I had included by error!q`
Wawa
12
Did you tell the I2C library which pins you are using on the WeMos.
Wire.begin(D2, D1); // data and clock pins used
Leo..
srnet
13
There is a support forum for the ESP8266 and MicroPython;
ESP8266 and MicroPython