Skip to content

Commit d5a1a36

Browse files
committed
feat: Add dev container to make library development more streamlined. Updated README.md to be more readable
1 parent 486bd51 commit d5a1a36

File tree

4 files changed

+99
-98
lines changed

4 files changed

+99
-98
lines changed

β€Ž.devcontainer/Dockerfile

+5-20
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,13 @@ COPY arduino-cli.yaml /root/.arduino15/arduino-cli.yaml
2828
# Install build essentials
2929
RUN apt-get update && apt-get install -y build-essential
3030

31-
# Install common Arduino libraries
31+
# Install Arduino cores for ESP8266 and ESP32
32+
RUN arduino-cli core install esp8266:esp8266 esp32:esp32
33+
34+
# Install only required dependencies for DallasTemperature library
3235
RUN arduino-cli lib install \
3336
"OneWire" \
34-
"DallasTemperature" \
35-
"Adafruit BusIO" \
36-
"Adafruit Unified Sensor" \
37-
"DHT sensor library" \
38-
"WiFiManager" \
39-
"ArduinoJson" \
40-
"PubSubClient" \
41-
"ESP8266WiFi" \
42-
"ESP32" \
43-
"Wire" \
44-
"SPI" \
45-
"FastLED" \
46-
"NTPClient" \
47-
"AsyncTCP" \
48-
"ESPAsyncTCP" \
49-
"ESPAsyncWebServer"
37+
"ArduinoUnit" # For testing
5038

5139
# Verify library installation
5240
RUN arduino-cli lib list
@@ -55,9 +43,6 @@ RUN arduino-cli lib list
5543
COPY update-libraries.sh /usr/local/bin/
5644
RUN chmod +x /usr/local/bin/update-libraries.sh
5745

58-
# Add a weekly cron job to update libraries
59-
RUN (crontab -l 2>/dev/null; echo "0 0 * * 0 /usr/local/bin/update-libraries.sh > /var/log/library-updates.log 2>&1") | crontab -
60-
6146
# Add aliases for build operations
6247
RUN echo 'alias arduino-build="./build.sh build"' >> /home/vscode/.bashrc && \
6348
echo 'alias arduino-test="./build.sh test"' >> /home/vscode/.bashrc && \

β€Ž.devcontainer/update-libraries.sh

+7-17
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,15 @@ echo "Updating installed libraries..."
88
arduino-cli lib update-index
99
arduino-cli lib upgrade
1010

11+
# Update Arduino cores
12+
echo "Updating ESP8266 and ESP32 cores..."
13+
arduino-cli core install esp8266:esp8266
14+
arduino-cli core install esp32:esp32
15+
1116
# List of libraries to ensure are installed/updated
1217
LIBRARIES=(
1318
"OneWire"
14-
"DallasTemperature"
15-
"Adafruit BusIO"
16-
"Adafruit Unified Sensor"
17-
"DHT sensor library"
18-
"WiFiManager"
19-
"ArduinoJson"
20-
"PubSubClient"
21-
"ESP8266WiFi"
22-
"ESP32"
23-
"Wire"
24-
"SPI"
25-
"FastLED"
26-
"NTPClient"
27-
"AsyncTCP"
28-
"ESPAsyncTCP"
29-
"ESPAsyncWebServer"
19+
"ArduinoUnit"
3020
)
3121

3222
echo "Checking and installing libraries..."
@@ -43,4 +33,4 @@ done
4333
echo "Verifying all libraries are up to date..."
4434
arduino-cli lib list
4535

46-
echo "Library update complete!"
36+
echo "Library update complete!"

β€ŽREADME.md

+85-53
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,120 @@
1+
2+
# 🌑️ Arduino Temperature Control Library
3+
14
[![Arduino CI](https://github.com/milesburton/Arduino-Temperature-Control-Library/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
25
[![Arduino-lint](https://github.com/milesburton/Arduino-Temperature-Control-Library/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/AS5600/actions/workflows/arduino-lint.yml)
36
[![JSON check](https://github.com/milesburton/Arduino-Temperature-Control-Library/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/AS5600/actions/workflows/jsoncheck.yml)
47
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/milesburton/Arduino-Temperature-Control-Library/blob/master/LICENSE)
58
[![GitHub release](https://img.shields.io/github/release/milesburton/Arduino-Temperature-Control-Library.svg?maxAge=3600)](https://github.com/milesburton/Arduino-Temperature-Control-Library/releases)
69

10+
A robust and feature-complete Arduino library for Maxim Temperature Integrated Circuits.
11+
12+
## πŸ“Œ Supported Devices
713

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
920

10-
## Usage
21+
## πŸš€ Installation
1122

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
1329

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
1435

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
2137

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)
2242

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>
2647

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
3150

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);
3453

54+
void setup(void) {
55+
Serial.begin(9600);
56+
sensors.begin();
57+
}
3558

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+
```
3668
37-
#define REQUIRESNEW
69+
## πŸ› οΈ Advanced Features
3870
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
4075
41-
#define REQUIRESALARMS
76+
### Configuration Options
4277
78+
You can slim down the code by defining the following at the top of DallasTemperature.h:
4379
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+
```
4584

46-
Finally, please include OneWire from Paul Stoffregen in the library manager before you begin.
85+
## πŸ“š Additional Documentation
4786

48-
## Credits
87+
Visit our [Wiki](https://www.milesburton.com/w/index.php/Dallas_Temperature_Control_Library) for detailed documentation.
4988

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
5890

91+
If you want to contribute to the library development:
5992

60-
## Website
93+
### Using Dev Container
94+
The project includes a development container configuration for VS Code that provides a consistent development environment.
6195

96+
1. **Prerequisites**
97+
- Visual Studio Code
98+
- Docker
99+
- VS Code Remote - Containers extension
62100

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
65106

66-
# License
107+
> Note: Currently compiling against arduino:avr:uno environment
67108
68-
MIT License
109+
## ✨ Credits
69110

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]]
71115

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
78117

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
81119

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.

β€Žbuild.sh

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22

3-
# Note this is intended for use within the devcontainer
4-
53
# Set error handling
64
set -e
75

@@ -19,17 +17,13 @@ compile_for_board() {
1917
local fqbn=$1
2018
local sketch=$2
2119
echo "πŸ“¦ Compiling $sketch for $fqbn..."
22-
arduino-cli compile --fqbn $fqbn "$sketch"
20+
arduino-cli compile --fqbn $fqbn "$sketch" --library .
2321
}
2422

2523
# Function to build library and examples
2624
build() {
2725
echo "πŸ”¨ Building library and examples..."
2826

29-
# Compile library
30-
echo "πŸ“š Installing library..."
31-
arduino-cli lib install .
32-
3327
# Compile all examples
3428
echo "πŸ” Compiling examples..."
3529
for example in examples/*/*.ino; do
@@ -69,4 +63,4 @@ case "${1:-all}" in
6963
;;
7064
esac
7165

72-
echo "βœ… Process completed!"
66+
echo "βœ… Process completed!"

0 commit comments

Comments
Β (0)