|
| 1 | + |
| 2 | +# 🌡️ Arduino Temperature Control Library |
| 3 | + |
1 | 4 | [](https://github.com/marketplace/actions/arduino_ci)
|
2 | 5 | [](https://github.com/RobTillaart/AS5600/actions/workflows/arduino-lint.yml)
|
3 | 6 | [](https://github.com/RobTillaart/AS5600/actions/workflows/jsoncheck.yml)
|
4 | 7 | [](https://github.com/milesburton/Arduino-Temperature-Control-Library/blob/master/LICENSE)
|
5 | 8 | [](https://github.com/milesburton/Arduino-Temperature-Control-Library/releases)
|
6 | 9 |
|
| 10 | +A robust and feature-complete Arduino library for Maxim Temperature Integrated Circuits. |
| 11 | + |
| 12 | +## 📌 Supported Devices |
7 | 13 |
|
8 |
| -# Arduino Library for Maxim Temperature Integrated Circuits |
| 14 | +- DS18B20 |
| 15 | +- DS18S20 (⚠️ Known issues with this series) |
| 16 | +- DS1822 |
| 17 | +- DS1820 |
| 18 | +- MAX31820 |
| 19 | +- MAX31850 |
9 | 20 |
|
10 |
| -## Usage |
| 21 | +## 🚀 Installation |
11 | 22 |
|
12 |
| -This library supports the following devices : |
| 23 | +### Using Arduino IDE Library Manager (Recommended) |
| 24 | +1. Open Arduino IDE |
| 25 | +2. Go to Tools > Manage Libraries... |
| 26 | +3. Search for "DallasTemperature" |
| 27 | +4. Click Install |
| 28 | +5. Also install the required "OneWire" library by Paul Stoffregen using the same method |
13 | 29 |
|
| 30 | +### Manual Installation |
| 31 | +1. Download the latest release from [GitHub releases](https://github.com/milesburton/Arduino-Temperature-Control-Library/releases) |
| 32 | +2. In Arduino IDE, go to Sketch > Include Library > Add .ZIP Library... |
| 33 | +3. Select the downloaded ZIP file |
| 34 | +4. Repeat steps 1-3 for the required "OneWire" library |
14 | 35 |
|
15 |
| -* DS18B20 |
16 |
| -* DS18S20 - Please note there appears to be an issue with this series. |
17 |
| -* DS1822 |
18 |
| -* DS1820 |
19 |
| -* MAX31820 |
20 |
| -* MAX31850 |
| 36 | +## 📝 Basic Usage |
21 | 37 |
|
| 38 | +1. **Hardware Setup** |
| 39 | + - Connect a 4k7 kΩ 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. |
| 40 | + - For DS18B20: Ground pins 1 and 3 (the centre pin is the data line) |
| 41 | + - For reliable readings, see pull-up requirements in the [DS18B20 datasheet](https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf) (page 7) |
22 | 42 |
|
23 |
| -You will need a pull-up resistor of about 5 KOhm between the 1-Wire data line |
24 |
| -and your 5V power. If you are using the DS18B20, ground pins 1 and 3. The |
25 |
| -centre pin is the data line '1-wire'. |
| 43 | +2. **Code Example** |
| 44 | + ```cpp |
| 45 | + #include <OneWire.h> |
| 46 | + #include <DallasTemperature.h> |
26 | 47 |
|
27 |
| -In case of temperature conversion problems (result is `-85`), strong pull-up setup may be necessary. See section |
28 |
| -_Powering the DS18B20_ in |
29 |
| -[DS18B20 datasheet](https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf) (page 7) |
30 |
| -and use `DallasTemperature(OneWire*, uint8_t)` constructor. |
| 48 | + // Data wire is connected to GPIO 4 |
| 49 | + #define ONE_WIRE_BUS 4 |
31 | 50 |
|
32 |
| -We have included a "REQUIRESNEW" and "REQUIRESALARMS" definition. If you |
33 |
| -want to slim down the code feel free to use either of these by including |
| 51 | + OneWire oneWire(ONE_WIRE_BUS); |
| 52 | + DallasTemperature sensors(&oneWire); |
34 | 53 |
|
| 54 | + void setup(void) { |
| 55 | + Serial.begin(9600); |
| 56 | + sensors.begin(); |
| 57 | + } |
35 | 58 |
|
| 59 | + void loop(void) { |
| 60 | + sensors.requestTemperatures(); |
| 61 | + float tempC = sensors.getTempCByIndex(0); |
| 62 | + Serial.print("Temperature: "); |
| 63 | + Serial.print(tempC); |
| 64 | + Serial.println("°C"); |
| 65 | + delay(1000); |
| 66 | + } |
| 67 | + ``` |
36 | 68 |
|
37 |
| - #define REQUIRESNEW |
| 69 | +## 🛠️ Advanced Features |
38 | 70 |
|
39 |
| -or |
| 71 | +- Multiple sensors on the same bus |
| 72 | +- Temperature conversion by address (`getTempC(address)` and `getTempF(address)`) |
| 73 | +- Asynchronous mode (added in v3.7.0) |
| 74 | +- Configurable resolution |
40 | 75 |
|
41 |
| - #define REQUIRESALARMS |
| 76 | +### Configuration Options |
42 | 77 |
|
| 78 | +You can slim down the code by defining the following at the top of DallasTemperature.h: |
43 | 79 |
|
44 |
| -at the top of DallasTemperature.h |
| 80 | +```cpp |
| 81 | +#define REQUIRESNEW // Use if you want to minimise code size |
| 82 | +#define REQUIRESALARMS // Use if you need alarm functionality |
| 83 | +``` |
45 | 84 |
|
46 |
| -Finally, please include OneWire from Paul Stoffregen in the library manager before you begin. |
| 85 | +## 📚 Additional Documentation |
47 | 86 |
|
48 |
| -## Credits |
| 87 | +Visit our [Wiki](https://www.milesburton.com/w/index.php/Dallas_Temperature_Control_Library) for detailed documentation. |
49 | 88 |
|
50 |
| -The OneWire code has been derived from |
51 |
| -http://www.arduino.cc/playground/Learning/OneWire. |
52 |
| -Miles Burton <[email protected]> originally developed this library. |
53 |
| -Tim Newsome <[email protected]> added support for multiple sensors on |
54 |
| -the same bus. |
55 |
| -Guil Barros [[email protected]] added getTempByAddress (v3.5) |
56 |
| - Note: these are implemented as getTempC(address) and getTempF(address) |
57 |
| -Rob Tillaart [[email protected]] added async modus (v3.7.0) |
| 89 | +## 🔧 Library Development |
58 | 90 |
|
| 91 | +If you want to contribute to the library development: |
59 | 92 |
|
60 |
| -## Website |
| 93 | +### Using Dev Container |
| 94 | +The project includes a development container configuration for VS Code that provides a consistent development environment. |
61 | 95 |
|
| 96 | +1. **Prerequisites** |
| 97 | + - Visual Studio Code |
| 98 | + - Docker |
| 99 | + - VS Code Remote - Containers extension |
62 | 100 |
|
63 |
| -Additional documentation may be found here |
64 |
| -https://www.milesburton.com/w/index.php/Dallas_Temperature_Control_Library |
| 101 | +2. **Development Commands** |
| 102 | + Within the dev container, use: |
| 103 | + - `arduino-build` - Compile the library and examples |
| 104 | + - `arduino-test` - Run the test suite |
| 105 | + - `arduino-build-test` - Complete build and test process |
65 | 106 |
|
66 |
| -# License |
| 107 | + > Note: Currently compiling against arduino:avr:uno environment |
67 | 108 |
|
68 |
| -MIT License |
| 109 | +## ✨ Credits |
69 | 110 |
|
70 |
| -Copyright (c) [2025] [Miles Burton] |
| 111 | +- Original development by Miles Burton <[email protected]> |
| 112 | +- Multiple sensor support by Tim Newsome <[email protected]> |
| 113 | +- Address-based temperature reading by Guil Barros [[email protected]] |
| 114 | +- Async mode by Rob Tillaart [[email protected]] |
71 | 115 |
|
72 |
| -Permission is hereby granted, free of charge, to any person obtaining a copy |
73 |
| -of this software and associated documentation files (the "Software"), to deal |
74 |
| -in the Software without restriction, including without limitation the rights |
75 |
| -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
76 |
| -copies of the Software, and to permit persons to whom the Software is |
77 |
| -furnished to do so, subject to the following conditions: |
| 116 | +## 📄 License |
78 | 117 |
|
79 |
| -The above copyright notice and this permission notice shall be included in all |
80 |
| -copies or substantial portions of the Software. |
| 118 | +MIT License | Copyright (c) 2025 Miles Burton |
81 | 119 |
|
82 |
| -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
83 |
| -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
84 |
| -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
85 |
| -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
86 |
| -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
87 |
| -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
88 |
| -SOFTWARE. |
| 120 | +Full license text available in [LICENSE](LICENSE) file. |
0 commit comments