0
\$\begingroup\$

enter image description hereI have an IoT project with the raspberry pi as the microcontroller. Now my device connects with the power supply of a truck i.e. via the 24-volt cigarette lightning adapter.

The device has few push buttons which need to be detected once pressed. To power down the 24 volts - 5 volts I am using the lm2596 based buck converters. Push-button is detected once the GPIO pin is set high i.e. by default they are set low.

Now what I have observed is sometimes the push button gets automatically detected without any pressing. This happens very less but still, it's a major drawback for me. How can I solve this? What is the issue here? Because if my circuit was wrong then this should happen regularly but it doesn't. If this is a voltage ripple problem, how can I solve it?

EDIT: Added the schematic diagram(I have not attached the resistors as shown in the diagram). I have a basic layout for the push buttons with a total of 6 push buttons attached. The input pins for receiving the signal from the push button on the raspberry pi are set to LOW(GPIO.pul i.e. button callback function will activate once the pin goes from low to high. This is the code written for that

GPIO.setup(dumpbutton,GPIO.IN,pull_up_down = GPIO.PUD_DOWN) GPIO.add_event_detect(dumpbutton,GPIO.RISING,callback=dump_button_callback,bouncetime=500)

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Please add schematics. It’s very difficult to help you otherwise. \$\endgroup\$
    – StarCat
    Apr 5, 2020 at 13:17
  • \$\begingroup\$ I could guess that your configuration needs a pull-down resistor which is missing or too high in value. But please provide schematics to help us understand your circuit. \$\endgroup\$ Apr 5, 2020 at 13:33
  • \$\begingroup\$ @StarCat I have added the schematics. Kindly ignore the resistors as I have not used them. As you can see it's a very basic schematic. \$\endgroup\$ Apr 5, 2020 at 14:20
  • \$\begingroup\$ @MichaelKarcher I have updated my question. Kindly have a look \$\endgroup\$ Apr 5, 2020 at 14:21

1 Answer 1

0
\$\begingroup\$

It seems you got the basic connection right: You switch the 3.3V supply to the GPIO pins, and you have the internal pull-down resistor enabled, so the pin is pulled low unless something actively supplies current into the pin (in your case, the switch).

The internal pull-down resistor of the Raspberry Pi is 50kOhm, so you do not need a lot of current to make the input high. It is quite likely that you can get enough current through interference to create a false rising edge, especially if there are some inches of wire between the Pi and the button, and especially if you are in an electrically noise environment. My first attempt would be to provide an external pull-down resistor (as shown in the diagram you provided) of 1kOhm to 2kOhm instead of (just) the internal pull-down resistor of 50 kOhm (lower numbers are stronger). The diagram shows 10k resistors, which are OK in a controlled environment, but in a truck a lower pull-down value is recommended for better interference suppression.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for explaining so well. I will definitely try this. \$\endgroup\$ Apr 5, 2020 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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