Using 1-Wire to switch something on and off

This page describes a MicroLan module. The module includes a relay which can be turned on or off by commands from the master computer. Thus, with this module and other units, you could, for instance, have a home cooling system which would use a fan to increase airflow out of a hot loft... but the fan would only come on when it suited you and when conditions were such that spending the electricity was worthwhile. Note: The loft might, on a given day, be, say, 80 degrees. Do you want the fan on? If it is 90 outside, no. But if it's 70 outside, yes. Easy to arrange, with a MicroLan and a few 1-Wire chips. (The module which is the subject of this page, PCB206, includes pads for a temperature sensor, if you want one co-located with the MicroLan-controlled relay.)

The availability of the design is the Good News. And it works!

The Bad News...
- It was designed by an amateur
- It may be over-engineered
- There may be flaws in the design. I don't think there's anything "dangerous" in it, but changes might make it even more reliable. It has always worked for me, but maybe there are environments it wouldn't like, even though the chip it is built around, the DS2405, "should" work in those circumstances

- You can't buy the pcb pre-made (yet)
- As designed, it is not suitable for switching household voltages. Don't fool with them (110v AC in many places, 240v AC in the UK.) unless you know what you are doing. Those readers who do know what they are doing will find that my design has taken care of most of the work they need to do. Not only must your relay be adequately rated for the power you wish to switch, but you must design and build the circuit and its enclosure according to electrical codes, and ensuring the safety of users.

Back to Good News...
- I am relinquishing the "rights" to the circuit. If you want to copy it, you are welcome to do so, for personal or commercial use. I would appreciate a mention of in any documentation of "your" device.
- If you are in a position to make the circuit board in "hobbyist" quantities, and would like to participate in a cooperative effort to make and market it, so please get in touch? I don't want to make money on the thing.... but I don't want to lose money, either!
- My design, as posted here, doesn't include a footprint for an RJ-11 or RJ-45 socket, or for a second for "pass-through". I suppose that such should be provided, but I didn't want to fuss with that on the prototype board. The connector provisions should provide for re-routing signals on lines other than the basic 1-Wire Data and Ground, which, thank heavens, do seem always to be on the center pins, and on them the same way "around". The RJ provisions should create at least one way to feed the unregulated power to the board. It might even be a good idea to allow the relay contacts access to the RJ, but that would certainly need to be re-configurable via links.

Further Details

The module needs to be supplied with an unregulated DC supply. It must be at least 7.5v, and probably shouldn't be as much as 30 volts. Typically it will be 12v. Your choice of voltage may be affected by other things you want to supply from the same power source. Note: The coil of the relay in the module will be operated by 5 volts regardless of the Vunreg you supply.

If you click on the following links, the relevant diagrams will open in their own windows: PCB206 schematic and pcb layout. (You may have to ask your browser to tile the windows.)

In the schematic...
- the chip at "A" is a DS2405
- the chip at "B" is a DS1820 (or DS18B20, or DS1822)
- the chip at "C" is a 78L05 voltage regulator

Apologies for the crude symbol for the relay in the schematic... It is at the upper right.

If you want to supply a voltage to whatever the relay is controlling, from the same source of Vunreg used by PCB206, you can do this. All you have to do is connect the pads of "link 1", and Vunreg is supplied to the common pin of the relay. If part of your reason for using a relay is for isolating parts of circuits, PCB206 can be wired up for that, too. The various pads of "RelayOut" are not used in every application, but all are needed to provide for all the different options.

A warning: I once had an expensive week playing with a "simple", "safe" circuit not unlike the one presented here. No matter what I did with opto-isolators, etc, I still managed to overlook something that was frying the PIC microcontrollers I was working with.

That scenario went like this: I had the PIC running off of a simple voltage regulator, similar to the one in this circuit. I was using the same source of unregulated voltage to power a model train's DC motor, and couldn't put a field-collapse-surge-trapping diode on the line, as I wanted the train to be able to run both ways. (Hmmm... as I type that, I realize that the diode could have gone "above" the reverse-polarity switch... did I try that at the time?...) ANYWAY: Bottom line: Maybe (depending on your application) you need separate power supplies for your MicroLan module(s) and things controlled by the relay's contacts. (Anyone who can point me at things to examine would be a "hero" if he/ she were to write with ideas for me to look into!! (But the project is almost dead, and I've given much too little information, so don't spend much time on this.)

The connections at the left on the schematic are where Vunreg is supplied to the circuit. The voltage regulation circuit is the most "suspect" part of the design. If you know more about these things than I do, don't hesitate to criticize my capacitor choices, given in the "parts" list, below.

Do you need the "nuisance" of the power connection to the module? I included it because I didn't want to have to think about powering the relay's coil by other means. The voltage you pass through the relay's contacts may change from project to project, but with my design, you don't have to worry about changing the relay for it's coil's voltage needs. I was also a bit nervous about my ability to correctly decide what voltage was safe going into the switching transistor. Additionally, having the on-board 5v means that the optional temperature sensor to the board can be designed to run in the "powered" mode, (i.e. not in "parasitic"), which I suspect is a help to MicroLan robustness. (If you want to dispense with the on-board 5v, there is a 0v rail near the relevant pin of the temperature sensor; you should tie it low if you decide to re-design for parasitic powering.)


The excellent Dallas-supplied iButtonViewer will tell you that there is a DS2405 on your MicroLan, and it will tell you it's unique ID, but that's all iButtonViewer will to. To access the internals of the DS2405, you can use the Dallas-supplied OneWireViewer... which I don't much like, as I find the installation cumbersome and demanding of disc space. You must also have a Java run time environment installed (JRE), but that is becoming useful for all sorts of things anyway. You may have installed one already.

(If you want a free complete java programming environment, see my page about free programming tools on the web.)

Alternatively, you might want to go straight to your own DS2405 software. Before your module will be much use, you'll need to write software to take advantage of its presence. I have published information on writing Delphi applications for 1-Wire chips. Much of what is in those tutorials will be of use to programmers using other languages. The best of my tutorials online at the moment is my introduction to MicroLan programming, but other things have been written, and are awaiting "packaging" for the web. Feel free to "pester" me if you want them got "out the door". (Be sure to look in the Delphi 1-Wire Tutorials table of contents, in case I've got them out, but haven't yet revised this page.)

I have produced a .DLL which takes just a few parameters, and allows you to say "on" or "off" from anything which can access a DLL, e.g. even some spreadsheets (OpenOffice, for one). A file inside the downloadable zip archive has further explanations for you.

Minor (?) Details

LED1 or LED2 needs to be re-located. One is to show that the device has power, the other is only supposed to light when the relay coil is energized.

The transistor was chosen by the non-rigorous technique of digging through my spares box. It may not be the best for the job, and certainly isn't the only, but, as I said, the circuit works!

Many designs for MicroLan devices include a BAT545. Transient suppression? (I may have the part number wrong.. a tiny surface mount device with two diodes in it.) I would have added it if a) I knew how, b) I had the parts.... so don't hesitate to write and tell me how if you know, and if I could buy some from you at a reasonable cost... I don't want to pay one of the commercial people $15 shipping for $5 worth of parts. Defray the p&p expenses you had, and release that tied up capital of yours!

Parts list

(see text, above)

C1: 0.47 uF 63 v electrolytic
C2: 0.22 uF 63 v electrolytic
Transistor: BCY70
LEDs: two
R1, R2: to suit LEDs with 5v supply, say 680 ohm.
VReg: 78L05
QD1: DS2405
QD2: (optional): DS 1820 or similar. (Temperature sensor)
D1: 1N4001
Relay: 5 v coil. I used a NEC MR62-9USR, also marked "A9043"

Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, download something, and circulate it for me? At least (please) send an 'I liked the parallel port use page, and I'm from (country/ state)' email? (No... I don't do spam) Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

Here is how you can contact this page's editor.
Click here to go up to general 'electronic projects' page by editor of this page.