SHINY_T
Posts: 4
Joined: Sun Jan 15, 2017 1:10 pm

GPIO 4 trouble

Sun Jan 15, 2017 1:40 pm

Hi,

I write there because my GPIO 4 ramdomly works.

Code: Select all

#!/usr/bin/python
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

# init list with pin numbers

pinList = [2, 3, 4, 17, 27, 22, 10, 9]

# loop through pins and set mode and state to 'low'

for i in pinList: 
    GPIO.setup(i, GPIO.OUT) 
    GPIO.output(i, GPIO.HIGH)

# time to sleep between operations in the main loop

SleepTimeL = 2

# main loop

try:
  GPIO.output(2, GPIO.LOW)
  print "ONE"
  time.sleep(SleepTimeL); 
  GPIO.output(3, GPIO.LOW)
  print "TWO"
  time.sleep(SleepTimeL);  
  GPIO.output(4, GPIO.LOW)
  print "THREE"
  time.sleep(SleepTimeL);
  GPIO.output(17, GPIO.LOW)
  print "FOUR"
  time.sleep(SleepTimeL);
  GPIO.output(27, GPIO.LOW)
  print "FIVE"
  time.sleep(SleepTimeL);
  GPIO.output(22, GPIO.LOW)
  print "SIX"
  time.sleep(SleepTimeL);
  GPIO.output(10, GPIO.LOW)
  print "SEVEN"
  time.sleep(SleepTimeL);
  GPIO.output(9, GPIO.LOW)
  print "EIGHT"
  time.sleep(SleepTimeL);
  GPIO.cleanup()
  print "Good bye!"

# End program cleanly with keyboard
except KeyboardInterrupt:
  print "  Quit"

  # Reset GPIO settings
  GPIO.cleanup()
this is the code that i used for turn on a group of relè.
All works well but, after some seconds, the relè attached to the GPIO 4 stop work.


in this video you can see the problem better
https://www.youtube.com/watch?v=KB463S9dAmQ


Sorry for my bad english.

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: GPIO 4 trouble

Sun Jan 15, 2017 2:47 pm

You are the third person in 24 hours who is struggling with that type of relay board.
But your youtube video is a very good example of showing what happens.

I assume you are not using the relay to switch anything at the moment?
So there are no other voltages/spikes which can cause trouble.

Those relay boards are design to work from a 5Volt computer.
The Pi is 3.3Volts. That MAY be a problem.
Have a look here viewtopic.php?f=42&t=170821#p1094996 what I write about that.
(voltage drop, LED, resistor, diode etc.)

However having seen your video I start to hesitate if that is the problem.
Debugging on a distance is never easy, but your video is a BIG help.
I wish more people would do that, because a picture says more then a thousand words.
If there is insufficient voltage I would expect the LEDs to be dimmed.
In your video they are very bright so it may well be that the 3.3Volts IS enough to drive the board.

You can also temporarily short-circuit the LED of the GPIO4 channel on the relay board.
(Just hold a short wire over the ends, It will not damage anything.)
If the problem goes away you know that it is a matter of low voltage.
Please let me know because there are others with the same problem.
Also check with a volt meter what the GPIO output does.

User avatar
joan
Posts: 14936
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO 4 trouble

Sun Jan 15, 2017 2:51 pm

Are you sure you haven't used the 1-wire bus in the past and left it enabled? That will muck about with GPIO4 every minute or so.

grep "w1" /boot/config.txt

SHINY_T
Posts: 4
Joined: Sun Jan 15, 2017 1:10 pm

Re: GPIO 4 trouble

Sun Jan 15, 2017 3:04 pm

Gert van Loo wrote:You are the third person in 24 hours who is struggling with that type of relay board.
But your youtube video is a very good example of showing what happens.

I assume you are not using the relay to switch anything at the moment?
So there are no other voltages/spikes which can cause trouble.

Those relay boards are design to work from a 5Volt computer.
The Pi is 3.3Volts. That MAY be a problem.
Have a look here viewtopic.php?f=42&t=170821#p1094996 what I write about that.
(voltage drop, LED, resistor, diode etc.)

However having seen your video I start to hesitate if that is the problem.
Debugging on a distance is never easy, but your video is a BIG help.
I wish more people would do that, because a picture says more then a thousand words.
If there is insufficient voltage I would expect the LEDs to be dimmed.
In your video they are very bright so it may well be that the 3.3Volts IS enough to drive the board.

You can also temporarily short-circuit the LED of the GPIO4 channel on the relay board.
(Just hold a short wire over the ends, It will not damage anything.)
If the problem goes away you know that it is a matter of low voltage.
Please let me know because there are others with the same problem.
Also check with a volt meter what the GPIO output does.

Thank for your answer.
Tomorrow i will go to school where i have a volmeter and i will check the output, then i will reply here

SHINY_T
Posts: 4
Joined: Sun Jan 15, 2017 1:10 pm

Re: GPIO 4 trouble

Sun Jan 15, 2017 3:10 pm

joan wrote:Are you sure you haven't used the 1-wire bus in the past and left it enabled? That will muck about with GPIO4 every minute or so.

grep "w1" /boot/config.txt
mmmm....i dont think its possible.

I bought my raspberry just yesterday, and this is my first project whit this rasp.

btw this is the result of your command :

Code: Select all

dtoverlay=w1-gpio

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: GPIO 4 trouble

Sun Jan 15, 2017 3:12 pm

You won't see GPIO changes on a multimeter, they happen too quickly, you need an oscilloscope.

Remove that line from config.txt and reboot, that will prevent GPIO4 being driven by the 1-wire driver.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

SHINY_T
Posts: 4
Joined: Sun Jan 15, 2017 1:10 pm

Re: GPIO 4 trouble

Sun Jan 15, 2017 3:23 pm

DougieLawson wrote:You won't see GPIO changes on a multimeter, they happen too quickly, you need an oscilloscope.

Remove that line from config.txt and reboot, that will prevent GPIO4 being driven by the 1-wire driver.

WOOOOO :D :D :D

thanks you man .... now the relay led dont stop work and all looks ok ....thanks you very much

Return to “General discussion”