- Notifications
You must be signed in to change notification settings - Fork499
🌡️ Arduino library for interfacing with Maxim temperature sensors like DS18B20, DS18S20, and MAX31850. 🔌 Supports multiple sensors, ⚡ asynchronous operation, and 🎯 configurable resolution for precise temperature monitoring.
License
milesburton/Arduino-Temperature-Control-Library
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A robust and feature-complete Arduino library for Maxim Temperature Integrated Circuits.
| device | power | notes |
|---|---|---|
| DS18B20 | 3-5 V | the reference |
| DS18S20 | 3-5 V | 9 bit only |
| DS1822 | 3-5 V | |
| DS1820 | 5 V | 9 bit only |
| MAX31820 | 3 V | |
| MAX31850/1 | 3-3.7V | thermocouple |
- Open Arduino IDE
- Go to Tools > Manage Libraries...
- Search for "DallasTemperature"
- Click Install
- Also install the required "OneWire" library by Paul Stoffregen using the same method
- Download the latest release fromGitHub releases
- In Arduino IDE, go to Sketch > Include Library > Add .ZIP Library...
- Select the downloaded ZIP file
- Repeat steps 1-3 for the required "OneWire" library
Hardware Setup
- Connect a 4k7 Ω pull-up resistor between the 1-Wire data line and 5V power. Note this applies to the Arduino platform, for ESP32 and 8266 you'll need to adjust the resistor value accordingly.
- For DS18B20: Ground pins 1 and 3 (the centre pin is the data line)
- For reliable readings, see pull-up requirements in theDS18B20 datasheet (page 7)
Code Example
#include<OneWire.h>#include<DallasTemperature.h>// Data wire is connected to GPIO 4#defineONE_WIRE_BUS4OneWireoneWire(ONE_WIRE_BUS);DallasTemperaturesensors(&oneWire);voidsetup(void) { Serial.begin(9600); sensors.begin();}voidloop(void) { sensors.requestTemperatures();delay(750);float tempC = sensors.getTempCByIndex(0); Serial.print("Temperature:"); Serial.print(tempC); Serial.println("°C");delay(1000);}
- Multiple sensors on the same bus
- Temperature conversion by address (
getTempC(address)andgetTempF(address)) - Asynchronous mode (added in v3.7.0)
- Configurable resolution
You can slim down the code by defining the following at the top of DallasTemperature.h:
#defineREQUIRESNEW// Use if you want to minimise code size#defineREQUIRESALARMS// Use if you need alarm functionality
Visit ourWiki for detailed documentation.
If you want to contribute to the library development:
The project includes a development container configuration for VS Code that provides a consistent development environment.
Prerequisites
- Visual Studio Code
- Docker
- VS Code Remote - Containers extension
Development CommandsWithin the dev container, use:
arduino-build- Compile the library and examplesarduino-test- Run the test suitearduino-build-test- Complete build and test process
Note: Currently compiling against arduino:avr:uno environment
- Original development by Miles Burtonmail@milesburton.com
- Multiple sensor support by Tim Newsomenuisance@casualhacker.net
- Address-based temperature reading by Guil Barrosgfbarros@bappos.com
- Async mode by Rob Tillaartrob.tillaart@gmail.com
MIT License | Copyright (c) 2025 Miles Burton
Full license text available inLICENSE file.
About
🌡️ Arduino library for interfacing with Maxim temperature sensors like DS18B20, DS18S20, and MAX31850. 🔌 Supports multiple sensors, ⚡ asynchronous operation, and 🎯 configurable resolution for precise temperature monitoring.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.