How to Efficiently Connect to Sensors in IoT Endpoints Using 1-Wire Communication

By Bill Giovino

Contributed By Digi-Key's North American Editors

While it is common for Internet of Things (IoT) and Industrial IoT (IIoT) endpoints to have localized control areas, some need to connect to simple sensors that are more than one meter away from the location of the host microcontroller. Traditionally, SPI or I²C serial interfaces are used to easily communicate with these sensors. However, as control algorithms become more complicated and more sensors need to be deployed, the microcontroller must use more SPI and I²C lines to reach these sensors. This increases the complexity of the wiring, which adds to configuration and maintenance costs, particularly as distances increase.

This article will show developers how to use the 1-Wire protocol from Maxim Integrated to cost-effectively connect to IoT sensors using only one wire plus ground. It will discuss the advantages of the 1-Wire protocol, including significantly extending sensor range and providing power and data over the same wires. It will then introduce a bridge device that converts 1-Wire signals to either SPI or I²C and a development kit with software to help designers get started.

Expanding use of IoT and IIoT sensors

The expansion of IoT and IIoT networking is about making systems and manufacturing processes more efficient while expanding functionality. This involves collecting data using sensors. While a home may have one thermostat in a room that contains a temperature sensor, an automated building or IIoT network may place many temperature and humidity sensors in a room and throughout the building or facility. For example, additional sensors may be placed in heating, ventilation and air conditioning (HVAC) ducts alongside pressure sensors. Security systems may also use different types of sensors, and they may also be placed in multiple locations.

Manufacturing and conveyor belt systems are also seeing an increase in the use of sensors for process monitoring and data logging for analysis on how to, for example, save energy by making systems more efficient, while also improving safety.

The most common sensors for these applications are environmental, including temperature, humidity, and pressure; visual sensors including visual light and capacitance proximity sensors; and position sensors including microelectromechanical systems (MEMS) accelerometers, MEMS gyroscopes, and vibration sensors. Miniaturization and advances in MEMS technologies have resulted in sensors in packages smaller than a thumbnail that draw only a few hundred milliamperes (mA). Most of these sensors are easily accessible by an SPI or I²C communication interface, both found on almost any microcontroller. When interfacing to these simple sensors, it can be impractical to build an entire IoT or IIoT endpoint or child node to just sample temperature, so it is often simpler and faster to just run the SPI or I²C communication lines directly to them.

In some cases, analog sensors are still used, such as high-temperature thermocouples and some pressure sensors. In these cases, the microcontroller interfaces with an SPI or I²C analog-to-digital converter (ADC) at the sensor location which samples the analog sensor locally. This avoids voltage drops across analog sensor lines and so improves accuracy.

Interfacing to remote SPI and I²C sensors

A microcontroller communicates with these sensors by extending the reach of SPI and I²C data lines. However, I²C is limited to a range of one meter or less, and SPI has similar limitations. In addition, full-duplex SPI requires four pins, including an individual peripheral select for each one. As a result, reaching four SPI peripherals on a bus requires seven pins, plus power and ground, for a total of nine pins. Half-duplex I²C requires two pins, plus power and ground, to the peripheral, for a total of four lines. At the same time, the many high-speed signals increase electromagnetic interference (EMI), which can generate crosstalk, resulting in reduced signal integrity and lowered system reliability.

What is needed is a solution that minimizes power and data wiring and simplifies operation while maintaining compatibility with existing I²C and SPI sensors.

To solve the problem of connecting to remote sensors over longer distances while reducing wire count, Maxim Integrated developed a 1-Wire protocol that connects to most SPI or I²C sensors using one wire, plus a ground. The protocol reduces the six-wire count from SPI and the four used by I²C, to just two wires that carry both data and power up to 100 meters (m).

Applying 1-Wire

When using 1-Wire, the remote sensor has a 1-Wire communications bridge that converts the 1-Wire protocol into compatible SPI or I²C signals that interface to the sensor. Both the 1-Wire bridge and the sensor are parasitically powered by just the 1-Wire signal plus a ground line. This allows 1-Wire signals to be routed in small areas, saving costs by using less wire.

While both SPI and I²C use a dedicated clock signal, 1-Wire embeds the clock with the data signal. SPI addresses a particular peripheral using a separate select signal for each peripheral, while I²C uses a 7-bit bus address transmitted along the data line; in comparison, 1-Wire uses a 56-bit address that is hard-wired into each individual communication bridge. This wider addressing range not only increases the number of unique peripherals on a bus, but also increases security by making it harder for an attacker to guess the address of a peripheral on the 1-Wire bus.

Word size on a 1-Wire peripheral bus is 8 bits. A microcontroller 1-Wire bus host can bit-bang the 1-Wire protocol, but it is also supported by a simple UART driver. This allows even an 8-bit microcontroller to be a 1-bit bus host. A 1-bit bus can contain SPI or I²C peripherals, but not both. This consistency prevents conflicts and collisions on the bus and simplifies programming with the protocol.

Real-world 1-Wire solutions

For designers looking to interface to an SPI or I²C peripheral across a 1-Wire bus, Maxim Integrated offers the DS28E18Q+T 1-Wire-to-I²C/SPI bridge with command sequencer (Figure 1).

Diagram of Maxim Integrated DS28E18Q+T 1-Wire-to-I²C/SPI bridge with command sequencer (click to enlarge)Figure 1: The DS28E18Q+T 1-Wire-to-I²C/SPI bridge with command sequencer interfaces to a 1-Wire bus IO and GND pins. (Image source: Maxim Integrated)

Referring to Figure 1, parasitic power is extracted from the bus when IO is high and made available on the SENS_VDD pin to power the peripheral. The bridge buffers and translates 1-Wire commands into the appropriate I²C or SPI commands.

The IO pin and GND connect to the 1-Wire bus and are sent to the front-end with its state machine. Each device is identified by a 56-bit ROM ID, prefixed with an 8-bit, 1-Wire family code that designates the revision of the DS28E18Q+T. This allows for unique identification of a specific DS28E18Q+T by the microcontroller firmware, allowing it to be flexible enough to address any changes in the device family. There is a 48-bit unique serial number for the device with an 8-bit cyclic redundancy check (CRC) code.

The front-end sends the translated data to the command sequencer using a 144-byte command buffer which includes 128 bytes of data from the IO bus and 16 bytes for internal use. The command sequencer processes the commands and can store up to 512 bytes of I²C or SPI commands in its buffer to be later sent to the peripheral, instead of having the 1-Wire bus process commands one at a time.

This 512-byte buffer also allows the DS28E18Q+T to coordinate its own internal power behavior so that timing for communication with the peripheral allows parasitic power to be maintained. The command sequencer maintains this timing when it sends instructions to the I²C/SPI Master and GPIO controller which processes the data so that it conforms to the I²C and SPI standards.

An external 470 nanofarad (nF) capacitor is connected to the CEXT pin which acts as a power reserve for the DS28E18Q+T during 1-Wire bus operation. Parasitic power is available for the connected peripheral at the SENS_VDD pin. For SPI operation, the four pins SS#, MISO, MOSI, and SCLK provide full-duplex communication to the connected peripheral. I²C operation only uses two pins with alternate function pins, SDA and SCL. Pins SS# and MISO for SPI operation are unused for I²C operation and so can be used as general-purpose I/O (GPIO) with alternate function GPIOA and GPIOB. This provides greater flexibility that can be used to light diagnostic LEDs at the sensor location or to manage configuration pins on a sensor or ADC to change the behavior of the device.

Using the Maxim Integrated DS28E18Q+T, a single UART on a microcontroller can communicate using only two wires with many sensors on the same 1-Wire plus ground bus; each sensor is connected to a DS28E18Q+T that can be up to 100 m away. This can be especially useful for HVAC systems where only two wires can be routed through an air duct to monitor temperature and humidity along its length at each vent. This improves the efficiency of the system by monitoring for hot or cold spots that may be caused by obstructions.

1-Wire development

To get started developing with the 1-Wire protocol, Maxim Integrated offers the DS28E18EVKIT# evaluation system. This consists of a hardware development board (Figure 2) and software.

Image of Maxim DS28E18EVKIT# evaluation boardFigure 2: The Maxim DS28E18EVKIT# evaluation board allows a developer to easily connect an SPI or I²C peripheral to the 1-Wire bus. The included software can be used to program and monitor the bus and peripheral behavior, as well as help generate the microcontroller device drivers. (Image source: Maxim Integrated)

The evaluation board allows a developer to program and monitor the DS28E18Q+T. For development purposes, the board comes with a USB adapter that interfaces the board to a USB port on a Windows computer. The developer needs to download and run the DS28E18EVKIT# evaluation kit software to aid in development. As seen in Figure 3, the evaluation software allows programming and monitoring of the DS28E18Q+T and its attached peripheral.

Image of Maxim Integrated DS28E18EVKIT# evaluation software (click to enlarge)Figure 3: The DS28E18EVKIT# evaluation software allows a developer to configure the on-board DS28E18Q+T using the USB adapter and monitor its behavior. The 512-byte command sequencer memory can be filled with data and then sent to the peripheral to perform the sensor operation. (Image source: Maxim Integrated)

The software can send commands to the DS28E18Q+T evaluation board and configure it for the target SPI or I²C peripheral. It can select the address range of the peripheral and fill the 512-byte command sequencer memory with peripheral commands to be executed. The software can also help configure the UART drivers for the target microcontroller, saving the effort of learning all the details of the 1-Wire communications protocol. A developer can also use the evaluation board in their own application, saving the time and effort of building and configuring a sensor node.

Conclusion

As IoT and IIoT systems add more sensors, the wiring to the sensors becomes more complex and costly, particularly as distances increases. Sending power to the sensors is also another concern that can complicate setting up a sensor network. As shown, the 1-Wire protocol and associated hardware from Maxim Integrated can make interfacing to the sensor network easier and more efficient by providing data and power over just one wire, plus ground.

Disclaimer: The opinions, beliefs, and viewpoints expressed by the various authors and/or forum participants on this website do not necessarily reflect the opinions, beliefs, and viewpoints of Digi-Key Electronics or official policies of Digi-Key Electronics.

About this author

Bill Giovino

Bill Giovino is an Electronics Engineer with a BSEE from Syracuse University, and is one of the few people to successfully jump from design engineer, to field applications engineer, to technology marketing.

For over 25 years Bill has enjoyed promoting new technologies in front of technical and non-technical audiences alike for many companies including STMicroelectronics, Intel, and Maxim Integrated. While at STMicroelectronics, Bill helped spearhead the company’s early successes in the microcontroller industry. At Infineon Bill orchestrated the company’s first microcontroller design wins in U.S. automotive. As a marketing consultant for his company CPU Technologies, Bill has helped many companies turn underperforming products into success stories.

Bill was an early adopter of the Internet of Things, including putting the first full TCP/IP stack on a microcontroller. Bill is devoted to the message of “Sales Through Education” and the increasing importance of clear, well written communications in promoting products online. He is moderator of the popular LinkedIn Semiconductor Sales & Marketing Group and speaks B2E fluently.

About this publisher

Digi-Key's North American Editors