I have a relay like this one Relay
I am working with it with an Arduino UNO without problems so relay it is working just fine.
I want to use it using Pi4J. To do so I have done something like this:
GpioController gpio;
GpioPinDigitalOutput pin_relay;
pin_relay = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_05, "Relay", PinState.LOW);
pin_relay.setShutdownOptions(true, PinState.LOW);
main()
{
while(true)
{
System.out.println("High");
pin_relay.high();
Thread.sleep(2000);
System.out.println("LOW");
pin_relay.low();
Thread.sleep(2000);
}
}
Note some code is not shown. Anyway, if I attach a Led to the metioned pin, it just do what it is supposed to. However, problem comes when I use the Relay. I connect 5V and GND from Raspberry and the otput to the pin. Eventhough the starting state of the pins is LOW, the relay connects and then nothing changes. The different changes from High to Low does nothing to the state of the Relay which remains connected as if the output of the pin was HIGH. I thested the voltage between the output PIN and the GND and when it is high it has 4,26V and when it is in LOW state there are 1,26V. I did the same on Arduino and when the state is HIGH it shows 5V and when the state is low it shows 0V. Do you guys think that 1,26V when LOW state is the reason why the relay is always connected? Why do I have 1,26V on the output of the pin, why not 0V like on the Arduino?
Am I doing something wrong? I am aware Arduino only outputs 3,3V on the pins so..why this 4,26 V between the output pin and gnd?
Thank you all!!