What is 1-Wire Protocol?

What is 1-Wire Protocol?

What if I told you about a not-so-popular serial communication protocol that is:

1- Low-power

2- Supports multi-drop communication: multidrop refers to a communication network topology where multiple devices are connected to a shared communication line or bus, allowing for communication between one master device and multiple slave devices.

3- Device Discovery

4- Requires only one pin for signal, and a ground pin

5- No separate power supply connections

1-Wire was first developed by Dallas Semiconductor, which later became part of Maxim Integrated.


1-Wire devices connect to an open-drain bus, which means that any device can pull the bus low, but can't drive it high.

Every 1-Wire bus has a passive pull-up resistor that range between 100 ohms to a few thousand ohms depending on the kind and number of devices on the bus.

1-Wire devices transmit and receive data over that single wire.



Since the 1-Wire bus is open-drain, there is a FET switch on the IO line of the device, that is used to pull the bus low when it's time to send data.

There is also a buffer used to square up the data (reshaping a signal to make it have clear, sharp transitions between low and high states, resembling a square wave) to ensure reliable communication by cleaning up and restoring signal integrity.

There is also a rectifier and an internal capacitor, to be able to run logic power even when there is another device pulling the bus low (called parasite power).


The sequence of bits coming from the host (a microcontroller for example) is presented to an interface and control block, this block is present in every 1-Wire device and services as a bridge between the bus itself and whatever device functionality might be in the backend.

One more important thing that sets the 1-Wire system apart from all the other serial interface schemes, is that the interface and control block has 64-bit identifier that's unique to every 1-Wire device. No two 1-Wire devices have the same identifier.

Sending and receiving bits

The transfer is simple, every transaction is initiated by the host (a microcontroller for example) whether the microcontroller will write a bit to the device, or read a bit from it.

The standard rate is 15.4Kbps for 65us bit time.

There is also an overdrive speed with 125Kbps for 8us bit time.


To send a '1' bit, the host pulls down the IO line and holds it low for 1-15us, then releases it for the rest of 65us bit period.

To send a '0' bit, the host pulls down the IO line for 60-120us, then releases it and holds the line high for at least 5us.


Those HIGH times are critical, they demarcate the bit period, and also save time for the parasite power capacitors to charge up between bits.

In the 1-Wire device, the falling edge at the beginning starts a timer, then a few seconds later samples the line, if the host wrote 1 -> it will see the bus high, if the host wrote 0 -> it will see the bus low. (the 1-Wire device samples, not the host)


To read a bit from the 1-Wire device, the host basically sends a '1', and if the 1-Wire device wants to send a '1' to the host, it will leave the IO line high as it is.

If the 1-Wire device wants to send a '0' bit, as soon as it sees the IO line fall, it begins pulling it low too!

the host will sample the IO line after a few microseconds, it should see if the IO line is HIGH or LOW. meaning it can read what bit the 1-Wire device sent. (the host samples, not the 1-Wire device)

1-Wire Transaction

To start a transaction, the host will hold the IO line down for 480-640us, that's called a Reset Pulse, that's how the host gets attention. And if any 1-W device sees a reset pulse, it answers by pulling the bus low for between 60-240us, and that's called presence detect pulse. If the host sees a presence detect pulse, it'll know that at least one device is on the line and ready to accept a command.



There is a list of useful commands published on the 1-Wire documentation.

If you only have one device on the bus, you can SKIP ROM and give it commands directly without specifying address (since it's the only one out there).

You can also READ ROM to get its address, but if there is more than one device on the bus, you should not do the READ ROM command so they won't respond at the same time.

If you have multiple devices, you can first SEARCH ROM, that will get you all addresses on the bus, then you can MATCH ROM, which will call the device that has that specific address, and let it be ready for the next command.


1-Wire Devices

DS18B20 - Temperature Sensor

  • A widely used 1-Wire digital thermometer that measures temperatures with high accuracy and supports a wide temperature range. It's often used in environmental monitoring, HVAC systems, and DIY projects.

DS2401 - Silicon Serial Number

  • A unique, factory-lasered, 64-bit serial number device used for identification purposes in various systems, asset tracking, and authentication.

DS2431 - 1Kb EEPROM

  • A 1-Wire memory chip providing electrically erasable programmable memory with a 1Kb capacity. Useful for storing calibration data, configurations, or small data logs.

DS2413 - Dual Channel Addressable Switch

  • A 1-Wire device with two programmable I/O pins. It is often used for controlling or monitoring small loads and interfacing with other digital devices.

DS28E17 - 1-Wire-to-I2C Master Bridge

  • This device acts as a bridge, enabling a 1-Wire master to communicate with I2C slave devices, providing flexibility in interfacing with various sensors and peripherals.

DS1990A - iButton

  • A small, robust, and uniquely numbered identification device used for access control, asset management, and security applications. iButtons are durable and often used in rugged environments.

DS2480B - Serial 1-Wire Line Driver

  • Converts serial communication to 1-Wire signaling, often used to interface microcontrollers or PCs with a 1-Wire network.

DS2423 - 4Kb 1-Wire RAM with Counters

  • Combines RAM memory with two 32-bit counters, used for data logging and counting events in applications like metering and monitoring.

Albert Gohar

Tech Enthusiast | Lifelong Learner

3 个月

Nice insight ?? Keep up the good work ??

回复
Xiaoyan Zheng

Account Manager at Shenzhen New Lung LTD

4 个月

1-Wire proves that simplicity and efficiency can redefine connectivity, powering innovation with just one data line!

回复

要查看或添加评论,请登录

Omar Mustafa的更多文章

  • MQTT: The protocol powering IoT

    MQTT: The protocol powering IoT

    You’ve heard of HTTP (the protocol behind websites), but MQTT is HTTP’s minimalist cousin, built for machines, not…

    1 条评论

社区洞察

其他会员也浏览了