From SmartCore Wiki
Jump to: navigation, search

Connecting 1-wire devices

The 1-wire interface is a hardware standard for connecting small digital devices, like the very popular DS18B20 thermo sensor. 1-Wire bus only one data line (with power) and ground, for communication with a central microprocessor. However a better long distance/low power result can be achieved using an additional 5V power line. (Do to the max 3.3V high input on the GPIO)

1-wire allows multiple devices to be connected to the same wires, in parallel. To achieve this, each device can only pull the data line to low. When no device is doing that, the line is pulled high, by a pull-up resistor. When connecting multiple devices, the best result is achieved by having all devices on one long line. If more then 10 devices are connected, the port has to be reconfigured to handle it.

At the command prompt:

 modprobe wire max_slave_count=50

Edit /etc/modules to reflect this:

 wire max_slave_count=50

The line can be over 100m long, if there is only a few devices attached. The pull-up resistor should be smaller with more devices and long distances. Have a look at this tutorial

This solution is suited for up to 10m cable, with one or few devices:

RPi3-1-Wire-Temp-Sensors.png

Please use twisted pair cable like network or telephone cable. Let the data line and ground, be a pair. Put the 5V power on an other line, as it is less critical.