라즈베리파이 피코 WH 프로젝트 예제 50개

MicroPython 코드 · 센서 연결 · GPIO/ADC/I2C/SPI/UART/Wi‑Fi IoT 실습 자료

학교 수업, 동아리, 수행평가, 피지컬 컴퓨팅 프로젝트용

📌 사용 전 핵심 주의사항

항목설명
전압Pico WH GPIO는 3.3V 기준입니다. 5V 신호를 GPIO에 직접 넣지 마세요.
공통 GND센서, 모터드라이버, 외부 전원은 Pico WH와 GND를 반드시 공통으로 연결합니다.
ADC 핀아날로그 입력은 GP26, GP27, GP28을 사용합니다.
I2C 기본 예시SDA=GP0, SCL=GP1 기준으로 작성했습니다.
라이브러리OLED, BMP280, MPU6050, RFID 등은 별도 MicroPython 라이브러리 파일이 필요할 수 있습니다.

🔗 프로젝트 바로가기

PROJECT 01

내장 LED 깜빡이기

핵심 개념기본 출력 / GPIO
준비물내장 LED
연결LED
주의없음
from machine import Pin
import time

led = Pin("LED", Pin.OUT)

while True:
    led.value(1)
    time.sleep(0.5)
    led.value(0)
    time.sleep(0.5)
PROJECT 02

외부 LED 켜고 끄기

핵심 개념디지털 출력
준비물LED + 220Ω 저항
연결GP15 → 저항 → LED(+), LED(-) → GND
주의LED 극성 확인
from machine import Pin
import time

led = Pin(15, Pin.OUT)

while True:
    led.on()
    time.sleep(1)
    led.off()
    time.sleep(1)
PROJECT 03

버튼 입력으로 LED 제어

핵심 개념디지털 입력 / 풀다운
준비물버튼, LED
연결버튼: GP14-GND, LED: GP15
주의PULL_UP 사용
from machine import Pin
import time

button = Pin(14, Pin.IN, Pin.PULL_UP)
led = Pin(15, Pin.OUT)

while True:
    if button.value() == 0:
        led.on()
    else:
        led.off()
    time.sleep(0.05)
PROJECT 04

버튼 누른 횟수 세기

핵심 개념입력 이벤트
준비물버튼
연결버튼 한쪽 GP14, 다른쪽 GND
주의채터링 방지
from machine import Pin
import time

button = Pin(14, Pin.IN, Pin.PULL_UP)
count = 0
old = 1

while True:
    now = button.value()
    if old == 1 and now == 0:
        count += 1
        print("누른 횟수:", count)
        time.sleep(0.2)
    old = now
PROJECT 05

부저로 삐 소리 내기

핵심 개념디지털 출력
준비물능동 부저
연결부저 +: GP16, -: GND
주의능동 부저 기준
from machine import Pin
import time

buzzer = Pin(16, Pin.OUT)

while True:
    buzzer.on()
    time.sleep(0.2)
    buzzer.off()
    time.sleep(0.8)
PROJECT 06

PWM 부저 음계 만들기

핵심 개념PWM / 주파수
준비물수동 부저
연결부저 +: GP16, -: GND
주의수동 부저 사용
from machine import Pin, PWM
import time

buzzer = PWM(Pin(16))
notes = [262, 294, 330, 349, 392, 440, 494, 523]

for n in notes:
    buzzer.freq(n)
    buzzer.duty_u16(30000)
    time.sleep(0.3)

buzzer.duty_u16(0)
PROJECT 07

LED 밝기 조절

핵심 개념PWM 출력
준비물LED + 220Ω
연결GP15 → 저항 → LED → GND
주의PWM duty 사용
from machine import Pin, PWM
import time

led = PWM(Pin(15))
led.freq(1000)

while True:
    for duty in range(0, 65535, 2000):
        led.duty_u16(duty)
        time.sleep(0.03)
    for duty in range(65535, 0, -2000):
        led.duty_u16(duty)
        time.sleep(0.03)
PROJECT 08

RGB LED 색 바꾸기

핵심 개념PWM 3채널
준비물RGB LED
연결R:GP13, G:GP14, B:GP15
주의공통 음극 기준
from machine import Pin, PWM
import time

r = PWM(Pin(13)); g = PWM(Pin(14)); b = PWM(Pin(15))
for x in (r, g, b):
    x.freq(1000)

colors = [(65535,0,0), (0,65535,0), (0,0,65535), (65535,65535,0), (0,65535,65535)]

while True:
    for cr, cg, cb in colors:
        r.duty_u16(cr); g.duty_u16(cg); b.duty_u16(cb)
        time.sleep(1)
PROJECT 09

가변저항 값 읽기

핵심 개념ADC 아날로그 입력
준비물가변저항
연결가운데: GP26, 양끝: 3V3/GND
주의ADC는 GP26~GP28
from machine import ADC
import time

pot = ADC(26)

while True:
    value = pot.read_u16()
    print("가변저항:", value)
    time.sleep(0.2)
PROJECT 10

가변저항으로 LED 밝기 조절

핵심 개념ADC + PWM
준비물가변저항, LED
연결ADC:GP26, LED:GP15
주의입력값을 duty로 사용
from machine import Pin, ADC, PWM
import time

pot = ADC(26)
led = PWM(Pin(15))
led.freq(1000)

while True:
    value = pot.read_u16()
    led.duty_u16(value)
    print(value)
    time.sleep(0.05)
PROJECT 11

조도센서 값 읽기

핵심 개념ADC / 빛 센서
준비물LDR 조도센서 모듈
연결AO: GP26, VCC:3V3, GND:GND
주의모듈 출력 전압 확인
from machine import ADC
import time

light = ADC(26)

while True:
    value = light.read_u16()
    print("밝기값:", value)
    time.sleep(0.5)
PROJECT 12

어두우면 LED 켜기

핵심 개념조건문 + ADC
준비물조도센서, LED
연결LDR AO:GP26, LED:GP15
주의임계값 조절 필요
from machine import Pin, ADC
import time

light = ADC(26)
led = Pin(15, Pin.OUT)

while True:
    value = light.read_u16()
    if value < 25000:
        led.on()
    else:
        led.off()
    print(value)
    time.sleep(0.2)
PROJECT 13

토양 습도 센서 읽기

핵심 개념ADC / 환경 데이터
준비물토양 습도 센서
연결AO: GP27, VCC:3V3, GND:GND
주의부식 방지 주의
from machine import ADC
import time

soil = ADC(27)

while True:
    value = soil.read_u16()
    print("토양 습도 원시값:", value)
    time.sleep(1)
PROJECT 14

자동 물주기 알림

핵심 개념ADC + 부저
준비물토양습도센서, 부저
연결SOIL:GP27, BUZZER:GP16
주의릴레이 대신 알림 예제
from machine import Pin, ADC
import time

soil = ADC(27)
buzzer = Pin(16, Pin.OUT)

while True:
    value = soil.read_u16()
    if value > 45000:
        buzzer.on()
        print("흙이 건조합니다!")
    else:
        buzzer.off()
        print("습도 적당:", value)
    time.sleep(1)
PROJECT 15

온도 센서 LM35 읽기

핵심 개념ADC / 온도 변환
준비물LM35
연결OUT: GP26, VCC:3V3, GND:GND
주의LM35 출력 특성 확인
from machine import ADC
import time

sensor = ADC(26)

while True:
    raw = sensor.read_u16()
    voltage = raw * 3.3 / 65535
    temp_c = voltage * 100
    print("온도:", temp_c, "°C")
    time.sleep(1)
PROJECT 16

Pico 내부 온도 측정

핵심 개념내장 ADC
준비물내부 온도 센서
연결별도 연결 없음
주의대략값
from machine import ADC
import time

sensor = ADC(4)
conversion = 3.3 / 65535

while True:
    voltage = sensor.read_u16() * conversion
    temp = 27 - (voltage - 0.706) / 0.001721
    print("내부 온도:", temp)
    time.sleep(1)
PROJECT 17

DHT11 온습도 읽기

핵심 개념디지털 센서
준비물DHT11
연결DATA: GP15, VCC:3V3, GND:GND
주의dht 모듈 필요
from machine import Pin
import dht
import time

sensor = dht.DHT11(Pin(15))

while True:
    sensor.measure()
    print("온도:", sensor.temperature(), "°C")
    print("습도:", sensor.humidity(), "%")
    time.sleep(2)
PROJECT 18

DHT22 정밀 온습도

핵심 개념디지털 센서
준비물DHT22
연결DATA: GP15
주의DHT22는 DHT11보다 정밀
from machine import Pin
import dht
import time

sensor = dht.DHT22(Pin(15))

while True:
    sensor.measure()
    t = sensor.temperature()
    h = sensor.humidity()
    print("온도:", t, "습도:", h)
    time.sleep(2)
PROJECT 19

초음파 거리 측정

핵심 개념펄스 시간 측정
준비물HC-SR04
연결TRIG:GP3, ECHO:GP2
주의Echo 5V이면 분압 필요
from machine import Pin, time_pulse_us
import time

trig = Pin(3, Pin.OUT)
echo = Pin(2, Pin.IN)

while True:
    trig.low()
    time.sleep_us(2)
    trig.high()
    time.sleep_us(10)
    trig.low()

    duration = time_pulse_us(echo, 1)
    distance = duration * 0.0343 / 2
    print("거리:", distance, "cm")
    time.sleep(1)
PROJECT 20

거리 가까우면 경고음

핵심 개념초음파 + 부저
준비물HC-SR04, 부저
연결TRIG:GP3, ECHO:GP2, BUZZER:GP16
주의장애물 경고
from machine import Pin, time_pulse_us
import time

trig = Pin(3, Pin.OUT)
echo = Pin(2, Pin.IN)
buzzer = Pin(16, Pin.OUT)

while True:
    trig.low(); time.sleep_us(2)
    trig.high(); time.sleep_us(10)
    trig.low()
    duration = time_pulse_us(echo, 1)
    distance = duration * 0.0343 / 2

    buzzer.value(distance < 20)
    print(distance)
    time.sleep(0.2)
PROJECT 21

PIR 인체 감지

핵심 개념디지털 입력
준비물PIR 센서
연결OUT: GP14
주의감도 조절 가능
from machine import Pin
import time

pir = Pin(14, Pin.IN)
led = Pin("LED", Pin.OUT)

while True:
    if pir.value():
        print("움직임 감지!")
        led.on()
    else:
        led.off()
    time.sleep(0.2)
PROJECT 22

기울기 센서

핵심 개념디지털 입력
준비물Tilt sensor
연결OUT: GP14
주의ON/OFF 감지
from machine import Pin
import time

tilt = Pin(14, Pin.IN, Pin.PULL_UP)

while True:
    if tilt.value() == 0:
        print("기울어짐")
    else:
        print("정상")
    time.sleep(0.5)
PROJECT 23

진동 센서 감지

핵심 개념디지털 입력
준비물진동 센서
연결DO: GP14
주의민감도 조절
from machine import Pin
import time

vibration = Pin(14, Pin.IN)

while True:
    if vibration.value():
        print("진동 발생!")
    time.sleep(0.1)
PROJECT 24

자석 리드 스위치

핵심 개념문 열림 감지
준비물리드 스위치
연결GP14와 GND 사이
주의PULL_UP 사용
from machine import Pin
import time

door = Pin(14, Pin.IN, Pin.PULL_UP)

while True:
    if door.value():
        print("문 열림")
    else:
        print("문 닫힘")
    time.sleep(0.5)
PROJECT 25

서보모터 각도 제어

핵심 개념PWM 제어
준비물SG90 서보
연결Signal: GP15, VCC:5V, GND공통
주의외부전원 권장
from machine import Pin, PWM
import time

servo = PWM(Pin(15))
servo.freq(50)

def angle(a):
    min_duty = 1638
    max_duty = 8192
    duty = int(min_duty + (max_duty - min_duty) * a / 180)
    servo.duty_u16(duty)

while True:
    for a in [0, 45, 90, 135, 180]:
        angle(a)
        time.sleep(1)
PROJECT 26

가변저항으로 서보 제어

핵심 개념ADC + PWM
준비물가변저항, 서보모터
연결ADC:GP26, SERVO:GP15
주의전원 부족 주의
from machine import Pin, PWM, ADC
import time

pot = ADC(26)
servo = PWM(Pin(15))
servo.freq(50)

while True:
    raw = pot.read_u16()
    duty = int(1638 + raw * (8192 - 1638) / 65535)
    servo.duty_u16(duty)
    print(raw, duty)
    time.sleep(0.05)
PROJECT 27

릴레이 제어

핵심 개념디지털 출력
준비물릴레이 모듈
연결IN: GP15, VCC, GND
주의고전압 부하 주의
from machine import Pin
import time

relay = Pin(15, Pin.OUT)

while True:
    relay.on()
    print("릴레이 ON")
    time.sleep(2)
    relay.off()
    print("릴레이 OFF")
    time.sleep(2)
PROJECT 28

7세그먼트 숫자 표시

핵심 개념다중 GPIO
준비물7세그먼트
연결a~g: GP2~GP8
주의저항 필요
from machine import Pin
import time

pins = [Pin(i, Pin.OUT) for i in range(2, 9)]
nums = {
    0:[1,1,1,1,1,1,0], 1:[0,1,1,0,0,0,0],
    2:[1,1,0,1,1,0,1], 3:[1,1,1,1,0,0,1],
    4:[0,1,1,0,0,1,1], 5:[1,0,1,1,0,1,1],
    6:[1,0,1,1,1,1,1], 7:[1,1,1,0,0,0,0],
    8:[1,1,1,1,1,1,1], 9:[1,1,1,1,0,1,1]
}

while True:
    for n in range(10):
        for p, v in zip(pins, nums[n]):
            p.value(v)
        time.sleep(1)
PROJECT 29

I2C 주소 검색

핵심 개념I2C 기본
준비물I2C 센서/OLED
연결SDA:GP0, SCL:GP1
주의주소 확인용
from machine import Pin, I2C

i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
print("I2C 주소:", i2c.scan())
PROJECT 30

OLED에 글자 출력

핵심 개념I2C OLED
준비물SSD1306 OLED
연결SDA:GP0, SCL:GP1
주의ssd1306.py 필요
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C

i2c = I2C(0, sda=Pin(0), scl=Pin(1))
oled = SSD1306_I2C(128, 64, i2c)

oled.fill(0)
oled.text("Pico WH", 0, 0)
oled.text("MicroPython", 0, 16)
oled.show()
PROJECT 31

OLED에 센서값 표시

핵심 개념I2C + ADC
준비물OLED, 가변저항
연결OLED I2C, POT:GP26
주의문자 출력
from machine import Pin, I2C, ADC
from ssd1306 import SSD1306_I2C
import time

i2c = I2C(0, sda=Pin(0), scl=Pin(1))
oled = SSD1306_I2C(128, 64, i2c)
pot = ADC(26)

while True:
    value = pot.read_u16()
    oled.fill(0)
    oled.text("ADC Value", 0, 0)
    oled.text(str(value), 0, 20)
    oled.show()
    time.sleep(0.3)
PROJECT 32

BMP280 기압 센서

핵심 개념I2C 환경센서
준비물BMP280
연결SDA:GP0, SCL:GP1
주의라이브러리 필요
from machine import Pin, I2C
import time
import bmp280

i2c = I2C(0, sda=Pin(0), scl=Pin(1))
bmp = bmp280.BMP280(i2c)

while True:
    print("온도:", bmp.temperature)
    print("기압:", bmp.pressure)
    time.sleep(1)
PROJECT 33

MPU6050 가속도 읽기

핵심 개념I2C 모션센서
준비물MPU6050
연결SDA:GP0, SCL:GP1
주의mpu6050.py 필요
from machine import Pin, I2C
import time
from mpu6050 import MPU6050

i2c = I2C(0, sda=Pin(0), scl=Pin(1))
mpu = MPU6050(i2c)

while True:
    acc = mpu.read_accel_data()
    print(acc)
    time.sleep(0.5)
PROJECT 34

RFID 카드 UID 읽기

핵심 개념SPI 통신
준비물MFRC522 RFID
연결SCK:GP18, MOSI:GP19, MISO:GP16, CS:GP17, RST:GP20
주의mfrc522.py 필요
from machine import Pin, SPI
import mfrc522
import time

reader = mfrc522.MFRC522(spi_id=0, sck=18, miso=16, mosi=19, cs=17, rst=20)

while True:
    stat, tag_type = reader.request(reader.REQIDL)
    if stat == reader.OK:
        stat, uid = reader.SelectTagSN()
        if stat == reader.OK:
            print("카드 UID:", uid)
    time.sleep(0.2)
PROJECT 35

UART GPS 데이터 읽기

핵심 개념UART 통신
준비물GPS 모듈
연결GPS TX→GP1(RX), RX→GP0(TX)
주의9600bps 흔함
from machine import UART, Pin
import time

uart = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1))

while True:
    if uart.any():
        line = uart.readline()
        print(line)
    time.sleep(0.1)
PROJECT 36

블루투스 HC-05 UART

핵심 개념UART 문자열 통신
준비물HC-05
연결TX→GP1, RX→GP0
주의HC-05는 5V 레벨 주의
from machine import UART, Pin

uart = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1))

while True:
    if uart.any():
        msg = uart.readline()
        print("받음:", msg)
        uart.write(b"OK\n")
PROJECT 37

네오픽셀 LED 8개 제어

핵심 개념PIO/NeoPixel
준비물WS2812B
연결DIN: GP15, 5V, GND
주의전원과 GND 공통
from machine import Pin
import neopixel
import time

np = neopixel.NeoPixel(Pin(15), 8)

while True:
    for i in range(8):
        np.fill((0, 0, 0))
        np[i] = (30, 0, 0)
        np.write()
        time.sleep(0.1)
PROJECT 38

소리 센서 감지

핵심 개념아날로그/디지털
준비물마이크 소리 센서
연결AO:GP26 또는 DO:GP14
주의모듈별 차이
from machine import ADC
import time

sound = ADC(26)

while True:
    value = sound.read_u16()
    print("소리 크기:", value)
    time.sleep(0.1)
PROJECT 39

화염 센서 경보

핵심 개념디지털 입력
준비물Flame sensor
연결DO:GP14, BUZZER:GP16
주의실험 안전 주의
from machine import Pin
import time

flame = Pin(14, Pin.IN)
buzzer = Pin(16, Pin.OUT)

while True:
    if flame.value() == 0:
        print("화염 감지!")
        buzzer.on()
    else:
        buzzer.off()
    time.sleep(0.2)
PROJECT 40

가스 센서 MQ-2 읽기

핵심 개념아날로그 입력
준비물MQ-2
연결AO:GP26, VCC, GND
주의5V 모듈 출력 주의
from machine import ADC
import time

gas = ADC(26)

while True:
    value = gas.read_u16()
    print("가스 센서값:", value)
    time.sleep(1)
PROJECT 41

빗물 감지 센서

핵심 개념ADC 센서
준비물Rain sensor
연결AO:GP27
주의부식 주의
from machine import ADC
import time

rain = ADC(27)

while True:
    value = rain.read_u16()
    print("빗물 감지값:", value)
    time.sleep(1)
PROJECT 42

라인 트레이서 센서

핵심 개념디지털 입력
준비물IR 라인 센서
연결OUT:GP14
주의검정/흰색 반사 차이
from machine import Pin
import time

line = Pin(14, Pin.IN)

while True:
    if line.value():
        print("흰색 또는 반사 많음")
    else:
        print("검정선 감지")
    time.sleep(0.2)
PROJECT 43

IR 장애물 감지

핵심 개념디지털 입력
준비물IR obstacle sensor
연결OUT:GP14
주의거리 조절 가능
from machine import Pin
import time

ir = Pin(14, Pin.IN)
led = Pin("LED", Pin.OUT)

while True:
    detected = ir.value() == 0
    led.value(detected)
    print("장애물:", detected)
    time.sleep(0.2)
PROJECT 44

미니 DC 모터 제어

핵심 개념트랜지스터/드라이버
준비물DC 모터, 모터드라이버
연결IN:GP15
주의직접 연결 금지
from machine import Pin
import time

motor = Pin(15, Pin.OUT)

while True:
    motor.on()
    print("모터 ON")
    time.sleep(2)
    motor.off()
    print("모터 OFF")
    time.sleep(2)
PROJECT 45

DC 모터 속도 조절

핵심 개념PWM 모터 제어
준비물모터드라이버
연결PWM:GP15
주의외부전원 권장
from machine import Pin, PWM
import time

motor = PWM(Pin(15))
motor.freq(1000)

while True:
    for speed in range(0, 65535, 5000):
        motor.duty_u16(speed)
        time.sleep(0.2)
    motor.duty_u16(0)
    time.sleep(1)
PROJECT 46

Wi-Fi 연결 확인

핵심 개념Pico WH Wi-Fi
준비물내장 무선 기능
연결없음
주의ssid/password 수정
import network
import time

ssid = "YOUR_WIFI"
password = "YOUR_PASSWORD"

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)

while not wlan.isconnected():
    print("연결 중...")
    time.sleep(1)

print("연결 완료:", wlan.ifconfig())
PROJECT 47

웹서버로 LED 제어

핵심 개념Wi-Fi 웹서버
준비물내장 LED
연결없음
주의같은 Wi-Fi에서 접속
import network
import socket
from machine import Pin
import time

ssid = "YOUR_WIFI"
password = "YOUR_PASSWORD"
led = Pin("LED", Pin.OUT)

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)

while not wlan.isconnected():
    time.sleep(1)

addr = socket.getaddrinfo("0.0.0.0", 80)[0][-1]
s = socket.socket()
s.bind(addr)
s.listen(1)

print("접속 주소:", wlan.ifconfig()[0])

while True:
    cl, addr = s.accept()
    request = cl.recv(1024).decode()
    if "/on" in request:
        led.on()
    if "/off" in request:
        led.off()
    html = "<h1>Pico WH LED</h1><a href='/on'>ON</a><br><a href='/off'>OFF</a>"
    cl.send("HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n")
    cl.send(html)
    cl.close()
PROJECT 48

웹페이지에 온습도 표시

핵심 개념Wi-Fi + DHT
준비물DHT11/DHT22
연결DATA:GP15
주의네트워크 정보 수정
import network, socket, time
from machine import Pin
import dht

ssid = "YOUR_WIFI"
password = "YOUR_PASSWORD"
sensor = dht.DHT11(Pin(15))

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)

while not wlan.isconnected():
    time.sleep(1)

s = socket.socket()
s.bind(("0.0.0.0", 80))
s.listen(1)
print("IP:", wlan.ifconfig()[0])

while True:
    cl, addr = s.accept()
    sensor.measure()
    t = sensor.temperature()
    h = sensor.humidity()
    page = f"<h1>Pico WH Weather</h1><p>Temp: {t} C</p><p>Humidity: {h}%</p>"
    cl.recv(1024)
    cl.send("HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n")
    cl.send(page)
    cl.close()
PROJECT 49

IFTTT 웹훅 알림

핵심 개념HTTP 요청
준비물Wi-Fi + 센서
연결센서 자유
주의인터넷 연결 필요
import network, urequests, time

ssid = "YOUR_WIFI"
password = "YOUR_PASSWORD"
event = "pico_alert"
key = "YOUR_IFTTT_KEY"

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)

while not wlan.isconnected():
    time.sleep(1)

url = f"https://maker.ifttt.com/trigger/{event}/with/key/{key}"
data = {"value1": "Pico WH", "value2": "Sensor Alert", "value3": "ON"}

response = urequests.post(url, json=data)
print(response.text)
response.close()
PROJECT 50

ThingSpeak로 센서값 전송

핵심 개념IoT 데이터 업로드
준비물Wi-Fi + ADC 센서
연결ADC:GP26
주의API Key 필요
import network, urequests, time
from machine import ADC

ssid = "YOUR_WIFI"
password = "YOUR_PASSWORD"
api_key = "YOUR_THINGSPEAK_WRITE_KEY"
sensor = ADC(26)

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)

while not wlan.isconnected():
    time.sleep(1)

while True:
    value = sensor.read_u16()
    url = f"https://api.thingspeak.com/update?api_key={api_key}&field1={value}"
    r = urequests.get(url)
    print("전송:", value, r.text)
    r.close()
    time.sleep(20)