Raspberry Pi 3 with Grove Relay issue

Hi there,

My setup;

Raspberry pi 3 with Grove Pi+ using ultrasonic sensor and relay. I have the raspian installed and software is installed to make the grovepi+ work. I have tested following few examples.

This is the relay I am using;

My code is very simple. I am reading the values from the ultrasonic sensor and at the specific distance triggering the relay ON or OFF.

Basically, just combined these two examples;

I am using an external adapter that is providing 5V, 2A to RPi.

The idea is that I will use ultrasonic sensor to check how much water is left in the tank and then based on that information will turn ON or OFF the water pump. I have a small pump for aquariam that takes AC 230 input and rated 8 W.

Here is the issue now;

Whenever I test my program without connecting the pump to the realy everything works fine. Btw I have tested couple of relays.

When I connect the pump with the relay, what happend is when the realy turns ON the pump starts and I can see distance on the Pi screen which I am printing. BUT when I turn OFF the relay my Pi screen goes dark for a second and comes back, the program freezes and the RST LED turn ON on the GrovePi shield. I then have to restart my Pi to make the program work again.

Any help in this direction will be really appreciated.

Just noticed one more thing. If i am explicitly making the D7 in my case as ‘OUTPUT’, don’t you think when I read the gpios that pin should be identified as OUT not IN, see screenshot below;

Hmm, that’s acting as if the GrovePi loses the power for a split second. Can you try replacing the pump with something that uses a lot less power?

What I’m trying to see is if it’s due to how much power the pump has to draw.

Any time I hear of a problem with turning off motors I think about a shock the teacher box I made as a kid - when the power is disconnected a coil dumps a powerful spike back down the wires.

Robert, I have initially thought the same thing. But then the problem is lets assume that is the case and if I take say a lamp and i will not have this problem. This will still not solve my problem because I will be driving an AC motor/pump with this realy anyways as that is the main part of project.
But I am going to try with a lamp anyways.

Any thoughts?


I have tried a normal table lamp that also takes AC as input. The behaviour is somewhat inconsistent. Usually it is working but sometimes it hangs and the RST LED goes red. I then reset and try again and often it works. Whenever it hangs the screen remains the same unlike the case when I was using the pump.
Seems like the pump is drawing too much current (impulse) that is the problem?

Perhap watch this tutorial and note the “Relay Snubber” circuitry for inductive loads (motors):

Would like to hear what ultimately solves the problem. Keep us updated.