
Start with a single 4.7 kΩ pull-up resistor attached to the data line–this ensures stable communication without signal degradation. Wire the component’s VDD pin directly to a 3.3V or 5V supply, depending on microcontroller compatibility; lower voltage reduces power draw in battery-powered applications. Ground the device’s GND pin to the common ground of your system to prevent floating voltages.
Connect the data pin to a general-purpose input/output (GPIO) on your controller–Arduino’s D2 or Raspberry Pi’s GPIO4 are reliable choices. For long cable runs (over 5 meters), add a 100 nF decoupling capacitor between VDD and GND near the chip to suppress noise. Avoid routing the data line parallel to high-current pathways like motor drivers or switching regulators to minimize interference.
Use a parasitic power configuration if wiring simplicity is critical–short VDD to GND and rely on the data line for both communication and power. However, parasitic mode requires precise timing during readings to prevent brownouts; ensure your code implements delays of at least 750 ms between conversions for stable operation. For multiple devices on a single bus, assign unique 64-bit addresses via hardware or software scanning to avoid collisions.
Calibrate readings by comparing against a reference thermometer in ice water (0°C) and boiling water (100°C). If deviations exceed ±0.5°C, check for loose connections, insufficient pull-up resistance, or incorrect power supply levels. For high-precision applications, log ambient conditions and apply linear correction algorithms to compensate for sensor drift over time.
Wiring Guide for the DS Model Thermometer Probe

Connect the probe’s data pin to a 4.7 kΩ pull-up resistor linked to a 5V supply–this ensures stable readings in parasitic power mode. Ground the probe’s negative terminal directly to the MCU’s common reference point to minimize signal noise. Use a single-core 22 AWG wire for the data line to reduce capacitance; stranded wires introduce errors over runs longer than 10 meters. For multi-probe setups, wire each device in parallel with separate pull-ups or use a single 2.2 kΩ resistor on a shared bus with no more than 10 devices.
- 3.3V systems require a 2.2 kΩ resistor to maintain signal integrity–higher values cause communication failures.
- Twisted-pair wiring (data + ground) cuts interference by 60% compared to plain wire, especially near motors or switching power supplies.
- For outdoor use, seal connections with heat-shrink tubing and silicone gel to prevent corrosion–solder alone fails within months under humidity.
- Test each probe with a 1-Wire bus scanner before final assembly; address conflicts will corrupt readings.
Power the probe via an external 12V source only if the MCU lacks sufficient current; parasitic power limits accuracy to ±0.5°C. Add a 100 nF decoupling capacitor between the probe’s power pin and ground within 1 cm of the IC to filter spikes. For long cable runs (50+ meters), use a dedicated 1-Wire driver like the DS2480B or MAX31826 to boost signal strength–passive pull-ups fail beyond 30 meters. Avoid routing cables near AC lines or transformers; maintain at least 15 cm clearance to prevent induction errors. Verify timing with an oscilloscope: pulses below 15 µs indicate loading issues.
Connecting the Maxim Integrated One-Wire Probe to Controllers: Pin Mapping and Energy Needs

Attach the data lead to a dedicated I/O pin on your microcontroller, ensuring internal pull-up resistance is disabled. For Arduino-based boards, pin D2 or D3 works reliably; ESP32 and ESP8266 handle parasitic power modes better on pins supporting RTC (e.g., GPIO 12 or GPIO 14). Avoid shared pins with high-frequency peripherals to minimize signal corruption.
Power the device through a 3.0V–5.5V supply–directly from the controller’s regulated output if stable, or via a low-dropout regulator (e.g., AP2112K) when input exceeds 5V. Noise-sensitive deployments benefit from a 0.1µF ceramic capacitor soldered between VDD and GND, positioned within 5mm of the module.
For parasitic mode, short VDD to GND and rely on a 4.7kΩ pull-up resistor on the data line. This method simplifies wiring but demands controllers capable of brief 5V boosts during read/write cycles–STM32 and SAMD21 support this natively, while AVR-based boards require manual transistor-assisted pull-up (e.g., 2N7000 MOSFET).
Ground looping introduces inaccuracies; bond the probe’s GND to a single system ground plane, avoiding daisy-chaining from motors or relays. For extended cables (>2m), use a shielded twisted pair with the shield tied to ground at one end only to prevent ground loops.
Controller-Specific Pin Assignments
AVR (ATmega328P/Arduino Uno): Data on D2 or D3 (PCINT-enabled pins), VDD from 5V rail, GND to analog ground. Disable ADC during conversions to eliminate digital crosstalk.
ESP32: Data on GPIO 12/14/27 (RTC-capable pins), VDD from 3.3V regulator. Enable internal pull-up only during idle states–ESP32’s strong drive current (40mA) can emulate external pull-up behavior.
Raspberry Pi Pico: Data on GP2 (default) or GP6-GP9 (supports PIO-assisted timing). VDD from 3V3(OUT) pin, GND to any ground pour. Use onewire library with PIO for deterministic response.
When operating at voltages below 3.3V (e.g., battery-powered nodes), select the TO-92 package with a 3.0V minimum threshold. Verify the device’s ROM through the family code 0x28–counterfeit batches (family code 0xFF) often lack low-voltage stability. For multi-drop networks, limit total cable capacitance to 1nF per meter to maintain signal integrity.
Optimal Pull-Up Resistance for OneWire Device Integration

Use a 4.7 kΩ resistor for most setups involving a single probe on a short bus (under 5 meters). This value balances signal integrity with power consumption, ensuring reliable communication without excessive current draw. For microcontrollers with weak internal pull-ups (commonly 20–50 kΩ), an external resistor is mandatory to maintain proper voltage levels during data transitions.
Longer lines or multiple probes require adjustments. A 3.3 kΩ resistor improves noise immunity for buses exceeding 10 meters, while 1 kΩ suits high-load scenarios (e.g., 10+ peripherals). Avoid values below 1 kΩ–excessive current (VCC/R) risks damaging both the controller and peripheral. Measure actual voltage at the data pin with an oscilloscope; ideal levels should swing between 0.8V (low) and at least 2.4V (high) to meet protocol specifications.
Consider environmental factors: ambient EMI or fluctuating supply voltage (e.g., automotive systems) may necessitate 2.2 kΩ to 3.3 kΩ. For parasitic power mode, ensure the pull-up can source sufficient current (minimum 1 mA sustained) to charge parasitic capacitance during read slots. Test with a 1 kHz square wave–clean edges confirm proper termination.
Fabrication tolerance impacts performance. Metal-film resistors (±1%) outperform carbon (±5%) in stability, crucial for consistent timing. Combine with a 100 nF decoupling capacitor near the device’s power pin to filter high-frequency noise. For boards with multiple buses, isolate each with dedicated pull-ups to prevent crosstalk.
Alternative: active pull-ups (e.g., MOSFET-based) offer dynamic drive strength but complicate design. Stick to passive components unless debugging persistent issues–then validate failing conditions (e.g., bus recovery time) with a logic analyzer. Document final resistor values in schematics, noting justification (e.g., “4.7 kΩ: 3m bus, 2 devices, 5V supply”).
Reading Thermal Readings: Code Snippets for Arduino and STM32
For Arduino, use the OneWire and DallasTemperature libraries to simplify data acquisition. Install both via the Library Manager (search “OneWire” and “DallasTemperature”), then include them in your sketch:
#include <OneWire.h>
#include <DallasTemperature.h>
#define DATA_PIN 2
OneWire oneWire(DATA_PIN);
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(9600);
sensors.begin();
}
void loop() {
sensors.requestTemperatures();
float reading = sensors.getTempCByIndex(0);
Serial.print("Measured value: ");
Serial.println(reading);
delay(1000);
}
STM32 requires adjustment due to its different GPIO architecture. Use the HAL libraries and the same OneWire protocol, but manually manage timing. Below is a minimal implementation for STM32CubeIDE:
STM32 HAL Implementation
#include "stm32f1xx_hal.h"
#define DS_PIN GPIO_PIN_0
#define DS_PORT GPIOA
void DS18B20_Init() {
GPIO_InitTypeDef GPIO_InitStruct = {0};
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = DS_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(DS_PORT, &GPIO_InitStruct);
}
uint8_t DS18B20_Reset() {
HAL_GPIO_WritePin(DS_PORT, DS_PIN, GPIO_PIN_RESET);
HAL_Delay(480);
HAL_GPIO_WritePin(DS_PORT, DS_PIN, GPIO_PIN_SET);
HAL_Delay(60);
return HAL_GPIO_ReadPin(DS_PORT, DS_PIN);
}
Both platforms benefit from parasitic power mode when wiring simplicity is critical. For Arduino, set the `requestTemperatures()` method to use parasitic mode by passing `true` as an argument. For STM32, ensure the data line is pulled high through a 4.7kΩ resistor after sending the reset pulse. This method reduces component count but may require longer conversion times (up to 750ms for 12-bit precision).
Error handling is critical in harsh environments. Arduino’s `getTempCByIndex()` returns -127.00°C on failure. Add a check in your loop:
if (reading == DEVICE_DISCONNECTED_C) {
Serial.println("Error: probe disconnected");
// Reinitialize or trigger an alert
}
STM32 lacks this built-in check, so implement CRC validation manually. The sensor transmits a CRC byte after the reading. Compare it with a calculated CRC using the OneWire protocol’s polynomial. If they mismatch, discard the data and reset the communication.
For multi-device setups, uniquely identify each probe by its 64-bit ROM code. Arduino’s `getAddress()` retrieves this code; STM32 requires manual parsing of the ROM command response. Store addresses in an array for sequential polling. Use `setResolution()` to balance speed (9-bit) and accuracy (12-bit) per device–lower resolution reduces conversion time from 750ms to 93.75ms.