Skip to main content

1-wire

Communicate with 1-Wire devices like DS18B20 temperature sensors using a single data line.

Overview

The 1-wire node enables communication with 1-Wire protocol devices. This protocol allows multiple devices to share a single data line, making wiring simple. Most commonly used with DS18B20 temperature sensors.

1
Data Wire
100+
Devices Per Bus
100m
Max Wire Length
64-bit
Unique ID

Enable 1-Wire on Raspberry Pi

1. Edit /boot/config.txt

# Add this line (default GPIO 4)
dtoverlay=w1-gpio

# Or specify different pin
dtoverlay=w1-gpio,gpiopin=17

2. Reboot and Verify

sudo reboot

# Check devices are detected
ls /sys/bus/w1/devices/

# Example output:
# 28-00000abcdef1
# w1_bus_master1

Wiring Diagram

DS18B20 Wiring

VCC (Red)3.3V

GND (Black)GND

DATA (Yellow)GPIO 4 (Pin 7)

Important: Add 4.7kΩ pull-up resistor between DATA and VCC

Multiple Sensors

All sensors share the same 3 wires. Each has a unique 64-bit address.

VCC → 3.3V (all)

GND → GND (all)

DATA → GPIO 4 (all, parallel)

Pull-up: Single 4.7kΩ for all

Properties

Property Type Required Default Description
deviceId string No "" Specific device ID or empty for all
command string No "read" "read", "list", or "search"
family string No "" Filter by family code (e.g., "28" for DS18B20)

Inputs

Read Specific Device
{
  "payload": {
    "command": "read",
    "deviceId": "28-00000abcdef1"
  }
}
List All Devices
{
  "payload": {
    "command": "list"
  }
}

Outputs

Temperature Reading
{
  "payload": 23.5,
  "deviceId": "28-00000abcdef1",
  "family": "28",
  "type": "DS18B20",
  "raw": "23500",
  "unit": "°C"
}
Device List
{
  "payload": [
    "28-00000abcdef1",
    "28-00000abcdef2"
  ],
  "count": 2
}

Common 1-Wire Devices

Device Family Type Notes
DS18B20 28 Temperature -55°C to +125°C, ±0.5°C
DS18S20 10 Temperature Older, 9-bit resolution
DS2438 26 Battery Monitor Voltage, current, temp
DS2413 3A GPIO Switch 2-channel I/O

Example: Multi-Sensor Temperature Logger

Read all DS18B20 sensors every 10 seconds and store in database.

inject (10s) 1-wire (list) split 1-wire (read) sqlite
[
  {
    "id": "trigger",
    "type": "inject",
    "repeat": "10",
    "payload": "{ "command": "list", "family": "28" }",
    "payloadType": "json"
  },
  {
    "id": "list-sensors",
    "type": "1-wire",
    "command": "list"
  },
  {
    "id": "split-devices",
    "type": "split"
  },
  {
    "id": "read-temp",
    "type": "1-wire",
    "command": "read"
  },
  {
    "id": "store-db",
    "type": "sqlite",
    "sql": "INSERT INTO temperatures (device_id, value, timestamp) VALUES (?, ?, ?)"
  }
]

Troubleshooting

No devices found
  • Check /boot/config.txt has dtoverlay=w1-gpio
  • Verify 4.7kΩ pull-up resistor is connected
  • Check wiring (VCC, GND, DATA)
  • Ensure you've rebooted after config changes
Reading 85°C constantly

85°C is the power-on reset value. This indicates:

  • Insufficient power - use powered mode, not parasitic
  • Reading too quickly after conversion started
  • Loose connection or damaged sensor
CRC errors
  • Try a lower value pull-up resistor (2.2kΩ)
  • Reduce wire length or use shielded cable
  • Add decoupling capacitor (0.1µF) at sensor

Related Nodes