from machine import Pin, ADC, I2C
from ssd1306 import SSD1306_I2C
import utime
import math
x = 128
y = 64
BETA = 3950
i2c = I2C(0, scl = Pin(1), sda = Pin(0), freq=200000)
adc = ADC(28)
oled = SSD1306_I2C(x, y, i2c)
oled.text(str(adc.read_u16()), 0, 0)
oled.show()
def get_temperautre():
celsius = 1 / (math.log(1 / (65535 / adc.read_u16() - 1 )) / BETA + 1.0 / 298.15) - 273.15
print(celsius)
return celsius
while True:
get_temperautre()
utime.sleep(1)
oled.text(str(get_temperautre()), 0, 0)
oled.show()
oled.fill(0)
#const float BETA = 3950; // should match the Beta Coefficient of the thermistor
#int analogValue = analogRead(A0);
#float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;