Compare commits
2 commits
f481e4de38
...
12753d93fb
Author | SHA1 | Date | |
---|---|---|---|
|
12753d93fb | ||
|
f46e58b4e8 |
1
Misc/Temp-Monitor/main.py
Normal file
1
Misc/Temp-Monitor/main.py
Normal file
|
@ -0,0 +1 @@
|
|||
import temperature_monitor
|
|
@ -1,4 +1,5 @@
|
|||
import math
|
||||
import time
|
||||
from cs1237 import CS1237
|
||||
from machine import Pin
|
||||
|
||||
|
@ -10,7 +11,7 @@ ADC_RATE = 40
|
|||
cs1237 = CS1237(clock, data)
|
||||
cs1237.config(gain=1, rate=ADC_RATE)
|
||||
|
||||
print(repr(cs1237.get_config()))
|
||||
cs1237.get_config()
|
||||
|
||||
THERMISTOR_BETA = 3950.0
|
||||
THERMISTOR_R25 = 10e3
|
||||
|
@ -22,6 +23,7 @@ FILTER_RC = 1
|
|||
FILTER_A = 1 / ADC_RATE / (FILTER_RC / 1 / ADC_RATE)
|
||||
|
||||
temperature_filtered = 25
|
||||
last_report = time.ticks_ms()
|
||||
while True:
|
||||
raw_value = cs1237.read()
|
||||
value = float(raw_value) / (2**24 - 1)
|
||||
|
@ -37,4 +39,8 @@ while True:
|
|||
temperature_filtered * (1 - FILTER_A) + temperature * FILTER_A
|
||||
)
|
||||
|
||||
print(temperature_filtered)
|
||||
now = time.ticks_ms()
|
||||
elapsed = now - last_report
|
||||
if elapsed >= 200 or elapsed < 0:
|
||||
print(f"{temperature_filtered:.6f}")
|
||||
last_report = now
|
Loading…
Reference in a new issue