golemparts / rppal

A Rust library that provides access to the Raspberry Pi's GPIO, I2C, PWM, SPI and UART peripherals.
MIT License
1.24k stars 98 forks source link

GPIO starts fluctating #121

Closed thinkrapido closed 3 months ago

thinkrapido commented 1 year ago

Sorry for asking this question here, but I don't see any reason, why this happens. Maybe it is an electronic issue. Please help.

I have this programm here: https://github.com/rusticus-io/sound-player/blob/main/src/main.rs

I monitor my gpio with watch -n 1 raspi-gpio get 4

Before I start the program everything works fine, but after I start my program the gpio pin starts fluctuating and I receive a is_high unnecessarily, so this projects plays sounds on and on and not only after short-circuiting V3.3 with GPIO4.

After reattaching from power supply the PIN behaves as expected again.

golemparts commented 1 year ago

If you're not using a pullup or pulldown resistor, your input pin is likely floating and returning seemingly random results. I suggest enabling the Raspberry Pi's built-in pulldown resistor by changing into_input() into into_input_pulldown() and see if that helps resolve the issue.