#!/usr/bin/env python3
import time
import board
import math
import datetime

import adafruit_pcf8591.pcf8591 as PCF
from adafruit_pcf8591.analog_in import AnalogIn

i2c=board.I2C()
pcf=PCF.PCF8591(i2c)

thermistor=AnalogIn(pcf,PCF.A0)
R=10000/(65535/thermistor.value - 1)
def steinhart_temperature_C(r,Ro=10000.0,To=25.0,beta=3950.0):
    steinhart=math.log(r/Ro)/beta
    steinhart+=1.0/(To + 273.15)
    steinhart=(1.0/steinhart) - 273.15
    return steinhart
while True:
    print(steinhart_temperature_C(R),(datetime.datetime.now()))
    time.sleep(60)