Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions .not-cargo/config

This file was deleted.

39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

31 changes: 13 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "simple_max31865"
version = "1.0.0"
authors = ["Rudi Horn <dyn-git@rudi-horn.de>", "Emeric Martineau <11473190+emeric-martineau@users.noreply.github.com>"]
name = "simple-max31865"
version = "1.0.0" # Bumped for initial publish (stable API, but first release)
authors = ["Alan Robertson <alanr@unix.sh>"]
keywords = ["embedded-hal-v1", "rtd-sensor", "max31865"]
categories = ["embedded", "no-std", "hardware-support"]
description = "Simplified driver for the MAX31865 RTD to Digital converter (Raspberry Pi focus)"
documentation = "https://github.com/emeric-martineau/rs-max31865"
repository = "https://github.com/emeric-martineau/rs-max31865.git"
categories = ["embedded", "hardware-support"]
description = "Easy-to-use driver for the MAX31865 RTD to Digital converter (Raspberry Pi focus)"
documentation = "https://docs.rs/simple-max31865" # Standard for crates.io; will auto-generate on publish
repository = "https://github.com/Alan-R/simple-max31865-rs"
readme = "README.md"
license = "MIT OR Apache-2.0"
edition = "2021"
Expand All @@ -15,17 +15,12 @@ edition = "2021"
rppal = { version = "0.17", features = ["embedded-hal"] } # Enables embedded-hal v1 traits for SpiBus, OutputPin, etc.
embedded-hal = "1.0" # Ensure v1

[target.thumbv7m-none-eabi.dev-dependencies]
cortex-m-semihosting = "0.3.7"
cortex-m = "0.7.2"
cortex-m-rt = "0.6.13"
panic-halt = "0.2.0"
stm32f1xx-hal = { version = "0.7.0", features = ["stm32f103"] }
embedded-graphics = "0.6.2"
ssd1306 = "0.5.1"
[dev-dependencies]
clap = { version = "4.0", features = ["derive"] } # For CLI args in examples

#[target.'cfg(unix)'.dev-dependencies]
#linux-embedded-hal = "0.3.0"
[[example]]
name = "ice_bath_test"
path = "examples/ice_bath_test.rs"

[profile.test]
lto = "thin" # Enables link-time optimization: Strips unused symbols (e.g., test harness bloat) like in your main binary
Expand All @@ -42,4 +37,4 @@ test = true
path = "src/lib.rs"

[features]
doc = []
# Removed empty 'doc' feature; add back if needed for conditional compilation
96 changes: 85 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,80 @@
# `max31865`

A generic driver for the MAX31865 RTD to Digital converter
# simple-max31865

## [Documentation](https://rudihorn.github.io/max31865/max31865/index.html)
[![Crates.io](https://img.shields.io/crates/v/simple-max31865.svg)](https://crates.io/crates/simple-max31865)
[![Docs.rs](https://docs.rs/simple-max31865/badge.svg)](https://docs.rs/simple-max31865)
[![License](https://img.shields.io/badge/license-MIT%20or%20Apache-2.0-blue.svg)](LICENSE-APACHE)

## [Examples](https://github.com/rudihorn/max31865/tree/extra_examples/examples)
A Raspberry Pi driver for the MAX31865 RTD to Digital converter

## [Documentation](https://docs.rs/simple-max31865)

## [Examples](https://github.com/Alan-R/simple-max31865-rs/tree/main/examples)
Examples are in the *examples* directory from the root of the tree.

## What works

- reading the raw value and the converted temperature value
- setting the ohmic calibration value
- configuring V_BIAS, one shot, filter frequency
- Reading the raw value and the converted temperature value either in f64 or scaled integer forms.
- Detecting and recovering from errors.
- Setting the ohmic calibration value.
- Interaction with the chip works well.
- Reading temperatures and resistances from PT-100 sensors.
- Fault detection and recovery.
- Support for Raspberry Pi (via `rppal` crate).
- Tested with Max31856 hardware from Playing With Fusion
and an Adafruit clone board, both with a PT100 sensor.

## TODO
See src/lib.rs for details.

Future: Testing/Mocking
- Stub off hardware access by creating abstract implementations of Trait(s) and create minimal Mock unit tests (under a "mock" feature).
- Create mock implementation of SPI and Pin abstractions (controlled by a "mock" feature).
- Create "mock" hardware tests which exercise the APIs with mock feature.

Many other thoughts listed in the `src/lib.rs` file.

## Quick Start

### Raspberry Pi OS Configuration

- You need a Raspberry Pi with a working Max31865 HAT attached with a known chip select pin.
- enable GPIO/SPI via raspi-config or your OS settings before running.

### Add to `Cargo.toml`

[dependencies]
simple-max31865 = "1.0"

### Basic Usage (Raspberry Pi)

- [ ] Fault tolerance / detection / status
use simple_max31865::{decode_fault_status, RTDReader, RTDLeads, FilterHz};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut max = RTDReader::new(24, RTDLeads::Three, FilterHz::Sixty)?; // CS pin 24, 3-wire PT100, 60Hz filter
let temperature = max.get_temperature()?;
println!("Temperature: {:.2}°C", temperature);
let resistance = max.get_resistance()?;
println!("Resistance: {:.2} Ω", resistance);

match max.read_temp_100() {
Ok(temp) => println!("Temperature: {:.2}°C", temp as f64 / 100.0),
Err(e) => {
if max.is_max_fault(&e) {
let status = max.read_fault_status()?;
println!("Fault: {:?}", decode_fault_status(status)); // Fixed: No ? needed
let _ = max.clear_fault();
}
return Err(e.into());
}
}
Ok(())
}

## Examples

There is an example for the Raspberry pi in the examples directory.
Full examples (e.g., basic reading, fault handling) will be added to the examples/ directory soon.
The Quick Start above demonstrates core usage.

## License

Expand All @@ -29,9 +85,27 @@ Licensed under either of
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.

# References

- [MAX31865 Datasheet](https://datasheets.maximintegrated.com/en/ds/MAX31865.pdf)
- [PT100 Sensor wiring diagrams](https://www.playingwithfusion.com/docs/1203) - a
great reference on wiring the various types of PT100 sensors.

# Credits and License

The simple-max31865 crate is derived from version 1.0.0 of
the [rs-max31865](https://github.com/emeric-martineau/rs-max31865)
crate by Rudi Horn and Emeric Martineau, with significant modifications:

- Greatly simplified, opaque API hiding hardware details.
- Added Raspberry Pi support via rppal.
- Floating-point temperature and resistance reads.

Some original code snippets (e.g., register configs) and temperature conversion etc
are reused under the MIT/Apache-2.0 license. See the original repo for their contributions.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the
work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
additional terms or conditions.

additional terms or conditions.
Loading