Loading

Report as inappropriate

They may not be broken, just configured for a different voltage. The pi outputs 3.3V. Most arduinos use 5V. Using 3.3V with an output is usually ok with 5V devices because 3.3V > 2.5V (the halfway point to 5V). You can confirm this by connecting the relay straight to the 3.3V, GND, and 5V on the pi, and see what states the relay is in.

I almost didn't mention that caveat to the hack, because if the relay has an internal pullup (which it should), then it's not going to be erratic at all. If you want to be sure, you can combine that export in/out hack with a pull up resistor to 5V. Don't use the pullup with on/off, just the out/in. That's probably unnecessary because the relay board probably already has one.

If you want to avoid the export out/in hack, then you would need to add a transistor, controlled by the 3.3V output of the pi, and it will switch the relay from 5 to 0V. I'm not going to explain that in this comment section, there's plenty about it on the internet already.