GrovePi
GrovePi copied to clipboard
Multiple Relays
We've bought three relays, and we use the following Python Class to interact with the relay (see attached file). Nothing complicated. It's just Python 3 and more object encapsulation.
The problem we have is that when we set off a relay, the two other relays also set off ! Which is not what we're expected.
For example:
r1 = Relay(5)
r2 = Relay(6)
r3 = Relay(7)
r1.on()
r2.on()
r3.off() # r1 and r2 are now off ...
We observed the same problem without the object encapsulation. And thus we suspect that the problem is coming from GrovePi.
Is it a know bug? Or is GrovePi intended to only work with one relay?
Hey @Zangror : we'll try the example that you have sent and see how it works at our end.
@karan259 : thanks! :smiley:
It could also be an hardware relay problem...
do you have some LED's . The if the LED's work on the same ports, then it might be a hardware problem. (the same code should work with the LED's too)
By led you mean: http://www.seeedstudio.com/wiki/Grove_-_LED this kind of led?
yeah, those ones. (Logically to the code they are the same)
No we don't have any leds... We only have three relays, one barometer sensor and one temperature and humidity sensor on the same GrovePi+ .
Ok. I'll try it out at my end and get back to you
Thanks in advance! :smile:
Hey @Zangror : I just tried out your test code and it does work properly. I only had 2 relays so used that with an LED and it worked properly. Can you try out this relay_test_py.txt. Can you also run https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_firmware_version_check.py and check if the firmware on the GrovePi is v1.2.2
Our firmware version is v1.2.7.
Thanks for the feedback !
In our case, we are looping several times on the relay switching. Is it possible to you to run the following code and see if there is any illogical behavior?
import time
for _ in range(0, 10):
r8 = Relay(8)
r7 = Relay(7)
r5 = Relay(5)
time.sleep(1)
r8.on()
r7.on()
time.sleep(2)
r8.off()
r5.on()
r7.off()
time.sleep(2)
r5.off()
Hey @Zangror : this script also works for me. I am not sure where the 1.2.7 firmware came from. The latest stable version that we have is 1.2.2 and the beta is also at 1.2.6. Can you try updating the firmware from here: http://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/updating-firmware/ and check the firmware version and try your example again
@Zangror Did you get a chance to try this out