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 🙂

Comments

  1. Hi Manio,

    Thanks a lot for your posts, it’s indeed helpful for people like me who wanna start a new project similar to yours.
    I’ll give it a try with your solution about cheap 1wire module (ds2408).

    May I ask you some questions ?
    How did you do with interrupters (to turn on/off lights) ? Did you also use 1-wire to connect together all interrupters from all rooms ?
    I’m also wandering about the length of the circuit… Does it work for a whole house ? Is it better to use different circuit ?

    Wishing you all the best for your projects =)

    Best regards,
    Laurenzzo

    1. Hi Laurenzzo,
      Sure, answering your questions:
      Yes, I am also using 1wire for all switches in all rooms. The difference is that a switch is connected to my small “sensor board” with DS2413 instead of high voltage. I am only constantly checking all switches state in a loop and detecting a changes. The change is triggering relay and respectively turning ON/OFF the associated light 🙂
      But generally I am using switches very occasionally, because the lights are triggered from my PIR sensors (also connected to my “sensor boards”).

      Yes, it is working for a whole house. As I described here:
      https://skyboo.net/2017/02/raspberry-pi-1wire-bus-master/
      I was tested it with 45.2m cable and 22 slave devices on single bus. I did not test it on a longer distance just because I didn’t have additional cable at the moment 🙂
      But in my house my buses are diverging from one central bus master place (RPi), so I have four 1wire buses for a ground floor. On all buses I also have a DS18B20s for temperature monitoring in every room.

      It is all working very well for three-four years so far 🙂

  2. I tried connect ds2408 to Raspberry , but without any success .
    I already read maybe all google search but cant open “secret” of use this chip . Can you give circuit diagramm of your connections and detail sample as possibe change logic level on the pins od DS2408 .

    1. Hi Vlad,
      You did not provide basic information. First of all – is your DS2408 detected in linux filesystem? What you mean by “secret” use of this chip? 🙂
      What device you want to drive using the chip? Also a relay board? If so, than in idle state there should be a +5V on the input pins and if you set the chip output bit to ‘0’ then the relay is switched “on”.

      1. Hello Manio

        About the –
        when i connect ds2408 to Raspi , Linux found the chip and i seen ID , ican see the file system of internal registers .
        but unfortunately when i tried change levels on pins , – nothing , i check the multimeter but nothing. Maybe you can based on your expirience explain to me how possible change level on pins.

Leave a Reply

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