About Pull-Up resistors.

Hi all,
I wasted 2 days with a problem with an I2C expander (PCF8574) and a Nodemcu Esp8266. I wanted to read some push buttons using the interrupt from the PCF8574, but it didn’t work…
Read the datasheet, read from forums, searching on google… but the thing didn’t work. The INT pin, sometimes, was locked and the I2C bus didn’t work.
I put EVERY resistors suggested from the datasheet and nothing happens…

Suddenly, I discover a bug on the code (my fault) (a problem reading from PCF8574 in order to avoid bounces from the push button) and all start to work properly.

…then I removed, one by one, the resitors (SDA, SCL, INT) and still it works.
…then I removed all the pull-up resistors from the push-buttons and still it works.

Then my question is: ¿Is really necessary all those resistors?

Then my question is: ¿Is really necessary all those resistors

Yes they are if you want your design to work correctly under all circumstances with all hardware configurations.

Just because something appeared to function does not mean it is a reliable design.

No, they are not all needed. PCF8574 have “pseudobidirectional” pins. In Arduino terminology the pins may be only INPUT_PULLUP(*) or OUTPUT LOW. So they have pull-ups built in and if they are strong enough you don’t need external ones.
The same may be true for the I2C lines - but I know little about the ESP board so I have no idea if its pullups are strong enough and how to activate them.

(*) the pins does not have pullup resistor but pullup current source - it is likely not important here.

The same may be true for the I2C lines

No I2C lines on an Arduino Uno always need pull up resistors to work correctly. Just look at the signal on the lines without them, it is very poor.

Grumpy_Mike:
No I2C lines on an Arduino Uno always need pull up resistors to work correctly. Just look at the signal on the lines without them, it is very poor.

OP is using ESP8266. I know nothing about its pullups and I made my best to clearly state this. But it is likely the internal pullups will be weak and I2C working with them marginal. We cannot know unless we find it in the Datasheet (or better measure them).

Weak pullups are only good for on-board signals - anything from a external cable or board will need a
lower resistance to prevent noise coupling from hurting you. 50k to 100k is a weak pullup, 10k is
intermediate, 2.2k is a reasonable choice for a strong pull up for a long external cable.

In very electrically noisy environments even that may not be enough and more steps are needed to
prevent interference, but I2C bus I would recommend 10k for on-board, 4k7 off board, lower if issues
arise.

See this on I2C pull up resistors:- dsscircuits.com is for sale | HugeDomains

The page is very interesting. Note my copy of ESP8266 Technical Reference says: "Besides that, the chip has pull-up resistance inside which can help save the pull-up resistance outside." But I didn't manage to find any hint of value of this internal pull-up. I still think it is possible those pull-ups are strong enough to work as I2C pull-ups. We cannot be sure until someone finds reference or measures how strong those pull-ups are.

I still think it is possible those pull-ups are strong enough to work as I2C pull-ups.

Put it this way, if the ESP8266 has got internal pull up resistors capable of driving an I2C bus, it will be the first one out of about 40 processors I have used that could achieve this. It is highly unlikely because manufacturers want to cut down on power consumption to aid the thermal distribution in a chip and an unnecessary low resistor would upset that balance.

The information is likely to be in the absolute ratings sections of the data sheet, where it will be given as a spread between a maximum and minimum value like it is in the Atmel data sheets.

I wondered why strong enough internal pull-ups are not common part of I2C hardware. I didn't think about power dissipation problems. When ATMega sources "safe" 20mA it has 0.5V drop in the driver (from typical characteristics graph) meaning 10mW dissipation in the chip. 5kOhm pullup grounded is only 5mW so power dissipation alone cannot be the problem. Maybe having two drivers able to dissipate "so much" power at one pad makes the chip layout difficult? Or simply resistor able to dissipate this power needs to be large = expensive? Or possibly there is no single "right" I2C pull-up value and when you add process variations adding external resistors with value fitting application is the only viable way so noone sane would use internal pullups anyway (for mass produced device)?

AFAIK ESP8266 is made by an "Eastern" manufacturer and does not have as detailed datasheet as "Western" products do. Only Wiki-like collection of information is available and some documents covering some aspects of the chip written in strange English with very little electrical information.

danieletesta:
The internal pull-up resistors on the esp8266 is between 30k-100k, so I guess there is a first time for everything...

What makes you think that 30K is enough of a pull up to drive an I2C bus correctly. The I2C specification states a current is 2mA, so get real.

See what happens to the wave forms when you do not use a strong enough pull up.

Reviving quite old post here?

Grumpy_Mike:
What makes you think that 30K is enough of a pull up to drive an I2C bus correctly.

From ATMega328p datasheet:

Note that the internal pull-ups in the AVR pads can be enabled by setting the PORT bits corresponding to the SCL and SDA pins, as explained in the I/O Port section. The internal pull-ups can in some systems eliminate the need for external ones.

Sure ATMega is not ESP but...

can in some systems eliminate the need for external ones.

This statement is wrong.

If you have ever looked at the I2C waveforms on an oscilloscope you can see it has a very slow rise time. While it might function, sometimes, we get lots of post here from people who believe this and have problems. Once they fit proper pull up resistors then their system starts to work correctly.

An ESP has even higher internal pull up resistors than an AVR so is even worse. Note it can be up to 100K, with the AVR, from memory, the upper limit is about 55K.

Anyway the new post is not real, it is just some idiot who has taken offence at something I said and registers a sock puppet to try and prove me wrong. You know the type.
Only one post and he will never make another. Anyway he has already deleted his post so that clinches it.

Smajdalf:
I wondered why strong enough internal pull-ups are not common part of I2C hardware.

Because its a bus, not a point-to-point system. Busses have to share termination between all connected
devices, and typically have one ot two termination points (one at each end for a long bus).

In a bus the signals (or most of them) are paralleled (bussed) between all devices.

Grumpy_Mike:
This statement is wrong.

... While it might function, sometimes ...

You say the Datasheet is wrong and then you say exactly the same thing? They don't say it will work in any possible setup. But when you connect single device on single boards with no strong signals close to the "bus" and keep the clock speed low... Probably it is too much effort for saving two resistors but maybe sometimes it can save some routing/space problems?

You say the Datasheet is wrong

It is NOT a data sheet, it is marketing. A data sheet is a legal contract between the manufacturers and the customer. Data sheets never include the work “maybe”.

but maybe sometimes it can save some routing/space problems?

Given the size of resistors I doubt very much that this has ever happened.

Grumpy_Mike:
It is NOT a data sheet, it is marketing.

You mean the document presented on Microchip web page as "ATmega48A/PA/88A/PA/168A/PA/328/P Data Sheet" is not a data sheet but marketing"?

I don't think the data sheet directly suggests that the pull up resistors would be adequate in that particular case (I2C). Just adequate for some things.

Grumpy_Mike:
It is NOT a data sheet, it is marketing. A data sheet is a legal contract between the manufacturers and the customer. Data sheets never include the work “maybe”.

A data sheet is not a contract (believe me, I teach contract law). Representations about the properties of a product can sometimes give rise to warranties, but careful manufacturers disclaim such. For example, the Atmel data sheet for the 328P states:

Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein.

@aarg: I am sorry for the confusion. The quoted text is from 2-wire Serial Interface -> Overview of the TWI Module -> SCL and SDA pins (section 22.5.1 in my version). It is related to the I2C/TWI bus - I knew that and didn't realize it was not clear from the quoted text alone.