Controlling relay board with DS2408 over 1-Wire

I wanted to make my home automation to be cheap. Commercial solutions, like KNX was a way too expensive for me; besides creating own system gives great benefits like better knowledge about how it works, possibility to customize it to my needs (including software) and of course much fun 🙂
So I just bought some 5V 8-channel relay boards on the eBay. Because it has 8 channels to control, so I used a DS2408 8-channel, programmable I/O 1-Wire chip.
There was a kernel module for this chip (w1_ds2408). So the only thing left, was to design a small board for DS2408 which I could then connect to the 1-Wire bus:

The Vcc and GND is connected on the right side of the relay board. Because my DS2408 board is powered from the same power source as the relay board, so the GND is common. At idle state there is a logical “1” on all inputs – all relays are “off”. To switch “on” the relay, the DS2408 just pulls selected input to GND.

Firstly I designed this board with the DS1811 power-on-reset circuit. It was working quite nice but only without load. When I was switching the relays with 230V of load, that was triggering the DS1811 power-on-reset chip and the DS2408 was resetting.
I removed that DS1811 and inserted a 10K resistor between Vcc and the RSTZ pin instead (I wanted all relays to be “off” after powering on). I also added a 47uF electrolytic capacitor near the power input to suppress the noise.
After that fixes, controlling the relays is now working stable 🙂

Every board has it’s unique address, so to control the relay board I just need to send a one-byte value to the module’s sysfs output file, for instance:

/sys/bus/w1/devices/29-0000001137c7/output

Every bit from that byte corresponds to specific relay of the relay board. Simple as that 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *