Skip to content

read NTC thermistor temperature wired in a potential divider

License

Notifications You must be signed in to change notification settings

scruss/micropython-simple-thermistor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

micropython-simple-thermistor

read NTC thermistor temperature wired in a potential divider

WILL NOT WORK WITH

  • ESP8266 (limited 1 V max ADC)
  • W600 (no ADC!)

WILL NOT IMPLEMENT

  • High-side thermistor
  • °F conversion

TODO

  • some docs would be nice
  • implement:
    • Beta calculation from known second temperature and resistance (T₁, R₁): β(T₀/T₁) = ln(R₁/R₀) / (1/T₁ - 1/T₀)
    • Steinhart-Hart three-term calculation
  • platform testing:
    • rp2
    • EPS32
    • STM32/pyboard
    • SAMD
    • external ADC?
  • thermistor type testing

Sample Code

# MicroPython, Raspberry Pi Pico
# pylint: disable=E0401
# -*- coding: utf-8 -*-

import machine
import time
from simple_thermistor import Thermistor


# setup for KY-013-alike thermistor on GPIO 26
t = Thermistor(
    adc=machine.ADC(
        26
    ),  # ADC object with read_u16() method returning 0–65535
    beta=3950,
    r0=10000,  # thermistor nominal resistance of 10 kΩ at 25 °C
    t0=Thermistor.fromC(25),  # everything is Kelvin internally
    resistor=10000,  # high side resistor of 10 kΩ
)
while True:
    print(
        "%6.1f °C / %.1f Ω"
        % (Thermistor.toC(t.temperature()), t.resistance())
    )
    time.sleep(5)

About

read NTC thermistor temperature wired in a potential divider

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages