Timtonix / portable_weather

A portable weather station using WeatheStation and WeatherAPI
0 stars 0 forks source link

Afficher la température actuelle sur l'écran #6

Closed Timtonix closed 1 year ago

Timtonix commented 1 year ago

Afficher la température sur l'écran

Voici le code :

import ssd1306
from machine import Pin, SoftI2C
import urequests
import wifi

# On initialise l'écran
i2c = SoftI2C(scl=Pin(22), sda=Pin(21))
oled = ssd1306.SSD1306_I2C(128, 64 ,i2c)

wifi.do_connect()

response = urequests.get(url="http://api.weatherapi.com/v1/current.json?key=90daaf300c0f4d608a195409230401&q=Lille&aqi=no")
json_response = response.json()

oled.text(str(json_response["current"]["temp_c"]), 0, 10)
oled.show()

Et la photo :