TransWikia.com

GPIO pin PULL_DOWN would

Raspberry Pi Asked by CronbachAlpha on December 30, 2020

I have set up a Arduino to send a 3.3V signal to my RPi if an object is detected in front of the UltraSonic sensor. I have measured the signal at 3.26V. But it does not work.

Since the signal from the Arduino is 5V and the RPi GPIO pins needs 3.3V, I am using a voltage divider to get 3.3V (measured to 3.26V).

I have tested the program with a button and the Raspberry Pi´s own 3.3V pin, and the state changes are detected, so the program works. I am using Pi4J.

So my question is, why are not the state changed when I use the Arduino to sende the signal?

Here is my code on the RPi (Written in Java):

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalInput;
import com.pi4j.io.gpio.PinPullResistance;
import com.pi4j.io.gpio.RaspiPin;
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent;
import com.pi4j.io.gpio.event.GpioPinListenerDigital;

public class ButtonTest{

        public static void main(String[] args) throws InterruptedException{

                final GpioController gpio = GpioFactory.getInstance();

                final GpioPinDigitalInput myButton = gpio.provisionDigitalInputPin(RaspiPin.GPIO_06, "MyButton", PinPullResistance.PULL_DOWN);

                myButton.addListener(new GpioPinListenerDigital(){

                        @Override
                        public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event){

                                System.out.println("GPIO State change: " + event.getPin() + " = " + event.getState());

                        }

                });

                System.out.println("...");

                while(true != false){

                        //Thread.sleep(500);

                }

        }

}

I also have an image of the setup, the only difference is that I take the wire going to the terminal (where I measure) to the GPIO pin #6 on the Raspberry Pi.

enter image description here

Hope someone can give me some answers, thanks!

One Answer

If the software works when you replace the Arduino wire with a Pi wire that leaves two possibilities,

  1. the Arduino wire high voltage is less than 2.5V, or
  2. the Pi's ground is not connected to the Arduino ground.

In this particular case it was the connection of GND of the Pi and the Arduino.


per these comments: 1 and 2

Answered by Ghanima on December 30, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP