2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
# 🌡️ Arduino Temperature Control Library
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
[](https://github.com/marketplace/actions/arduino_ci)
[](https://github.com/milesburton/Arduino-Temperature-Control-Library/actions/workflows/arduino-lint.yml)
[](https://github.com/milesburton/Arduino-Temperature-Control-Library/actions/workflows/jsoncheck.yml)
[](https://github.com/milesburton/Arduino-Temperature-Control-Library/issues)
[](https://github.com/milesburton/Arduino-Temperature-Control-Library/blob/master/LICENSE)
[](https://github.com/milesburton/Arduino-Temperature-Control-Library/releases)
[](https://github.com/milesburton/Arduino-Temperature-Control-Library/commits/master)
A robust and feature-complete Arduino library for Maxim Temperature Integrated Circuits.
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
## 📌 Supported Devices
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
- DS18B20
- DS18S20 (⚠️ Known issues with this series)
- DS1822
- DS1820
- MAX31820
- MAX31850
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
## 🚀 Installation
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
### Using Arduino IDE Library Manager (Recommended)
1. Open Arduino IDE
2. Go to Tools > Manage Libraries...
3. Search for "DallasTemperature"
4. Click Install
5. Also install the required "OneWire" library by Paul Stoffregen using the same method
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
### Manual Installation
1. Download the latest release from [GitHub releases ](https://github.com/milesburton/Arduino-Temperature-Control-Library/releases )
2. In Arduino IDE, go to Sketch > Include Library > Add .ZIP Library...
3. Select the downloaded ZIP file
4. Repeat steps 1-3 for the required "OneWire" library
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
## 📝 Basic Usage
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
1. **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 the [DS18B20 datasheet ](https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf ) (page 7)
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
2. **Code Example **
```cpp
#include <OneWire.h>
#include <DallasTemperature.h>
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
// Data wire is connected to GPIO 4
#define ONE_WIRE_BUS 4
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
void setup(void) {
Serial.begin(9600);
sensors.begin();
}
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
void loop(void) {
sensors.requestTemperatures();
delay(750);
float tempC = sensors.getTempCByIndex(0);
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.println("°C");
delay(1000);
}
```
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
## 🛠️ Advanced Features
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
- Multiple sensors on the same bus
- Temperature conversion by address (`getTempC(address)` and `getTempF(address)` )
- Asynchronous mode (added in v3.7.0)
- Configurable resolution
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
### Configuration Options
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
You can slim down the code by defining the following at the top of DallasTemperature.h:
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
```cpp
#define REQUIRESNEW // Use if you want to minimise code size
#define REQUIRESALARMS // Use if you need alarm functionality
```
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
## 📚 Additional Documentation
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
Visit our [Wiki ](https://www.milesburton.com/w/index.php/Dallas_Temperature_Control_Library ) for detailed documentation.
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
## 🔧 Library Development
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
If you want to contribute to the library development:
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
### Using Dev Container
The project includes a development container configuration for VS Code that provides a consistent development environment.
2023-03-17 11:59:21 +00:00
2026-03-20 17:18:15 +00:00
1. **Prerequisites **
- Visual Studio Code
- Docker
- VS Code Remote - Containers extension
2. **Development Commands **
Within the dev container, use:
- `arduino-build` - Compile the library and examples
- `arduino-test` - Run the test suite
- `arduino-build-test` - Complete build and test process
> Note: Currently compiling against arduino:avr:uno environment
## ✨ Credits
- Original development by Miles Burton <mail@milesburton .com>
- Multiple sensor support by Tim Newsome <nuisance@casualhacker .net>
- Address-based temperature reading by Guil Barros gfbarros@bappos .com
- Async mode by Rob Tillaart rob.tillaart@gmail .com
## 📄 License
MIT License | Copyright (c) 2025 Miles Burton
Full license text available in [LICENSE ](LICENSE ) file.