diff --git a/Misc/Temp-Monitor/firmware.py b/Misc/Temp-Monitor/firmware.py new file mode 100644 index 0000000..b0dca32 --- /dev/null +++ b/Misc/Temp-Monitor/firmware.py @@ -0,0 +1,38 @@ +import time +from machine import Pin + +clock = Pin(2) +data = Pin(4) + +SLEEP_TIME = 1 + + +def read_adc(): + # Wait for DRDY + while data.high(): + pass + + value = 0 + for i in range(24): + clock.high() + time.sleep_us(SLEEP_TIME) + + value |= data.value() << (23 - i) + + clock.low() + time.sleep_us(SLEEP_TIME) + + # Shift 3 more bits + for i in range(3): + clock.high() + time.sleep_us(SLEEP_TIME) + clock.low() + time.sleep_us(SLEEP_TIME) + + return value + + +while True: + value = float(read_adc()) / (2**24-1) + print(f"{value:f}") + time.sleep(0.1)