I want to use the internall pull down resistor. In python the setup method accepts a parameter for that, like:

GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)

according the rpi-gpio.js documentation the setup looks like it:

setup(channel [, direction, edge], callback)

and the description says:

Sets up a channel for read or write. Must be done before the channel can be used.

channel: Reference to the pin in the current mode's schema.

direction: The pin direction, pass either DIR_IN for read mode or DIR_OUT for write mode. Defaults to DIR_OUT.

edge: Interrupt generating GPIO chip setting, pass in EDGE_NONE for no interrupts, EDGE_RISING for interrupts on rising values, EDGE_FALLING for interrupts on falling values or EDGE_BOTH for all interrupts. Defaults to EDGE_NONE.

callback: Provides Error as the first argument if an error occurred.

So ... what about the pull resistors ???

  • Possibly you should have a look at the documentation for GPIO.PUD_UP, if any, although this seems fairly self-explanatory. – goldilocks Mar 1 '17 at 8:50
  • Having looked at the repo it appears this is an unsupported feature. – Steve Robillard Mar 1 '17 at 9:23
  • 1
    @goldilocks there is no GPIO.PUD_XX on rpi-gpio.js. The example that I posted (and actually used) is from Python. There is no problem using it. The problem is that there is no equivalent in rpi-gpio.js – javirs Mar 1 '17 at 12:08
  • If your hardware is permanent you can configure the the gpios with a device tree overlay. – PaulF8080 Mar 3 '17 at 0:45
  • @PaulF8080 Sorry for the delayed comment. I was doubling on nmaas87 answer but it failed. My HW is permanent so .. can you lead me to a good source on the tree overlay solution?? – javirs Mar 12 '17 at 11:33

As you answered yourself - there is currently no way in using these resistors with rpi-gpio.js - unless someone expands the code. Most probably would need to provide a binding to some c program which then would access the gpio pins directly, as this option cannot be achieved via simple access to /sys (see here: https://raspberrypi.stackexchange.com/a/36582/36367).

EDIT: There are other libs out there which claim to be able to use node.js and the requested feature. One of those seems to be raspi-gpio which can be found here: https://github.com/nebrius/raspi-gpio Maybe you want to give it a try? :)

| improve this answer | |
  • can I just call shell commands from the nodejs server and use any of those methods your link suggest? – javirs Mar 1 '17 at 17:46
  • @javirs I think I found something useful, I edited my answer :) – nmaas87 Mar 1 '17 at 19:15
  • The idea was TOTALLY worth it but after trying it for a while an getting in close contact with the author of the module. We did not manage to get it to run... Do you know other library claiming to manage the feature ? – javirs Mar 12 '17 at 11:31
  • PS: here the link of the issue I opened github.com/nebrius/raspi/issues/7 – javirs Mar 12 '17 at 11:31
  • @javirs I am not directly aware of other libraries, which does not mean that they don't exist :). I would encourage you to use google :). – nmaas87 Mar 13 '17 at 13:02

I've got this working example for a reboot button using a momentary switch on pin 11 and GND. Makes use of pull up and waits for falling edge.

import RPi.GPIO as GPIO
import os
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.wait_for_edge(11, GPIO.FALLING)
os.system("sudo reboot")
| improve this answer | |
  • Wow Andy .. this is a 2 years old question .. my Pi is currently doing other stuff and I won't have the chance to test it,, Have you test if changing the pull_up_down actually affects the HW, and if this works on every port (or you have to be aware of which ones you use) I'm also interested on knowing the default pull for each GPIO – javirs Dec 18 '19 at 7:35
  • is not a ton of info.. to be honest :( – javirs Dec 19 '19 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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