Thermistor utilities
A python based library implementing models to convert thermistor values from temperature to resistance and vice versa.
Steinhart--Hart model
Implementation precision
How to use
# import the Steinhart--Hart and or the Beta converter
from thermistor_utils import SH_converter
Create a converter from A, B, and C coefficients:
A, B, C = (0.0008402250578523375, 0.00025963477647737156, 1.5674403473853433e-07, )
conv = SH_converter(A, B, C)
If they're not available the converter could compute the values from three evenly spaced readings of temperature and resistance.
Create the converter from temp/res readings:
readings = (
(0, 27445),
(25, 10000),
(50, 4160),
)
conv = SH_converter.from_points(readings)
Printing the coefficients in a form suitable for subsequent use in python and C:
print(repr(conv))
# SH_converter(0.0008402250578523375, 0.00025963477647737156, 1.5674403473853433e-07, 0, 50)
print(conv.to_cstr())
# {0.0008402250578523375, 0.00025963477647737156, 1.5674403473853433e-07, 0, 50}
# compact but less precise representation
# (inverse of coefficients and no temperature range)
print(conv.to_cstr(compact=True, with_temps=False))
# {1./1190, 1./3852, 1./6379828}
Use the reference implementation in C (example-1.c):
#include <stdio.h>
#include <thermistor_utils.h>
int main(void)
{
struct sh_s coefficients = {
0.0008402250578523375,
0.00025963477647737156,
1.5674403473853433e-07
};
// 25C to Ohm and 10k Ohm to Celsius
double R_at_25 = sh_resistance(coefficients, 25),
T_at_10000 = sh_temperature(coefficients, 10000);
printf("25 Celsius -> %.0f Ohms\n", R_at_25);
printf("10k Ohms -> %.0f Celsius\n", T_at_10000);
}
To compile and run from the examples directory:
$ mkdir -p ../bin
$ gcc -o ../bin/example-1 \
-I../src/include \
../src/sh_converter.c \
-lm \
example-1.c
$ ../bin/example-1
25 Celsius -> 10000 Ohms
10k Ohms -> 25 Celsius
Beta model
Implementation precision
How to use
# import the Steinhart--Hart and or the Beta converter
from thermistor_utils import Beta_converter
Create a converter from beta values:
beta, R0, T0 = (3380, 10000, 25)
conv = Beta_converter(beta, R0, T0)
Printing the beta values in a form suitable for subsequent use in python and C:
print(repr(conv))
# Beta_converter(3380, 10000, 25)
print(conv.to_cstr())
# {3380, 10000, 25}
Use the reference implementation in C (example-2.c):
#include <stdio.h>
#include <thermistor_utils.h>
int main(void)
{
struct beta_s bpar = {3380, 10000, 25};
// 25C to Ohm and 10k Ohm to Celsius
double R_at_25 = beta_resistance(bpar, 25),
T_at_10000 = beta_temperature(bpar, 10000);
printf("25 Celsius -> %.0f Ohms\n", R_at_25);
printf("10k Ohms -> %.0f Celsius\n", T_at_10000);
}
To compile and run from the examples directory:
$ mkdir -p ../bin
$ gcc -o ../bin/example-2 \
-I../src/include \
../src/beta_converter.c \
-lm \
example-2.c
$ ../bin/example-2
25 Celsius -> 10000 Ohms
10k Ohms -> 25 Celsius
Metadata
Release files for thermistor-utils 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| thermistor_utils-0.0.4.tar.gz | 5.3 kB | Without provenance | Details for thermistor_utils-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| thermistor_utils-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for thermistor_utils-0.0.4-py3-none-any.whl |
Total release size: 13.7 kB
Release files / thermistor_utils-0.0.4.tar.gz
| Download URL | thermistor_utils-0.0.4.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a648689bb6e55129cb14403aae985068246e1365d74b154db33f2a86a38a415c
|
|
BLAKE2b-256 checksum How to use checksums |
b466f90da1f82fe207fe9cf677bb24cfd8b133345c940266dbcae7e1dbafa6fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.8.0
|
Release files / thermistor_utils-0.0.4-py3-none-any.whl
| Download URL | thermistor_utils-0.0.4-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
00923bc0e9d9728e3c2db5f10c29801baa9fa4842750f41ab5451365b2fc2c7c
|
|
BLAKE2b-256 checksum How to use checksums |
4ccebb89b5e80b1c1dd1e861bdfc105791a48abb63234f555bd78a2cef288d0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.8.0
|
Security for thermistor-utils 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.