-
• #2
The MCU internal pullups are not nearly as strong as is specified by the I2C spec. (The same is true on Arduino - it's not as far off, but it's still out of spec).
You might be able to get the desired behavior by setting the appropriate registers with poke - but as I said above, I don't expect it would work.
I always use external pullups when working with I2C.
-
• #3
If you accept to set up a reduced I2C speed, such as <10kHz, the internal pull-ups should work well. Anyway, as @DrAzzy said, the best solution is by far, connecting external pull-ups, as you don't want to encounter I2C errors, they are rather boring to handle.
Be careful by using the poke method (http://www.espruino.com/Reference#l__global_poke32), this is not safe at all... -
• #4
I remember having some trouble with the internal pullups for I2C, and not being able to get it to work (but that could have been on the F1-based original Espruino, not the Pico).
If you wanted to try it, you'd have to use
poke
to change the value in the pin's registers though, as I believe I2c needs to be inaf_opendrain
mode, butpinMode
won't do that while also providing a pullup.poke itself isn't desperately dangerous - you can crash Espruino so it needs a reboot, but it would be quite hard to cause physical damage.
... but in short, I'd say external pullups are easier - especially if it's just a solder jumper!
-
• #5
Thank you for the hints. First I thought it would be an Espruino/JavaScript API question and totally forgot to think about the electrical part.
The I²C specification says that the minimal pull-up is a little less than 1k with Vdd=3.3V and the maximum value depends on bus capacitance. Many breakouts have 4.7k so it's possible to use four devices (with pullups) in parallel without breaking the spec.
There is detailed application note from TI: http://www.ti.com/lit/an/slva689/slva689.pdf
On the other side I have to use a much lower value than the typical 40k MCU-internal resistors for 400kHz - I understand now.
So I found my stability problem with the MCP9808 http://www.espruino.com/MCP9808. My sentence
The sensor can handle bitrates up to 400000 but I had stability problems with this.
can be removed from the documentation.
BTW: Why are there "°"s instead of ° on the website?
Again, thanks for the Tips.
-
• #6
take a look at this test results with different pull up resistors
http://dsscircuits.com/articles/effects-of-varying-i2c-pull-up-resistors
-
• #7
Glad you got it sorted!
I've just filed a bug for the strange degree symbol - I think it's a UTF-8 issue on the website.
Hi,
I'm using the temperature and humidity I²C sensor HTU21D in my current experiments. The bought Sparkfun HTU21D breakout had no prewired pull-up resistors on SCL or SDA. They are on the board but initial not connected. To enable I could bridge a solder jumper. Ok, long background...
I would prefer to use the MCU-internal pull-ups and tried the following code which does not work:
Is this possible to use the MCU-internal pull-ups with i2c or can they only be used for simple input pins?