1

I am using the Nano RP2040 with MicroPython and run the following code:

import machine
import time

p0 = machine.Pin(0, machine.Pin.IN)
while True:
    print(p0.value())
    time.sleep(0.3)

The Nano has built-in pull-up and pull-down resistors. If I do not specify machine.Pin.PULL_xx, then these built-in resistors are not activated. If they are not activated, then shouldn't the signal received be floating, i.e., shouldn't the environment interfere with the input signal and make the code above print random series of 0s and 1s on the REPL? What actually happens is the REPL prints all 0s.

I read of how input pins are interpreted as high-impedance output and while I suspect this may be the cause, I do not not understand what that means.

1
  • is the input pin connected to anything? ... what happens if you touch the pin?
    – jsotola
    Commented Aug 20, 2022 at 17:13

1 Answer 1

1

That you'll get noise on a floating input observable in the read value isn't something you can rely on. The AVR like the ATMega328P seems to readily couple house/mains frequency noise onto inputs. However, I went to demonstrate this sort of thing for someone with a NodeMCU(ESP8266) board and found it was much harder to influence.

As I understand it the RP2040 has configurable Schmitt trigger inputs with a minimum hysteresis of 0.1 * IOVDD, 330 mV minimum, I think. And that these are on by default. So your noise has to be bouncing across this threshold to affect the read value, which it may easily not be doing. If you turn off the Schmitt trigger feature, you may see more noise. I don't know how to disable them in MicroPython. The PicoSDK has a function called gpio_set_input_hysteresis_enabled that should do it.

You can also try running something like an old vacuum cleaner next to it to throw lots of noise into the environment.

For my own curiosity I may try playing with this on an RPI Pico, though perhaps not in MicroPython (we'll see) and if I do I'll show what I found.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.