ESP32 Bit Pirate home
  • 1-Wire
  • Beginner
  • 5 min
  • Serial CLI

Recipe · Beginner · 1-Wire

How to read a DS18B20

A DS18B20 is one of the fastest ways to check if a 1-Wire setup works. You only need data, ground, supply and a pull-up on DQ.

DS18B20 temperature sensor on a 1-Wire bus.
Confirm the sensor ROM first, then let the firmware decode the temperature value.

Wiring View

DS18B20 BP DQ1-Wire GPIOVDDcorrect supplyGNDBP GNDPull-upDQ/VDD
Generated from the wiring summary: DS18B20 to BP.
Step 1

Commands

Run the typed commands first. If the command opens an interactive shell, select the named action from the shell menu instead of treating it as another CLI command.

Result

What success looks like

Family code 0x28 is commonly associated with DS18B20-style temperature sensors. The important part is that scan and temp agree on a valid device.

Troubleshooting

  • No pull-up resistor on the DQ line.
  • Connecting parasite-powered sensors without checking wiring.
  • Leaving multiple devices on the bus while testing a simple setup.

Next steps

  • Run read to inspect ROM and scratchpad data.
  • Use scan again if the temperature command becomes unstable.
  • Move to a longer cable only after a short wiring test passes.

DS18B20 temperature FAQ

What confirms that the device is really a DS18B20?

A stable scan result plus a successful temp read is the useful confirmation. DS18B20-style sensors commonly use family code 0x28, but the decoded temperature should also be repeatable.

What does scan prove before a temperature read?

Scan proves that a 1-Wire device can be discovered by ROM ID. A temperature read goes further by addressing a DS18B20-style sensor command and conversion workflow.

Can I leave several 1-Wire sensors connected?

1-Wire can support multiple devices, but start with one sensor while validating wiring. Add more devices only after scan, read and temp are stable on the simple setup.

Go deeper