Thank you for your donation!


Instruction Guide Use hardware momentary switches to control moOde
#71
I used another script, showing 0 or 1 every 0.1 second and I tested it with several GPIO, this is what I get:

Code:
1
1
0
1
0
1
1
0
1
0
1
1
0
1
0
1
0
0
1
0
1
0
1
1
0
1
0
1
1
0
0
1
1
Reply
#72
I don't have any GPIO connected devices that would make use of the feature but there are other moOde users that are using it. Maybe one of them will chime in and try to troubleshoot your particular issue.

If it turns out to be some sort of bug in moOde that can be reproduced then most likely it can be fixed.
Reply
#73
(04-13-2020, 05:11 PM)sisim Wrote: I used another script, showing 0 or 1 every 0.1 second and I tested it with several GPIO, this is what I get:

Code:
1
1
0
1
0
1
1
0
1
0
1
1
0
1
0
1
0
0
1
0
1
0
1
1
0
1
0
1
1
0
0
1
1


I'm not sure if I can help here but I believe that you had the same problem I did when I moved from Volumio. I had gpio pins 5  and 6 (default high )connected via  buttons to ground as the documentation suggested configuring for the opposite voltage as described here

The other gpio pin (13)(default low) I had conected to 3.3V.

however when I came to moode it didnt work properly .

as kent said


Quote:OK, so now I've actually read Tim's earlier reply:

Code:
Code:
GPIO.setup(sw_1_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

I haven't played with the GPIO package but I interpret this line to mean the pin is enabled as an input pin with its internal pull-up resistor (within the RPi) enabled, which means the pin is already tied to +3.3v through ca 50Kohm. If this is so, then a push button which momentarily connects the pin to +3.3v won't cause a transition.

I expect you have either to change the code to enable the pull-down resistor or to change the switch to connect to ground instead of +3.3v.

Or I could be off in left field again [Image: tongue.png]

Regards,
Kent

the code for every pin is set to pull up or (high ) when no button is pressed this stops it foating as explained in this excellent site I discovered here

This might be why you see the numbers fluctuating between 1 and 0

I would suggest that either you wire all pins you use to ground and keep using Tims script or keep your wiring that you have and change the
Code:
pull_up_down=GPIO.PUD_UP
to


Code:
pull_up_down=GPIO.PUD_DOWN

for each Gpio you have conected to 3.3V in Tims script .

although I'm not sure if Tim's script would be overwritten each time you updated Moode and you would have to chnage the value again .

I hope this helps as its something I've learned today based on reading that site regarding pins floating unless they are pulled (in software) using the internal resistors on the PI or an external pull up/down resitors is used.

Unfortunately (like many)  I didnt read the first post in this thread properly and it says


Quote:On the hardware side, you set your hardware button to connect the ground pin of your RPi with a GPIO pin of your choice

regards

Tim ( another one )
Reply
#74
Should there be a pull up/down configuration option for each pin in the GPIO Config screen or should all the pins be configured as pull down instead of pull up?
Reply
#75
(04-18-2020, 12:57 PM)Tim Curtis Wrote: Should there be a pull up/down configuration option for each pin in the GPIO Config screen or should all the pins be configured as pull down instead of pull up?

It might make an already complicated element even more complicated , I think that its nice that the GPIO config screen is rather clean and simple showing basic settings that you might need. You could however provide an advanced configuration tab in the config screen that allows changing the pull options but hides it by default.
Reply
#76
(04-18-2020, 12:57 PM)Tim Curtis Wrote: Should there be a pull up/down configuration option for each pin in the GPIO Config screen or should all the pins be configured as pull down instead of pull up?

IMHO, either make no change or change to a choice* of up or down. Otherwise the folks who already have working systems would have to make physical changes to their wiring.

Regards,
Kent

*As a hacker, I'd vote for choice but that's just for convenience. I prefer having switches ground a pin but there's no iron-clad rule I'm aware of that dictates one choice or the other.
Reply
#77
Hi everyone,

so I was still having some glitches with my setup regarding gpio problems, after a lot of research I have finally fixed it for good . I will start a fresh thread detailling my project and how I fixed issues with the gpio buttons.

here is the thread :

http://moodeaudio.org/forum/showthread.php?tid=2414

Tim I apologise if its not the best place for this thread , please move it if you think it would be better elsewhere
Reply
#78
If I want to add a few more buttons, I just have to add a few more paragraphs like this to the file,

elif str(row['id']) == '8' and row['enabled'] == '1':
       sw_8_pin = int(row['pin'])
       sw_8_cmd = row['command'].split(' ')
       GPIO.setup(sw_8_pin,GPIO.IN, pull_up_down=GPIO.PUD_UP)
       def sw_8_event(channel):
           subprocess.call(sw_8_cmd)
       GPIO.add_event_detect(sw_8_pin, GPIO.RISING, callback = sw_8_event, bouncetime = bounce_time)
       print str(datetime.datetime.now())[:19] + ' sw_8: pin=' + str(sw_8_pin) + ', enabled=' + row['enabled'] + ', bounce_time=' + str(bounce_time) + ', cmd=' + row['command']

only change the numbers to "9", "10", etc. Isnt it?
Reply


Forum Jump: