Page 2 of 3

Re: I/O expander

Posted: Wed Aug 03, 2016 9:59 am
by joehunt588
Thank you ,now i know

Re: I/O expander

Posted: Wed Aug 03, 2016 11:24 pm
by mcauser
@joehunt588 both the SCL and SDA pins on the I2C bus need pull-up resistors (connecting each to VCC).
Why? Because when they are missing, the pins are floating (sometimes high, sometimes low).

eg. When the master scans the bus for devices, each devices pulls low to respond "hello, I'm here".
When the pins are floating, they are low at unexpected times, which confuses the master thinking devices are present when they are not.

Re: RE: Re: I/O expander

Posted: Thu Aug 04, 2016 1:24 am
by joehunt588
mcauser wrote:@joehunt588 both the SCL and SDA pins on the I2C bus need pull-up resistors (connecting each to VCC).
Why? Because when they are missing, the pins are floating (sometimes high, sometimes low).

eg. When the master scans the bus for devices, each devices pulls low to respond "hello, I'm here".
When the pins are floating, they are low at unexpected times, which confuses the master thinking devices are present when they are not.
That why i saw many address when i doing i2c.scan()
Thank for the great info,it really help me Image Image

Re: I/O expander

Posted: Thu Aug 04, 2016 7:41 am
by pythoncoder
It's a little more complex than that, but the reasons are worth grasping especially on the ESP8266 where the interface is bit-banged and can be assigned to any device pins. On the Pyboard the interfaces are assigned to specific pins which are pulled up on the board. On the ESP8266 the user picks the pins and must supply the pullups.

The reason the pullups are required is that the drivers for the scl and sda lines are (or should be) open drain drivers. This means that the driver can pull the line down, but can't pull it up: the resistor performs that duty. This eliminates any possibility of a bus line being driven high by one device while being driven low by another, which can lead to tears before bedtime. Further, the fact that more than one device can simultaneously drive a line low is used by the interface for at least two purposes.

The first is clock stretching where the master pulls the clock low, and the slave reads its state and holds it low until it is ready. The second is multi-master arbitration. The spec allows for the situation where two masters simultaneously try to use the bus and provides an ingenious method of arbitration.

The drawback is that pulling a line up with a resistor is slower than using a transistor. How much slower depends on the capacitance of the line, which increases with length and with the number of attached devices. I2C is only suitable for use over very short distances - normally between devices on a single PCB.

Re: I/O expander

Posted: Thu Aug 04, 2016 8:07 am
by deshipu
pythoncoder wrote:It's a little more complex than that, but the reasons are worth grasping especially on the ESP8266 where the interface is bit-banged and can be assigned to any device pins. On the Pyboard the interfaces are assigned to specific pins which are pulled up on the board. On the ESP8266 the user picks the pins and must supply the pullups.
That's why I like to use gpio0 and gpio2 for i2c, as those need to have built-in pull-ups on development boards, to make sure the esp8266 boots into the correct mode.

Re: I/O expander

Posted: Fri Aug 05, 2016 1:20 am
by joehunt588
Hi guy thanks so much helping me ,now i can read i2c n control mcp23017

Re: I/O expander

Posted: Thu Dec 08, 2016 8:42 am
by Rajath Kumar K S
[quote="joehunt588"]Hi guy thanks so much helping me ,now i can read i2c n control mcp23017[/quote]

Hello joehunt588,

Can You Please share the Design of yours, What is the Pull Up Resistor Value that you're using ?

Thank You,

Re: I/O expander

Posted: Sat Dec 10, 2016 8:15 pm
by joehunt588
Rajath Kumar K S wrote:
joehunt588 wrote:Hi guy thanks so much helping me ,now i can read i2c n control mcp23017
Hello joehunt588,

Can You Please share the Design of yours, What is the Pull Up Resistor Value that you're using ?

Thank You,
Hello Raj ,sorry for late reply ,i using 10k resistor for pull up,both scl and sda from i2c i install the resistor

Re: I/O expander

Posted: Sat Dec 10, 2016 8:21 pm
by joehunt588
Image

Sent from my ASUS_T00J using Tapatalk

Re: I/O expander

Posted: Mon Jul 10, 2017 5:10 pm
by cefn
I have put together a library for MCP23017 and MCP23008 running on Micropython.

It has only so far been tested on ESP8266 with MCP23017 as I don't have a 23008, but seems functional.

It's based on the Adafruit library for Raspberry PI, but with everything swapped over for Micropython...

See https://github.com/ShrimpingIt/micropython-mcp230xx