gozillatm
Posts: 5
Joined: Fri Nov 24, 2017 8:00 am

Gpio inout noise and floating state

Fri Nov 24, 2017 8:17 am

Good morning,
I say that I am at the beginning with the programming of the raspberry, I come from arduino, but I am stopping on a problem that I can not solve.
I connected a floating switch to a pin, set as input, unfortunately although I have enabled pullupresistance, pin status keeps floating between 0 and 1 when not connected to vcc.
I have also tried to insert a physical pulluprersistance of 10 k, but the problem continues to persist, even several pin changes.
I use java with the library pi4j, I put the code where text the status of the pin.
FOR WELCOME TO THANK YOU.


Code: Select all

public static  void  osmoregolatore_init(Reefgui oguireef) {

		final GpioController gpioSensRabb = GpioFactory.getInstance();
		final GpioPinDigitalInput Sensrabb = gpioSensRabb.provisionDigitalInputPin(RaspiPin.GPIO_26,PinPullResistance.PULL_DOWN);
	   
		
		Sensrabb.setShutdownOptions(true);
        Sensrabb.addListener(new GpioPinListenerDigital() {
			@Override
			public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent event) {
				// display pin state on console
				// System.out.println(" --> GPIO PIN STATE CHANGE: " + event.getPin() + " = " + event.getState()+"errore: "+errore);
				if(event.getState().isHigh()) {
					System.out.println("high");
					
					statosens=1;
					
					//Statosens1Inizio=orologio.millis();  
           
				}else {
					statosens=0;
					//Statosens1Inizio=orologio.millis();
					
					System.out.println("low");
					

				}
			}

        });//*/

			}



sora03
Posts: 193
Joined: Mon Dec 29, 2014 4:11 pm
Contact: Website

Re: Gpio inout noise and floating state

Fri Nov 24, 2017 10:13 am

you should post the circuit schematic and can you to do the same in python code use the gpiozero library
FLOSS enthusiast, Debian user (linux-libre)

User avatar
joan
Posts: 14178
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Gpio inout noise and floating state

Fri Nov 24, 2017 10:19 am

A common error is not using the correct GPIO for the physical pin. Check that the numbering system being used by your software corresponds to the pin(s) you are using.

https://pinout.xyz/

gozillatm
Posts: 5
Joined: Fri Nov 24, 2017 8:00 am

Re: Gpio inout noise and floating state

Tue Nov 28, 2017 3:37 pm

Thanks to everyone, I find the matter was a bad soldered connector that bring impedence very high and cause the floating state.
Just connect the floating switch directly to raspi pin and all' work fine😊😊

Return to “Troubleshooting”