Dallas / Maxin Integrated's 1-Wire network remains popular as a connection scheme for simple sensors and switches, called 1-Wire Slaves. Popular 1-Wire Slaves include the DS18B20 temperature sensor and DS2413 dual-switch. While Maxim Integrated offers an advanced 1-Wire Master interface (DS2480B), many projects use a single GPIO pin, and others use a simple two-transistor driver.The two-transistor driver presented here is capable of driving longer 1-Wire lines with a UART providing accurate self-timing operation (see https://www.maximintegrated.com/en/design/technical-documents/tutorials/2/214.html#).
This two-transistor driver was built using the strongest 1k5 pull-up allowed for 1-Wire:
Note that D1/R4 are contained in the DS9503 used (pins 2 and 5 are grounded and thus don't appear in the combined schematic above).
A couple of 1-Wire devices are connected (a DS276x temperature probe and DS2413 switch) via a relatively long cable made of 18ga zip wire (speaker wire) and the bus is monitored for regular scan activity:
As expected, the bus levels are 0V and 5V. Let's zoom in and look at a specific 1-Wire transaction - this is called a Reset/Presence pulse. The 1-Wire Master generates a very long (520uS) low pulse to reset all 1-Wire slaves; they respond by generating a 120uS 'Presence' pulse:
In the above capture, you see a small amount of undershoot from the 1-Wire Slave Presence pulse; this is unavoidable on a longer cable like the 22' line here. Fortunately, the DS9503 clamps the negative pulse before it can damage the UART RxD line.
Let's zoom in even closer and look at a single data bit on the bus - this is a 'Read 1' transaction:
Note the timebase is 1uS/division. The master pulls the bus low for ~8uS, which signals the sensor it is ready to receive a bit - here, the sensor sends a '1' bit by allowing the bus to charge back up to 5V. Because the 1-Wire Master uses a 1k5 resistor, the charge follows an RC curve, rising above the RxD threshold in ~400nS and above 4V in ~1uS. The bus is sampled at ~4uS (which is off the right of the trace). We see that data integrity on the 22' cable is excellent. Of course, the 22' 1-Wire bus will have reflections of data pulses - these are visible as small squiggles on the rising RC curve for about 400nS if we zoom further in:
Because the RxD pin isn't sampled until ~4uS later, these (expected) reflections do not compromise the integrity of the data.
This experiment shows a simple 1-Wire Master driver works well with cables longer than 20'; while I haven't tested it, this probably would work up to 50'.
DO NOT try this with a single-pin SoC interface on a Raspberry Pi without a proper 3V ESD clamp.
hi, hey ive been running networks of several DS18B20's (on the same bus) off the simple 2N7000 circuit listed in AN148 (Application note)... works like a charm on "long" cables (100ft). You should check it out. A few cents worth of parts and youve got a kick ass master driver. It does require 2 pins on the micro though.
Understood. This circuit is actually deployed in a commercial product I designed several years ago, I saw random speculation on the Internet that this driver limited range to 10' (though we'd tested extensively...). So I re-tested and got pictures this time. 2N7000s and 2N3904s aren't THAT different - the bipolar transistor is a little slower - and I think the Dallas/Awtrey notes on this are a sales pitch for the (high-end) DS2480B. We're not driving 1000' of bus, we're driving maybe 20'... and it works well. The scope traces show it.
hi, hey ive been running networks of several DS18B20's (on the same bus) off the simple 2N7000 circuit listed in AN148 (Application note)... works like a charm on "long" cables (100ft). You should check it out. A few cents worth of parts and youve got a kick ass master driver. It does require 2 pins on the micro though.