import machine
import time
import ssd1306
i2c = machine.I2C(0, sda=machine.Pin(4), scl=machine.Pin(5), freq=400000)
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
sensor = machine.ADC(26)
conversion_factor = 3.3 / 65535
print("External Sensor Reading Started...")
while True:
raw_value = sensor.read_u16()
voltage = raw_value * conversion_factor
oled.fill(0)
oled.text("Raw Value:", 0, 0)
oled.text(str(raw_value), 0, 15)
oled.text("Voltage:", 0, 35)
oled.text("{:.2f} V".format(voltage), 0, 50)
oled.show()
time.sleep(0.2)Loading
pi-pico-w
pi-pico-w