1

I have a problem with the control of the GPIOs.

The ports are automatically active and the LED turn on as soon as I initialize them as "outputs". The modification of the values has no influence on the LED status.

First try with the console:

  1. export the GPIO:

    sudo echo 16 >/sys/class/gpio/export

  2. Change the GPIO to OutPut:

    cd /sys/class/gpio/gpio16

    sudo nano direction

    (Change the value from "in" into "out" and save it)

    ==> GPIO status is changing directly to active 3,3V and the LED turns on.

  3. Change the GPIO status by changing the Value:

    sudo nano value

    (Modify from "0" to "1" or from "1" to "0" an save the file)

    ==> The stauts of the GPIO is not changing and the LED is constantly turned on. It is not possible to turn it off.

2. try with a Python script:

import RPi.GPIO as GPIO
 import time
 GPIO.setmode(GPIO.BCM)
 pins = [16,26]
 GPIO.setup(pins, GPIO.OUT)

 for pin in pins :
    GPIO.output(pin, GPIO.HIGH)
    time.sleep(1)   
    GPIO.output(pin, GPIO.LOW)
    time.sleep(1)
    if not GPIO.input(pin):
       print("Pin "+str(pin)+" is working" )
    time.sleep(1)

 time.sleep(1)
 GPIO.cleanup()

When I run this script there is the same problem. The LEDs turn on at the initialization "GPIO.setup(pins, GPIO.OUT)" and stay active untill the end and turn off at "GPIO.cleanup()". The value High and Low have no influence and no switching is happening.

What I am doing wrong? I have the same script running on my old Raspberry 2 and there it is running. But now on my new Raspberry 3 I suddenly have these problems.

I guess there are some drivers, programs or settings missing. Does anybody know what to do?

Thanks a lot in advance, Mathias

enter image description here

  • There is no material difference in GPIO operation between the Pi2 and Pi3. If you used this set-up on the Pi2 that suggests you have wired something wrong. Perhaps you need to put the Pi2 back and check it still works. The LEDs on a relay reflect the relay circuitry. Not all relays are active high inputs. – joan Jul 26 '16 at 16:01
1

It's a bit hard to know what you are doing wrong.

I suggest you try the following

sudo pigpiod       # Start the pigpio daemon.

pigs m 16 w m 26 w # Set GPIO16/26 to mode OUTPUT.

pigs w 16 1        # Set GPIO16 high.
pigs r 16          # Read GPIO16.
pigs w 16 0        # Set GPIO16 low.
pigs r 16          # Read GPIO16.

pigs w 26 1        # Set GPIO26 high.
pigs r 26          # Read GPIO26.
pigs w 26 0        # Set GPIO26 low.
pigs r 26          # Read GPIO26.

Note that GPIO16 is connected to pin 36 and GPIO26 is connected to pin 37 of the expansion header.

  • After "pigs m 16 w m 26 w" both LEDs turn "ON" - pigs w 16 1 - pigs r 16 ==> LED is still ON, Output is "1" - pigs w 16 0 - pigs r 16 ==> LED is still ON, Output is "0" So the value is set correct but it has no influence on the LED status. – Mathias H. Jul 26 '16 at 14:14
  • 1
    @MathiasH. That suggests your circuit is wrong. You need to edit your question and add a photo of your Pi and the LED connections etc. – joan Jul 26 '16 at 14:50
  • Oh, thanks a lot. Can you please check this? I have added a picture into the description (please see above). The connection is acording to this webpage and it is a similar Relais board: instructables.com/id/… Vcc -> Pin4 (VCC); Gnd -> Pin6 (Gnd); Int1... -> direkt an die GPIOs; – Mathias H. Jul 26 '16 at 15:45
  • ​Hey, it is running now. I have changed the power supply from 5V to 3,3 V so that the output of the GPIO and the power supply have the same voltage. Then it is running. I will check now what circuit would be a good to add in advance to make it save running. Any advice? Thanks a lot, Mathias – Mathias H. Jul 27 '16 at 9:13
  • I am using now before each Relays this circut: ras-pi.de/wp-content/uploads/2014/07/RelaisBreadboard08.png Thanks for all who support me. Kind regards Mathias – Mathias H. Jul 27 '16 at 16:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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