1

My setup: Raspberry Pi 3B+, 2 BigRelays connected to it over different I2C busses (1hw, 1sw).

I had hoped to daisy-chain the two boards over the hardware I2C pins, though as the boards have the same address I had to set up an additional I2C software bus + solder two 2K resistors to pull the lines high.

Long story short, my problem is that some commands sent to one bus (e.g. /dev/i2c-1) toggle a relay on the second bus (/dev/i2c-3).

My /boot/config.txt relevant part looks like this:

 dtparam=i2c_arm=on
 # Add additional bus for I2C as BigRelays have the same address and
 # do not work through the same bus.
 dtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=1,i2c_gpio_sda=2,i2c_gpio_scl=3

Last time I've seen this was by doing this:

 # Turn on rPI
 # Note, the `bw_tool` software is provided by the BigRelay author.
 # I've tried my own implementation through Node.js and `i2c-bus` with similar results.

 # turn on first relay of SW bus.
 > bw_tool -I -D /dev/i2c-3 -s 50000 -a 9c -W 20:1:b
 # turn off first relay of SW bus
 > bw_tool -I -D /dev/i2c-3 -s 50000 -a 9c -W 20:0:b
 # turn on relay on hw I2C bus board
 > bw_tool -I -D /dev/i2c-1 -s 50000 -a 9c -W 20:1:b
 # turn off hardware relay
 > bw_tool -I -D /dev/i2c-1 -s 50000 -a 9c -W 20:1:b # 

And BOOM - the software Relay (on i2c-3) is turned on, as if I'd run the (2) marked command.

Some other info:

  • At first I've had the I2C implementation done through a Node.js library, but as I was getting strange results, I've tried the bw_tool. Got a bit more reliable results though still another bus is affected when targeting one.
  • Some commands turn other board's relays as expected. Sometimes I have to repeat a "-W 23:0:b" command 4 times for it to turn off the relay. Though sometimes I do hear relays clicking, which probably means that another board is getting the commands.
  • I've tried using the HW I2C pins in software mode, same results.

Maybe someone had similar issues and has solved them?

  • 1
    I suggest you lower the I2C bus speed to something pigpio can easily capture (such as 50kbps) and then monitor the buses with piscope. Have a look at the saved data when the error happened. See if there is traffic on the wrong bus. – joan Apr 28 at 22:00
  • Turns out there is a lot of noise on the line. It happens when a relay with 24VAC is turned on and a valve starts working. I've rewired my setup, and managed to get only the command bit being wrong sometimes. So my solution is to read the relay state of the board and retry turning relays off until the desired result is read. In the end it turned out that using simple, GPIO-controller relays would have been simpler and would've taken less time. :-) – Steponas Dauginis May 15 at 10:54
  • You can make an answer with that information and mark it correct in a day or so. – joan May 15 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.