GY-63_MS5611/libraries/MAX31850/README.md

172 lines
5.8 KiB
Markdown
Raw Normal View History

2022-11-16 14:52:35 -05:00
[![Arduino CI](https://github.com/RobTillaart/MAX31850/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/MAX31850/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/MAX14661/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/MAX31850/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/MAX14661/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/MAX31850/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/MAX31850.svg?maxAge=3600)](https://github.com/RobTillaart/MAX31850/releases)
2023-01-23 09:19:15 -05:00
2022-11-16 14:52:35 -05:00
# MAX31850
Arduino library for the MAX31850 / MAX31851 thermocouple sensor.
2023-01-23 09:19:15 -05:00
2022-11-16 14:52:35 -05:00
## Description
**WARNING EXPERIMENTAL** needs more testing (no hardware yet).
(feedback welcome)
his MAX31850 library is not a full featured library for the MAX31850 family.
The MAX31850/1 is a Cold-Junction Compensated, 1-Wire Thermocouple-to-Digital Converter.
The MAX31850/1 supports K-, J-, N-, T-, S-, R-, and E-type thermocouples. (to be tested).
The library supports both the MAX31850 and MAX31851 but is limited to one sensor per pin.
The only feature the class supports is the asynchronous reading of the temperature.
2023-01-23 09:19:15 -05:00
This allowed the class to be both minimal in size and non-blocking.
In fact the class has no support for a synchronous read in one call.
2022-11-16 14:52:35 -05:00
This choice will teach people how to work in a non-blocking way from the start.
2023-01-23 09:19:15 -05:00
Finally this library will probably make it easier to use a MAX31850 with processing
2022-11-16 14:52:35 -05:00
boards or IC's with small memory footprint.
2023-01-23 09:19:15 -05:00
The MAX31851 is (for now) functional identical to MAX31850.
2022-11-16 14:52:35 -05:00
## Hardware connection
```
// PROCESSOR MAX31850 THERMOCOUPLE
// +---------------+
// GND 1 | o o | T+
// DATA 2 | o |
// VCC 3 | o o | T-
// | |
// | oooo |
// +---------------+
// 4 address pins.
```
2023-01-23 09:19:15 -05:00
This library supports only one MAX31850 per Arduino/ MCU IO pin.
2022-11-16 14:52:35 -05:00
2023-01-23 09:19:15 -05:00
#### Pull up resistor
2022-11-16 14:52:35 -05:00
2023-01-23 09:19:15 -05:00
Connect a pull-up resistor 4.7 KOhm between DATA (pin 3) and VCC (pin 2).
When the wires are longer this resistor needs to be smaller.
2022-11-16 14:52:35 -05:00
An **indicative** table for pull up resistors, (E12 series), to get started.
2023-01-23 09:19:15 -05:00
Note: thicker wires require smaller resistors (typically 1 step in E12 series)
2022-11-16 14:52:35 -05:00
2023-01-23 09:19:15 -05:00
| Length | 5.0 Volt | 3.3 Volt |
|----------------:|-----------:|-----------:|
| 10cm (4") | 10K0 | 6K8 |
| 20cm (8") | 8K2 | 4K7 |
| 50cm (20") | 4K7 | 3K3 |
| 100cm (3'4") | 3K3 | 2K2 |
| 200cm (6'8") | 2K2 | 1K0 |
| 500cm (16'8") | 1K0 | \* |
| longer | \* | \* |
2022-11-16 14:52:35 -05:00
2023-01-23 09:19:15 -05:00
\* = no info, smaller
2022-11-16 14:52:35 -05:00
## Interface
2023-01-23 09:19:15 -05:00
```cpp
#include "MAX31850.h"
```
2022-11-16 14:52:35 -05:00
#### Constructor
- **explicit MAX31850(OneWire \* oneWire)** constructor.
2023-01-23 09:19:15 -05:00
- **bool begin(uint8_t retries = 3)** initialize the library.
2022-11-16 14:52:35 -05:00
Returns true if addresses are found.
2023-01-23 09:19:15 -05:00
Nr of retries can be adjusted if needed, default 3.
2022-11-16 14:52:35 -05:00
- **bool getAddress(uint8_t \* buffer)** get the address if found.
2023-01-23 09:19:15 -05:00
2022-11-16 14:52:35 -05:00
#### Read the sensor
2023-01-23 09:19:15 -05:00
- **void requestTemperatures(void)** Asynchronous request to start conversion.
- **bool isConversionComplete(void)** CHeck if requested conversion is done.
2022-11-16 14:52:35 -05:00
- **float read(void)** read the data from the sensor.
Returns the temperature of the thermoCouple as this is most often needed.
2023-01-23 09:19:15 -05:00
- **float getTempTC(void)** returns temperature of the ThermoCouple from cache.
One must call **read()** again to get new measurements.
- **float getTempInternal(void)** returns internal temperature from cache.
One must call **read()** again to get new measurements.
2022-11-16 14:52:35 -05:00
2023-01-23 09:19:15 -05:00
#### Other
- **uint8_t getAddressPins()** binary form of the 4 address bits. 0x00..0x0F.
- **uint8_t getErrorCode()** get the internal error code. See below.
- **bool setTypeTC(char typeTC)** typeTC is one char from E J K N R S T
- **uint8_t getTypeTC()** returns the current TC type.
2022-11-16 14:52:35 -05:00
## Types of thermocouples
The MAX31850 comes in MAX31850E.. MAX31850T types reflecting the version of TC to use.
2023-01-23 09:19:15 -05:00
| Sensor type | SC in µV/°C | Temp Range in °C | Material | notes |
|:-------------:|:--------------|:-------------------|:----------------------------|:------------|
| E_TC | 76.373 | -270 to +1000 | Constantan Chromel |
| J_TC | 57.953 | -210 to +1200 | Constantan Iron |
| K_TC | 41.276 | -270 to +1372 | Alumel Chromel | most used |
| N_TC | 36.256 | -270 to +1300 | Nisil Nicrosil |
| R_TC | 10.506 | -50 to +1768 | Platinum Platinum/Rhodium |
| S_TC | 9.587 | +50 to +1768 | Platinum Platinum/Rhodium |
| T_TC | 52.18 | -270 to +400 | Constantan Copper |
2022-11-16 14:52:35 -05:00
(MAX31851 idem)
## Error codes
| name | value |
|:--------------------------|:-------:|
2023-01-23 09:19:15 -05:00
| MAX31850_OK | 0 |
| MAX31850_ERR_SHORT_OPEN | 1 |
| MAX31850_ERR_SHORT_GND | 2 |
| MAX31850_ERR_SHORT_VDD | 4 |
2022-11-16 14:52:35 -05:00
## Future
2023-01-23 09:19:15 -05:00
#### Must
2022-11-16 14:52:35 -05:00
- improve documentation
- get hardware to test (sponsors welcome)
- test on different platforms
2023-01-23 09:19:15 -05:00
#### Should
- investigate different thermocouples
2022-11-16 14:52:35 -05:00
- test with different platforms
2023-01-23 09:19:15 -05:00
- has the 31851 special features to implement?
2022-11-16 14:52:35 -05:00
#### could
2023-01-23 09:19:15 -05:00
- extend error handling
- expand to multi sensor per pin.
2022-11-16 14:52:35 -05:00
- first get one sensor working
2023-01-23 09:19:15 -05:00
- investigate range checking on type TC
- need setType() and more.
- need lower upper range = int16_t will do.
- add CRC check
- + error code
#### Wont
2022-11-16 14:52:35 -05:00