Hi
I just got my Qwiic Quad Relay (https://www.sparkfun.com/products/15102) and connected it with Raspberry Pi 3 and wrote code with Python 3. I checked commands from Arduino example and first it seemed to work but at times there is strange behaviors. Some times status says that relay is ON, but it really is OFF. So my code tries to toggle it to “OFF” but then it is set ON :!: :!: :!: Some times I have seen relays to blink even if there is no activity in i2c bus!!??
I noticed there is no pullup resistors, so I added first 1.8k but same happened.
Then I saw this issue viewtopic.php?f=105&t=50806&p=207512&hi … ay#p207512 and changed my resistors to 8.2k (closest to 10k that I have) but same thing. I soldered the address jumber close but nothing changed (except the address).
At first I was using adafruit’s i2c library but then I wrote test code with SMBus:
import smbus
i2c_ch = 1
address = 0x6c
RELAY_ONE_STATUS = 0x5
bus = smbus.SMBus(i2c_ch)
count = 10000
r1_on = 0
r1_off = 0
r1_unknown = 0
error = 0
ON = 0xf
OFF = 0
state = OFF
#Turn all off
bus.write_byte(address, 0xA)
print("Test 10")
for i in range(count):
try:
state = bus.read_byte_data(address, RELAY_ONE_STATUS)
except:
error += 1
continue
if state == ON:
r1_on += 1
elif state == OFF:
r1_off += 1
else:
r1_unknown += 1
print(f'On: {r1_on}, Off: {r1_off}, Unknown: {r1_unknown}, Error: {error}')
And here is the result:
>>> %Run relay_test.py
Test 1
On: 0, Off: 9212, Unknown: 788, Error: 0
>>> %Run relay_test.py
Test 2
On: 5956, Off: 3291, Unknown: 750, Error: 3
>>> %Run relay_test.py
Test 3
On: 6173, Off: 3061, Unknown: 763, Error: 3
>>> %Run relay_test.py
Test 5
On: 4595, Off: 4603, Unknown: 800, Error: 2
>>> %Run relay_test.py
Test 6
On: 0, Off: 9164, Unknown: 835, Error: 1
>>> %Run relay_test.py
Test 7
On: 3778, Off: 5583, Unknown: 638, Error: 1
>>> %Run relay_test.py
Test 8
On: 0, Off: 9379, Unknown: 621, Error: 0
>>> %Run relay_test.py
Test 9
On: 3965, Off: 5380, Unknown: 654, Error: 1
>>> %Run relay_test.py
Test 10
On: 0, Off: 9319, Unknown: 680, Error: 1
>>>
As you can see, on test 1, 6, 8, 10 status is unknown 7-10% at the time (many times the result value was 127). On the other tests, relays switched state during the test, don’t know why. During these tests, there was no other devices at the bus.
So is there someting I should know when trying to use Raspberry with Qwiic system (some special i2c controls/setup) or is this board broken?
Mika