Raspberry Pi and 1-Wire

In a comprehensive tutorial by Jack Creasey, acclaimed author of Raspberry Pi Essentials, we delve into the world of remote input/output technology and devices compatible with the Raspberry Pi. Through this article, we will gain a deeper understanding of 1-wire technology and explore its potential integration with the Raspberry Pi.

While the concept of remote I/O is convenient, it’s not without its limitations. For instance, the Pi needs to be located at the site where the interface work is being carried out, which can be impractical. This approach can be effective for many projects, but it can become cumbersome when powering the Pi in remote areas where I/O functionality is required. The most apparent power solutions to consider are:

  • Powering the unit using battery-operated systems or integrating solar cells to ensure continuous functionality over extended periods.
  • Power Over Ethernet (POE) technology, which enables both data transmission and power delivery through a single Ethernet cable, extending connectivity up to 100 meters without the need for a repeater.
  • AC/DC power supply where a local supply is available

Another potential but somewhat risky solution could be connecting to the Wi-Fi because the attenuation through the walls and the distances also plays a role.

Raspberry Pi and 1-Wire

In many projects, a headless and remote Raspberry Pi is deployed to bring the device closer to the data collection point. While this setup can be effective, it can also introduce an additional complexity, such as requiring a separate computer system to serve as a Human Machine Interface (HMI) for controlling the remote Raspberry Pi.

(For more resources related to this topic, see here.)

Remote I/O

The 1-Wire technology began with the highly durable iButtons, which resembled stainless steel coins similar to the CR2032 coin batteries widely used today. Available in 3 mm and 6 mm thicknesses, these iButtons can be attached to key ring carriers. In this article, I’ll explore how to install a Raspberry Pi to read these iButtons.

The following image shows the dimensions for the iButton, the key ring carriers, and some available reader contacts:

The 1-Wire protocol

The master provides all the timing and power when addressing and transferring data to and from 1-Wire devices. A 1-Wire bus looks like this:

Raspberry Pi and 1-Wire diagram

When the master is not transmitting, the bus is pulled high by a resistor, and each connected device features an internal capacitor that enables energy storage. When the master drives the bus low to send data bits, the devices use their stored energy as a virtual battery, allowing them to detect incoming data and drive the bus low to transmit their own data. The accompanying block diagram illustrates the internal structure of a typical 1-wire device, showcasing its range of potential functions.

There are lots of data sheets on the 1-Wire devices produced by Maxim, Microchip, and other processor manufacturers. It’s fun to go back to the 1989 patent (now expired) by Dallas and see how it was originally conceived (http://www.google.com/patents/US5210846). Another great resource to learn the protocol details is at http://pdfserv.maximintegrated.com/en/an/AN937.pdf.

To look at a range of devices, go to http://www.maximintegrated.com/en/products/comms/one-wire.html.

Key takeaways for now: 1-Wire devices possess a fundamental serial number feature that enables identification and communication with a specific device. This unique numerical identifier is embedded in the silicon. The initial interaction with a device involves retrieving a 64-bit data structure containing a 1-byte family code (device type identifier), a 6-byte globally unique device serial number, and a 1-byte CRC field, as illustrated in the diagram below:

The bus master reads the family code and serial number of each device on the bus and uses it to talk to individual devices when required.

Raspberry Pi interface to 1-Wire

There are three primary ways to interface to the 1-Wire protocol devices on the Raspberry Pi:

  1. W1-gpio kernel: This module enables GPIO port manipulation for 1-Wire protocol usage. However, since it’s not designed for multidrop 1-wire microlans, we won’t be exploring it further.
  2. DS9490R USB Busmaster interface: The tool in question is often utilized in a commercial 1-wire reader provided by Maxim, with third-party copies also available. Its functionality extends to most desktop, laptop, and Raspberry Pi systems. For further information on this device, go to http://datasheets.maximintegrated.com/en/ds/DS9490-DS9490R.pdf.
  3. DS2482 I2C Busmaster Interface: This technology is widely employed in commercial applications for 1-Wire. Owing to the specific nature of these boards, which are often designed for particular microcomputer platforms, you’ll typically find variations suited for distinct systems. For instance, there are versions tailored for the Raspberry Pi and others for Arduino. For further reading on these devices, go to http://www.maximintegrated.com/en/app-notes/index.mvp/id/3684.

I chose a unique Raspberry Pi solution from AB Electronics based on the I2C 1-wire DS2482-100 bridge.

The following image shows the 1-Wire board with an RJ11 connector for the 1-Wire bus and the buffered 5V I2C connector pins shown next to it:

For more detail: Raspberry Pi and 1-Wire


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top