1-Wire is a single-master, multi-drop serial bus developed by Dallas Semiconductor (now Maxim Integrated, acquired by Analog Devices) that communicates using a single bidirectional data line, which can also supply parasitic power to low-current devices during high periods on the line when operating in parasitic-power mode. It is used primarily for identification, temperature sensing, and small data storage tasks at low data rates (standard mode ~16.3 kbps, overdrive mode ~142 kbps).
In practice
1-Wire is most commonly encountered in embedded designs through Maxim/Dallas temperature sensors such as the DS18B20 and DS18S20, as well as iButton devices (DS1990A and related parts) used for identification and access control. The bus uses a single data line (plus ground) with a pull-up resistor, typically 4.7 kΩ for standard parasitic-power configurations, though the correct value depends on bus length and the number of devices. The master initiates all transactions; slaves respond only when addressed by their unique 64-bit ROM code, which allows multiple devices on the same wire.
Timing is the central challenge of 1-Wire. The protocol encodes bits using precise time slots: a logic 0 is written by pulling the line low for 60-120 µs, while a logic 1 uses a short 1-6 µs pull-low followed by release. Reset and presence detection use similarly precise 480 µs pulses. These tolerances are tight enough that bit-banged implementations on heavily interrupted firmware can produce glitches. On bare-metal systems, disabling interrupts during time-critical slots is a common mitigation. Dedicated 1-Wire master ICs (e.g., DS2480B serial-to-1-Wire bridge) or the 1-Wire peripheral in some Maxim MCUs handle timing in hardware and are more reliable for longer buses or larger device counts.
Parasitic power mode, where the device harvests energy from the data line during high periods, is convenient for two-wire cabling (data + ground only) but imposes constraints. High-current operations such as DS18B20 temperature conversion require the master to actively drive the line high via a strong pull-up or a dedicated MOSFET during conversion, because the parasitic capacitance cannot sustain the current. Missing this step is a common source of failed or erratic conversions in new designs.
Bus topology and cable length affect reliability significantly. 1-Wire can span tens of meters on a single twisted pair in a star or linear topology, but capacitance and stub lengths must be managed. The Maxim application notes AN 148 and AN 255 cover layout guidelines in detail. For designs requiring robustness over longer runs, hardware master ICs or a dedicated 1-Wire-to-UART bridge approach (using the DS2480B or similar) is generally preferred over bit-banging on a general-purpose GPIO.
Frequently asked
Can I power a DS18B20 in parasitic mode without an external pull-up MOSFET?
Sometimes. For short buses with one or two sensors and a strong
pull-up resistor (2.2 kΩ or lower), the line may sustain enough current during the 750 ms conversion window. However, Maxim's datasheets formally recommend actively driving the DQ line high through a
MOSFET or dedicated pin during conversion to guarantee reliable results, especially on longer buses or with multiple devices. Omitting this is one of the most common causes of returning 85°C (the
power-on reset value) or
CRC errors from the DS18B20.
How does the master talk to a specific device when multiple sensors share the same bus?
Every 1-Wire device carries a factory-programmed 64-bit ROM code: 8 bits of family code, 48 bits of serial number, and 8 bits of
CRC. The master uses a ROM Search algorithm (defined in the 1-Wire protocol) to enumerate all devices, then issues a Match ROM command followed by the target device's 64-bit address to direct subsequent commands to that device. If only one device is on the bus, the master can issue Skip ROM to bypass addressing entirely.
Is bit-banging 1-Wire reliable enough for production firmware?
It depends on the platform and
interrupt load. On a dedicated or lightly loaded
MCU running at 8 MHz or faster, bit-banged 1-Wire with interrupts disabled during time slots is commonly used in production. On MCUs with heavy ISR activity, an RTOS with variable tick jitter, or a Linux-based SoC with a non-RT kernel, timing violations become likely. Hardware 1-Wire masters or a
UART-based 1-Wire implementation (using the UART peripheral's precise
baud timing to generate 1-Wire slots) are more deterministic alternatives in those environments.
What is the UART trick for 1-Wire, and how does it work?
A
UART peripheral can generate 1-Wire bit slots with hardware-accurate timing. For reset, the UART is configured to 9600
baud and transmits 0xF0; the received byte reflects the presence pulse. For data bits, the UART is reconfigured to 115200 baud, where specific byte values are used to produce short or extended pull-low periods on the line that correspond to logic 1 and logic 0 slots respectively. The exact byte values depend on the UART's idle polarity, inversion settings, and the external wiring (typically TX and RX shorted together and connected to the 1-Wire bus via a
diode or resistor). This approach offloads timing to the UART hardware and works well on MCUs where those conditions are met.
How does 1-Wire differ from other low-pin-count buses like I2C?
I2C uses two lines (SDA and SCL) and relies on a separate clock signal, which simplifies timing and allows higher data rates (up to 400 kbps in Fast mode on most
MCU peripherals, with higher rates such as Fast-mode Plus at 1 Mbps supported on some). 1-Wire uses one data line and encodes both clock and data in the timing of that single line, making it cheaper to wire at the cost of tighter timing requirements and lower throughput. I2C addresses are typically 7 or 10 bits and set by hardware pins or register configuration, while 1-Wire devices use a globally unique 64-bit factory address. For designs that already have a
pull-up and two
GPIO lines available, I2C is usually easier to implement reliably; 1-Wire's advantage is the absolute minimum wire count and the iButton form factor for contact-based identification.
Differentiators vs similar concepts
1-Wire is sometimes confused with UNI/O, a similar single-wire protocol from Microchip used on small serial
EEPROM devices (e.g., 11AA series). UNI/O uses a different encoding scheme (MACK/NoMAK arbitration) and is not compatible with 1-Wire devices. 1-Wire is also occasionally conflated with
LIN bus, which is also a single-wire serial protocol, but LIN operates at higher voltages (up to 18 V), uses
UART-style framing, targets automotive networks, and is entirely incompatible with 1-Wire at both the electrical and protocol level.