12.8.22
- owenmichael12333
- Dec 8, 2022
- 1 min read
I was sick for the majority of the week up until today, but I still made decent progress. The error I "fixed" would come back anytime I tried to update the code which made it very difficult to do anything with the OLED board. But Mr. Christy helped me by using the RESET pin on the Pi Pico, which, now anytime the error shows up, I place the RESET wire into the ground part of the breadboard, resetting it and fixing it. This is all I have gotten done this week since it's my first day back but this fix makes me feel a lot better about this project.
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
import framebuf
import time
WIDTH = 128
HEIGHT = 64
i2c=I2C(0,sda=Pin(0), scl=Pin(1), freq=400000)
display = SSD1306_I2C(128, 64, i2c)
def read_temp():
sensor_temp = machine.ADC(4)
conversion_factor = 3.3 / (65535)
reading = sensor_temp.read_u16() * conversion_factor
temperature = 27 - (reading - 0.706)/0.001721
formatted_temperature = "{:.1f}".format(temperature)
string_temperature = str("Temperature:" + formatted_temperature)
print(string_temperature)
time.sleep(1)
return string_temperature
while True:
temperature = read_temp()
display.text(temperature,0,14)
display.show()
display.fill(0)

Comments