dchote / talkiepi

The talkiepi project is for a truly headless mumble client for the Raspberry Pi, utilizing static config and GPIO for status LEDs and a button for push to talk
Mozilla Public License 2.0
271 stars 107 forks source link

PTT button not functioning as described #9

Closed TLMcNulty closed 4 years ago

TLMcNulty commented 5 years ago

Installation and configuration went off without a hitch, online and participant LEDs work. I can receive no problem.

I can manually trigger the transmit LED so I know it's wired correctly and connected to the correct pin number, but closing a circuit with a button from pin 25 (the button pin) to ground does not have any effect on the software nor the LED.

GPIO.25 is set as an input pin, as I believe it has to be for rpio to use it in a pull-up capacity.

Any tips?

dchote commented 5 years ago

Hey, I've not yet experienced any issues with button presses being handled. Is this a pi zero?

TLMcNulty commented 5 years ago

It's not, it's a raspberry pi 4B.

I've done a bunch of research into pull up and down circuits and think I have enough to try troubleshooting again. I ensured the pinout I was using was correct by manually triggering the relevant pins.

It's got to be some misconfiguration in my GPIO stuff. I dug into the pin set up code and from what I can tell it looks like it's setting up a pull up pin correctly and polling it.

I'm going to try the same button and pinout with some different code that'll just print the button status. Maybe I've got a bad button.

TLMcNulty commented 5 years ago

RPi.gpio wasn't installed.

TLMcNulty commented 5 years ago

Something is definitely not consistent with this portion of my setup. Installing RPi.gpio instantly solved my issue two weeks ago but I've moved into the next portion of the build and we're back exactly to the above behavior.

I've added some debug statements. Connecting BCM #25 directly to ground does not change the button state.

Oct 14 18:32:32 car252 talkiepi[1225]: Successfully opened RPIO connection
Oct 14 18:32:32 car252 talkiepi[1225]: Getting states...
Oct 14 18:32:32 car252 talkiepi[1225]: Current state: 0
Oct 14 18:32:33 car252 talkiepi[1225]: Connected to 157.230.219.183:64738 (0)
Oct 14 18:32:33 car252 talkiepi[1225]: Welcome message: WOT Motorsports Communications
Oct 14 18:32:33 car252 talkiepi[1225]: Unable to find channel: Race Ops
Oct 14 18:32:33 car252 talkiepi[1225]: Current state: 0
Oct 14 18:32:33 car252 talkiepi[1225]: Channel 'Root' has 2 participants
Oct 14 18:32:33 car252 talkiepi[1225]: Current state: 0
Oct 14 18:32:34 car252 talkiepi[1225]: Current state: 0
Oct 14 18:32:34 car252 talkiepi[1225]: Current state: 0
Oct 14 18:32:35 car252 talkiepi[1225]: Current state: 0

I have a feeling this is again related to how this portion of the gpio stuff is set up but I'm not sure.

TLMcNulty commented 5 years ago

Setting a pull-up resistor on pin 25 is designed to pull the pin to VCC. My pin 25 is not showing any current.

TLMcNulty commented 5 years ago

Sanity check me. Earlier when I said RPi.gpio wasn't installed I was referring to the python package. Given that this is go it'd be nonsense if that were to have any impact. This doesn't have any dependancies on python libraries does it? If not, what would that package have touched that kicked this into working?

TLMcNulty commented 5 years ago
    fmt.Printf("Setting pin %v high for testing...\n", ButtonPin)

    ButtonPinPullUp := rpio.Pin(ButtonPin)
    //ButtonPinPullUp.Pull(rpio.PullUp)

    ButtonPinPullUp.Output()
    ButtonPinPullUp.High()
    res := ButtonPinPullUp.Read()  // Read state from pin (High / Low)
    fmt.Printf("Button state: %v\n", res)
    fmt.Printf("Sleeping for 15 seconds...\n")
    time.Sleep(15 * time.Second)

    fmt.Printf("%v\n", ButtonPinPullUp)
    //rpio.Close()

    fmt.Printf("Sleeping for 15 seconds...\n")
    time.Sleep(15 * time.Second)
    fmt.Printf("Opening gpio.NewInput\n")

    // unfortunately the gpio watcher stuff doesnt work for me in this context, so we have to poll the button instead
    b.Button = gpio.NewInput(ButtonPin)
    go func() {
Oct 14 20:30:48 car252 systemd[1]: Started Mumble Client.
Oct 14 20:30:48 car252 talkiepi[3825]: Setting pin 25 high for testing...
Oct 14 20:30:48 car252 talkiepi[3825]: Button state: 1
Oct 14 20:30:48 car252 talkiepi[3825]: Sleeping for 15 seconds...
Oct 14 20:31:03 car252 talkiepi[3825]: 25
Oct 14 20:31:03 car252 talkiepi[3825]: Sleeping for 15 seconds...
Oct 14 20:31:18 car252 talkiepi[3825]: Opening gpio.NewInput
Oct 14 20:31:18 car252 talkiepi[3825]: 0
Oct 14 20:31:18 car252 talkiepi[3825]: Connected to 157.230.219.183:64738 (0)
Oct 14 20:31:18 car252 talkiepi[3825]: Welcome message: WOT Motorsports Communications
Oct 14 20:31:18 car252 talkiepi[3825]: Unable to find channel: Race Ops
Oct 14 20:31:18 car252 talkiepi[3825]: 0
Oct 14 20:31:18 car252 talkiepi[3825]: Channel 'Root' has 2 participants
Oct 14 20:31:19 car252 talkiepi[3825]: 0

Something is happening in b.Button = gpio.NewInput(ButtonPin)

TLMcNulty commented 5 years ago

I'm questioning my understanding of pull-up resistors at this point. I don't think it's NewInput in gpio.go though, as I stated above.

    if err := rpio.Open(); err != nil {
        fmt.Println(err)
        b.GPIOEnabled = false
        return
    } else {
        b.GPIOEnabled = true
    }

    ButtonPinPullUp := rpio.Pin(ButtonPin)
    ButtonPinPullUp.PullUp()

    res2 := ButtonPinPullUp.Read()
    fmt.Printf("Read after pull-up: %v\n", res2)
user@host:~ $ ~/executable
Read after pull-up: 0

Should the pin read 1 or 0 after having the pull up resistor set?

MarcusWolschon commented 5 years ago

I'm not sure that reading it right after the call to .PullUp() will already read the new value. Try waiting 10ms.

TLMcNulty commented 5 years ago

That's an excellent suggestion. I'll test that this evening.

TLMcNulty commented 5 years ago

Behavior is the same.

user@host:~ $ ~/bin/executable
Read after pull-up: 0
    ButtonPinPullUp := rpio.Pin(ButtonPin)
    ButtonPinPullUp.Pull(rpio.PullUp)
    time.Sleep(10 * time.Millisecond)
    res2 := ButtonPinPullUp.Read()
    fmt.Printf("Read after pull-up: %v\n", res2)
TLMcNulty commented 5 years ago

Maybe not applicable in all cases, and also maybe a problem limited to me, but setting a pin to pull-down and connecting it to VCC IS detected. I'm swapping the logic around to make that a workaround, I'm down to the wire on this project.

gadjodilo83 commented 4 years ago

Möglicherweise nicht in allen Fällen zutreffend und möglicherweise auch ein auf mich beschränktes Problem, aber das Setzen eines Pins zum Herunterziehen und Anschließen an VCC IS wurde erkannt. Ich tausche die Logik aus, um dies zu umgehen. Ich bin bei diesem Projekt an der Reihe.

I have the same problem with the Raspberry Pi 4 with Buster light.

have you found a solution?

Thanks Marc

TLMcNulty commented 4 years ago

Have you tried setting the pin to pull down instead of pull up as I suggested in my last comment? You'll have to connect the pin to voltage instead of ground.