tristan1990
Posts: 38
Joined: Wed May 22, 2013 3:49 pm

nodeJS & GPIO Error?

Mon Jul 08, 2013 12:41 pm

Hi,

I've set up nodeJS on the Pi to do a very basic control of a GPIO pin.

When the button is pressed, the server receives it and responds with -
Error when trying to open pin 7
gpio-admin: could not flush data to /sys/class/gpio/export: Device or resource busy
Does anybody know why this happens?
Thanks

User avatar
rpdom
Posts: 14710
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: nodeJS & GPIO Error?

Mon Jul 08, 2013 12:56 pm

I think you have already exported pin 7.

You only need to do it once at the start of the program to make the pin (/sys/class/gpio/gpio7/*) available.
It might be a good idea to check if directory /sys/class/gpio/gpio7 exists first, and only write "7" to export if it doesn't.

tristan1990
Posts: 38
Joined: Wed May 22, 2013 3:49 pm

Re: nodeJS & GPIO Error?

Mon Jul 08, 2013 1:04 pm

Thanks for the reply.

I have just checked and it seems that it doesn't exist in the directory. What is the next thing to do?

Thanks

vijay_nav
Posts: 6
Joined: Thu Oct 17, 2013 11:08 am

Re: nodeJS & GPIO Error?

Fri Oct 18, 2013 12:35 pm

i am facing an error in 17 line this syntax error is
if GPIO.input(8)
please help me
# Import the required modules.
import RPi.GPIO as GPIO
import time
# Set the numbering sequence of the pins, then set pins ten and twelve to output, and pin eight to input.
GPIO.setmode(GPIO.BOARD)
GPIO.setup(10, GPIO.OUT)`**enter code here**`
GPIO.setup(12, GPIO.OUT)
GPIO.setup(8, GPIO.IN)
# Turn both of the LEDs off.
GPIO.output(10, True)
GPIO.output(12, True)
# The SwitchState variable is 1 if the button is pressed, and 0 otherwise. LEDState is 0 when off, 1 when red, and 2 when green.
SwitchState = 0
LEDState = 0

while 1:
if GPIO.input(8)
# When the LED is off, keep the green LED off, turn the red one on, then change the state of the LED to reflect that it is red, and wait one second.
if LEDState == 0
GPIO.output(10, True)
GPIO.output(12, False)
LEDState = 1
time.sleep(1)

# When the LED is red, turn the green LED on, turn the red one off, then change the state of the LED to reflect that it is green, and wait one second.
elif LEDState == 1
GPIO.output(10, False)
GPIO.output(12, True)
LEDState = 2
time.sleep(1)

# When the LED is green, turn it off, then turn the red one off, then change the state of the LED to reflect that they are all off, and wait one second.
elif LEDState == 2
GPIO.output(10, True)
GPIO.output(12, True)
LEDState = 0
time.sleep(1)

User avatar
DeeJay
Posts: 2027
Joined: Tue Jan 01, 2013 9:33 pm
Location: East Midlands, UK

Re: nodeJS & GPIO Error?

Sat Oct 19, 2013 10:11 am

@vijay_nav: Duplicate of http://www.raspberrypi.org/phpBB3/viewt ... 91#p439891, where a response has been posted.
How To Ask Questions The Smart Way: http://www.catb.org/~esr/faqs/smart-questions.html
How to Report Bugs Effectively: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html

wt1664
Posts: 1
Joined: Fri Jan 17, 2014 11:25 pm

Re: nodeJS & GPIO Error?

Fri Jan 17, 2014 11:28 pm

I have been having the same error. What I found was I was trying to set the pin to high when it was already high. I changed the value to low and no error. I will now write my code to check the current pin status.

Return to “General programming discussion”