Skip to content

Commit

Permalink
feat: Add dev container to make library development more streamlined.…
Browse files Browse the repository at this point in the history
… Updated README.md to be more readable
  • Loading branch information
milesburton committed Jan 9, 2025
1 parent 486bd51 commit d5a1a36
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 98 deletions.
25 changes: 5 additions & 20 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,13 @@ COPY arduino-cli.yaml /root/.arduino15/arduino-cli.yaml
# Install build essentials
RUN apt-get update && apt-get install -y build-essential

# Install common Arduino libraries
# Install Arduino cores for ESP8266 and ESP32
RUN arduino-cli core install esp8266:esp8266 esp32:esp32

# Install only required dependencies for DallasTemperature library
RUN arduino-cli lib install \
"OneWire" \
"DallasTemperature" \
"Adafruit BusIO" \
"Adafruit Unified Sensor" \
"DHT sensor library" \
"WiFiManager" \
"ArduinoJson" \
"PubSubClient" \
"ESP8266WiFi" \
"ESP32" \
"Wire" \
"SPI" \
"FastLED" \
"NTPClient" \
"AsyncTCP" \
"ESPAsyncTCP" \
"ESPAsyncWebServer"
"ArduinoUnit" # For testing

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

# Add a weekly cron job to update libraries
RUN (crontab -l 2>/dev/null; echo "0 0 * * 0 /usr/local/bin/update-libraries.sh > /var/log/library-updates.log 2>&1") | crontab -

# Add aliases for build operations
RUN echo 'alias arduino-build="./build.sh build"' >> /home/vscode/.bashrc && \
echo 'alias arduino-test="./build.sh test"' >> /home/vscode/.bashrc && \
Expand Down
24 changes: 7 additions & 17 deletions .devcontainer/update-libraries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,15 @@ echo "Updating installed libraries..."
arduino-cli lib update-index
arduino-cli lib upgrade

# Update Arduino cores
echo "Updating ESP8266 and ESP32 cores..."
arduino-cli core install esp8266:esp8266
arduino-cli core install esp32:esp32

# List of libraries to ensure are installed/updated
LIBRARIES=(
"OneWire"
"DallasTemperature"
"Adafruit BusIO"
"Adafruit Unified Sensor"
"DHT sensor library"
"WiFiManager"
"ArduinoJson"
"PubSubClient"
"ESP8266WiFi"
"ESP32"
"Wire"
"SPI"
"FastLED"
"NTPClient"
"AsyncTCP"
"ESPAsyncTCP"
"ESPAsyncWebServer"
"ArduinoUnit"
)

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

echo "Library update complete!"
echo "Library update complete!"
138 changes: 85 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,120 @@

# 🌡️ Arduino Temperature Control Library

[![Arduino CI](https://github.com/milesburton/Arduino-Temperature-Control-Library/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![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)
[![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)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/milesburton/Arduino-Temperature-Control-Library/blob/master/LICENSE)
[![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)

A robust and feature-complete Arduino library for Maxim Temperature Integrated Circuits.

## 📌 Supported Devices

# Arduino Library for Maxim Temperature Integrated Circuits
- DS18B20
- DS18S20 (⚠️ Known issues with this series)
- DS1822
- DS1820
- MAX31820
- MAX31850

## Usage
## 🚀 Installation

This library supports the following devices :
### 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

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

* DS18B20
* DS18S20 - Please note there appears to be an issue with this series.
* DS1822
* DS1820
* MAX31820
* MAX31850
## 📝 Basic Usage

1. **Hardware Setup**
- 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.
- 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)

You will need a pull-up resistor of about 5 KOhm between the 1-Wire data line
and your 5V power. If you are using the DS18B20, ground pins 1 and 3. The
centre pin is the data line '1-wire'.
2. **Code Example**
```cpp
#include <OneWire.h>
#include <DallasTemperature.h>

In case of temperature conversion problems (result is `-85`), strong pull-up setup may be necessary. See section
_Powering the DS18B20_ in
[DS18B20 datasheet](https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf) (page 7)
and use `DallasTemperature(OneWire*, uint8_t)` constructor.
// Data wire is connected to GPIO 4
#define ONE_WIRE_BUS 4

We have included a "REQUIRESNEW" and "REQUIRESALARMS" definition. If you
want to slim down the code feel free to use either of these by including
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup(void) {
Serial.begin(9600);
sensors.begin();
}

void loop(void) {
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0);
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.println("°C");
delay(1000);
}
```
#define REQUIRESNEW
## 🛠️ Advanced Features
or
- Multiple sensors on the same bus
- Temperature conversion by address (`getTempC(address)` and `getTempF(address)`)
- Asynchronous mode (added in v3.7.0)
- Configurable resolution
#define REQUIRESALARMS
### Configuration Options
You can slim down the code by defining the following at the top of DallasTemperature.h:
at the top of DallasTemperature.h
```cpp
#define REQUIRESNEW // Use if you want to minimise code size
#define REQUIRESALARMS // Use if you need alarm functionality
```

Finally, please include OneWire from Paul Stoffregen in the library manager before you begin.
## 📚 Additional Documentation

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

The OneWire code has been derived from
http://www.arduino.cc/playground/Learning/OneWire.
Miles Burton <miles@mnetcs.com> originally developed this library.
Tim Newsome <nuisance@casualhacker.net> added support for multiple sensors on
the same bus.
Guil Barros [gfbarros@bappos.com] added getTempByAddress (v3.5)
Note: these are implemented as getTempC(address) and getTempF(address)
Rob Tillaart [rob.tillaart@gmail.com] added async modus (v3.7.0)
## 🔧 Library Development

If you want to contribute to the library development:

## Website
### Using Dev Container
The project includes a development container configuration for VS Code that provides a consistent development environment.

1. **Prerequisites**
- Visual Studio Code
- Docker
- VS Code Remote - Containers extension

Additional documentation may be found here
https://www.milesburton.com/w/index.php/Dallas_Temperature_Control_Library
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

# License
> Note: Currently compiling against arduino:avr:uno environment
MIT License
## ✨ Credits

Copyright (c) [2025] [Miles Burton]
- 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]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
## 📄 License

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
MIT License | Copyright (c) 2025 Miles Burton

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Full license text available in [LICENSE](LICENSE) file.
10 changes: 2 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

# Note this is intended for use within the devcontainer

# Set error handling
set -e

Expand All @@ -19,17 +17,13 @@ compile_for_board() {
local fqbn=$1
local sketch=$2
echo "📦 Compiling $sketch for $fqbn..."
arduino-cli compile --fqbn $fqbn "$sketch"
arduino-cli compile --fqbn $fqbn "$sketch" --library .
}

# Function to build library and examples
build() {
echo "🔨 Building library and examples..."

# Compile library
echo "📚 Installing library..."
arduino-cli lib install .

# Compile all examples
echo "🔍 Compiling examples..."
for example in examples/*/*.ino; do
Expand Down Expand Up @@ -69,4 +63,4 @@ case "${1:-all}" in
;;
esac

echo "✅ Process completed!"
echo "✅ Process completed!"

0 comments on commit d5a1a36

Please sign in to comment.