I2C.scan() only returning 1 address in chain

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
ESpy
Posts: 7
Joined: Sun Jun 28, 2020 6:58 am

I2C.scan() only returning 1 address in chain

Post by ESpy » Sun Jun 28, 2020 9:30 am

Hi all -

I'm running a WEMOS D1 mini clone, with a BMP280 (temp/humidity sensor) & a GY521 (accelerometer) attached on a breadboard.
GPIO 4 & 5 (SDA & SCL respectively) are being used as sw I2C; 4k7 pullups (to 3V3...) on both lines. Bus speed set to 400kHz.
If only one device is connected to the I2C bus, I2C.scan() reads back the ID of the device with no issues.
If both devices are connected, only one ID is read back.

Any thoughts on what I'm missing? I've searched, but not found anything that seems relevant. Total bus length is about 10cm with jumper wires which ought to be fine.

TIA!

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: I2C.scan() only returning 1 address in chain

Post by Roberthh » Sun Jun 28, 2020 9:54 am

As first attempt please Check the cables and the breadboard.
Which one of the two is detected?

ESpy
Posts: 7
Joined: Sun Jun 28, 2020 6:58 am

Re: I2C.scan() only returning 1 address in chain

Post by ESpy » Sun Jun 28, 2020 10:55 am

Pulled all the jumper wires, swapped them out for different ones. I've been disconnecting the slaves by pulling VCC from them, so the logic lines are still there.

Currently it's the GY521 being detected, which is physically 2nd in the chain. Pull power from it & the BMP280 is detected; repower and it's the GY521 again.

jomas
Posts: 59
Joined: Mon Dec 25, 2017 1:48 pm
Location: Netherlands

Re: I2C.scan() only returning 1 address in chain

Post by jomas » Sun Jun 28, 2020 11:26 am

ESpy wrote:
Sun Jun 28, 2020 10:55 am
Pulled all the jumper wires, swapped them out for different ones. I've been disconnecting the slaves by pulling VCC from them, so the logic lines are still there.

Currently it's the GY521 being detected, which is physically 2nd in the chain. Pull power from it & the BMP280 is detected; repower and it's the GY521 again.
Are you sure that both devices have different I2c adresses?
If not, you should change one of them.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: I2C.scan() only returning 1 address in chain

Post by Roberthh » Sun Jun 28, 2020 11:45 am

Maybe the combined pull-up resistance of both breakouts gets too low. In the pictures of the GY521 I find on the web the pull-up is 2k2 Ohm (the schematics say 4k7 Ohm). The BME280 has pull-ups too. But the ones I have carry 10k pull-ups, lowering it to 1k8 Ohm, which should still be fine. Are both sensor operating at 3.3V?
P.S.: The address of the MPU6050 on the GY521 is 0x68 or 0x69, the base address of the BME280 is 0x76

ESpy
Posts: 7
Joined: Sun Jun 28, 2020 6:58 am

Re: I2C.scan() only returning 1 address in chain

Post by ESpy » Sun Jun 28, 2020 2:28 pm

From inspection, it looks as though the BMP280 has 10k pullups while the GY521 has 2k2 (I'm assuming here, I ought to buzz them out & double check). Both modules are running off 3V3.

Interestingly... Having pulled everything apart and rewired it, I2C.scan() is now reporting addresses 0x08..0x77 inclusive regardless of which 1 device is connected to it. I think I might try another 8266 module for the sake of my sanity.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: I2C.scan() only returning 1 address in chain

Post by Roberthh » Sun Jun 28, 2020 2:32 pm

The latter happens if SDA is low all the time.

ESpy
Posts: 7
Joined: Sun Jun 28, 2020 6:58 am

Re: I2C.scan() only returning 1 address in chain

Post by ESpy » Fri Jul 03, 2020 10:46 am

And after all that, I've found the problem. Should have buzzed it out sooner; it was down to a faulty jumper wire...

Post Reply