Created
February 14, 2021 17:54
-
-
Save benalb/0ef9ca3cb15fbb6b960f6e2358f496b7 to your computer and use it in GitHub Desktop.
poor man's weather station with rpi pico.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from machine import Pin, SPI, ADC | |
import ssd1306 | |
import utime | |
spi = SPI(0,100_000,polarity=1,phase=1) | |
dc = Pin(4, Pin.OUT) | |
res = Pin(3, Pin.OUT) | |
cs = Pin(5, Pin.OUT) | |
oled = ssd1306.SSD1306_SPI(128,64,spi,dc,res,cs,False) | |
sensor_temp = ADC(4) | |
conversion_factor = 3.3/(65535) | |
while True: | |
reading = sensor_temp.read_u16()*conversion_factor | |
temperature = 27-(reading-0.706)/0.001721 | |
oled.fill(0) | |
oled.show() | |
utime.sleep(0.5) | |
oled.text(str(int(temperature))+" C", 0, 0) | |
oled.show() | |
utime.sleep(2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment