I have ported a remote weather app to Picoexplorer

Uses latest firmware from Pinorami
MicroPython v1.21.0, picow v1.21.0 on 2023-10-06; Raspberry Pi Pico W with RP2040

you may have to set up your own api at open weather and put in your location at line 21

import network
import time
import secrets
import urequests

from picographics import PicoGraphics, DISPLAY_PICO_EXPLORER

WIDTH, HEIGHT = display.get_bounds()

set up the hardware

display = PicoGraphics(display=DISPLAY_PICO_EXPLORER)
WHITE = display.create_pen(255, 255, 255)

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(secrets.SSID, secrets.PASSWORD)
while wlan.isconnected()==False:
print(‘Connecting . . .’)
print(‘Congratulations, You Have Connected’)
#weather=urequests.get(“https://api.openweathermap.org/data/2.5/weather?lat=0.478623&lon=33.164364&appid=0d631313b55e6e128285fd7882ba913f&units=imperial”).json()
weather=urequests.get(“https://api.openweathermap.org/data/2.5/weather?q=glasgow&appid=6b72756ad1ab174cd04a01ce9b1b3430&units=imperial”).json()
tm=time.localtime(weather[‘dt’]+weather[‘timezone’])
print(‘Welcome to ‘+weather[‘name’]+’, ‘+weather[‘sys’][‘country’])
print(‘Local Time: ‘+str(tm[3])+’:’+str(tm[4])+’ ‘+str(tm[1])+’/’+str(tm[2])+‘/’+str(tm[0]))
sr=time.localtime(weather[‘sys’][‘sunrise’]+weather[‘timezone’])
print(‘Sunrise at: ‘+str(sr[3])+’:’+str(sr[4]))
ss=time.localtime(weather[‘sys’][‘sunset’]+weather[‘timezone’])
print(‘Sunset at: ‘+str(ss[3]-12)+’:’+str(ss[4])+’ PM’)
print(‘Current Temp: ‘+str(weather[‘main’][‘temp’])+’ F’)
print(‘Current Humidity: ‘+str(weather[‘main’][‘humidity’])+’ %’)
print(‘Current Barometric Pressure: ‘+str(weather[‘main’][‘pressure’]*0.0009869233)+’ ATM’)
for i in range(len(weather[‘weather’])):
print('Current Conditions: ‘+weather[‘weather’][i][‘main’]+’, '+weather[‘weather’][i][‘description’])
print(‘Wind: ‘+str(weather[‘wind’][‘speed’])+’ MPH’)
myTime=time.time()
while True:
if time.time()-myTime>300:
weather=urequests.get(“https://api.openweathermap.org/data/2.5/weather?q=Jinja,Uganda&appid=098014b8c21bddb718496a654f417674&units=imperial”).json()
tm=time.localtime(weather[‘dt’]+weather[‘timezone’])
ss=time.localtime(weather[‘sys’][‘sunset’]+weather[‘timezone’])
myTime=time.time()
print(‘New Data Read’)
display.set_pen(WHITE)

display.text('Welcome '+weather['name'],0,0)
sr=time.localtime(weather['sys']['sunrise']+weather['timezone'])
display.set_pen(WHITE) 

display.text('Time: '+str(tm[3])+':'+str(tm[4]),0,16)
display.text('Date: '+str(tm[1])+'/'+str(tm[2])+'/'+str(tm[0]),0,32)
display.text('Sunrise: '+str(sr[3])+':'+str(sr[4]),0,48)
display.text('Sunset: '+str(ss[3]-12)+':'+str(ss[4])+' PM',0,64)
display.update()
time.sleep(10)
display.set_pen(WHITE) 
#display.text('Welcome to '+weather['name'],0,82)
display.text('Weather: ',0,82)
display.text('Temp: '+str(weather['main']['temp'])+' F',0,94)
display.text('Humidity: '+str(weather['main']['humidity'])+' %',0,110)
display.text('BP: '+str(weather['main']['pressure']*0.0009869233)+' ATM',0,126)
display.text('Wind: '+str(weather['wind']['speed'])+' MPH',0,142)
display.update()
time.sleep(5)
#dsp.fill(0)
WHITE = display.create_pen(255, 255, 255)
display.set_pen(WHITE)
#display.text('Welcome to '+weather['name'],0,178)
display.text('Conditions: ',0,160)
row=26
for i in range(len(weather['weather'])):
    display.text(weather['weather'][i]['main'],0,176)
    row=row+10
    display.text(weather['weather'][i]['description'],0,192)
    row=row+10
display.update()
time.sleep(5)









#dsp.fill(0)

sorry about code layout dont know how to attach file

Click the Preformatted Text button, the </>.
The other way to do it is three ` at the top of your block of code, and three more at the end / bottom.

‘’’
import network
import time
import secrets
import urequests

from picographics import PicoGraphics, DISPLAY_PICO_EXPLORER

WIDTH, HEIGHT = display.get_bounds()

set up the hardware

display = PicoGraphics(display=DISPLAY_PICO_EXPLORER)
WHITE = display.create_pen(255, 255, 255)

wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(secrets.SSID, secrets.PASSWORD)
while wlan.isconnected()==False:
print(‘Connecting . . .’)
print(‘Congratulations, You Have Connected’)
#weather=urequests.get(“https://api.openweathermap.org/data/2.5/weather?lat=0.478623&lon=33.164364&appid=0d631313b55e6e128285fd7882ba913f&units=imperial”).json()
weather=urequests.get(“https://api.openweathermap.org/data/2.5/weather?q=glasgow&appid=6b72756ad1ab174cd04a01ce9b1b3430&units=imperial”).json()
tm=time.localtime(weather[‘dt’]+weather[‘timezone’])
print(‘Welcome to ‘+weather[‘name’]+’, ‘+weather[‘sys’][‘country’])
print(‘Local Time: ‘+str(tm[3])+’:’+str(tm[4])+’ ‘+str(tm[1])+’/’+str(tm[2])+‘/’+str(tm[0]))
sr=time.localtime(weather[‘sys’][‘sunrise’]+weather[‘timezone’])
print(‘Sunrise at: ‘+str(sr[3])+’:’+str(sr[4]))
ss=time.localtime(weather[‘sys’][‘sunset’]+weather[‘timezone’])
print(‘Sunset at: ‘+str(ss[3]-12)+’:’+str(ss[4])+’ PM’)
print(‘Current Temp: ‘+str(weather[‘main’][‘temp’])+’ F’)
print(‘Current Humidity: ‘+str(weather[‘main’][‘humidity’])+’ %’)
print(‘Current Barometric Pressure: ‘+str(weather[‘main’][‘pressure’]*0.0009869233)+’ ATM’)
for i in range(len(weather[‘weather’])):
print('Current Conditions: ‘+weather[‘weather’][i][‘main’]+’, '+weather[‘weather’][i][‘description’])
print(‘Wind: ‘+str(weather[‘wind’][‘speed’])+’ MPH’)
myTime=time.time()
while True:
if time.time()-myTime>300:
weather=urequests.get(“https://api.openweathermap.org/data/2.5/weather?q=Jinja,Uganda&appid=6b72756ad1ab174cd04a01ce9b1b3430&units=imperial”).json()
tm=time.localtime(weather[‘dt’]+weather[‘timezone’])
ss=time.localtime(weather[‘sys’][‘sunset’]+weather[‘timezone’])
myTime=time.time()
print(‘New Data Read’)
display.set_pen(WHITE)

display.text('Welcome '+weather['name'],0,0,300,3)
sr=time.localtime(weather['sys']['sunrise']+weather['timezone'])
display.set_pen(WHITE) 

display.text('Time: '+str(tm[3])+':'+str(tm[4]),0,18,)
display.text('Date: '+str(tm[1])+'/'+str(tm[2])+'/'+str(tm[0]),0,33)
display.text('Sunrise: '+str(sr[3])+':'+str(sr[4]),0,46)
display.text('Sunset: '+str(ss[3]-12)+':'+str(ss[4])+' PM',0,64)
display.update()
#time.sleep(10)
display.set_pen(WHITE) 
#display.text('Welcome to '+weather['name'],0,82)
display.text('Weather: ',0,82)
display.text('Temp: '+str(weather['main']['temp'])+' F',0,96)
display.text('Humidity: '+str(weather['main']['humidity'])+' %',0,112)
display.text('BP: '+str(weather['main']['pressure']*0.0009869233)+' ATM',0,128)
display.text('Wind: '+str(weather['wind']['speed'])+' MPH',0,144)
display.update()
#time.sleep(5)
#dsp.fill(0)
WHITE = display.create_pen(255, 255, 255)
display.set_pen(WHITE)
#display.#text('Welcome to '+weather['name'],0,178)
display.text('Conditions: ',0,160)
row=26
for i in range(len(weather['weather'])):
    display.text(weather['weather'][i]['main'],0,176)
    row=row+10
    display.text(weather['weather'][i]['description'],0,192)
    row=row+10
display.update()
#time.sleep(5)

‘’’

'''
import network
import time
import secrets
import urequests
 

from picographics import PicoGraphics, DISPLAY_PICO_EXPLORER
# WIDTH, HEIGHT = display.get_bounds()
# set up the hardware
display = PicoGraphics(display=DISPLAY_PICO_EXPLORER)
WHITE = display.create_pen(255, 255, 255) 

 
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(secrets.SSID, secrets.PASSWORD)
while wlan.isconnected()==False:
    print('Connecting . . .')
print('Congratulations, You Have Connected')
#weather=urequests.get("https://api.openweathermap.org/data/2.5/weather?lat=0.478623&lon=33.164364&appid=0d631313b55e6e128285fd7882ba913f&units=imperial").json()
weather=urequests.get("https://api.openweathermap.org/data/2.5/weather?q=glasgow&appid=6b72756ad1ab174cd04a01ce9b1b3430&units=imperial").json()
tm=time.localtime(weather['dt']+weather['timezone'])
print('Welcome to '+weather['name']+', '+weather['sys']['country'])
print('Local Time: '+str(tm[3])+':'+str(tm[4])+'  '+str(tm[1])+'/'+str(tm[2])+'/'+str(tm[0]))
sr=time.localtime(weather['sys']['sunrise']+weather['timezone'])
print('Sunrise at: '+str(sr[3])+':'+str(sr[4]))
ss=time.localtime(weather['sys']['sunset']+weather['timezone'])
print('Sunset at: '+str(ss[3]-12)+':'+str(ss[4])+' PM')
print('Current Temp: '+str(weather['main']['temp'])+' F')
print('Current Humidity: '+str(weather['main']['humidity'])+' %')
print('Current Barometric Pressure: '+str(weather['main']['pressure']*0.0009869233)+' ATM')
for i in range(len(weather['weather'])):
    print('Current Conditions: '+weather['weather'][i]['main']+', '+weather['weather'][i]['description'])
print('Wind: '+str(weather['wind']['speed'])+' MPH')
myTime=time.time()
while True:
    if time.time()-myTime>300:
       weather=urequests.get("https://api.openweathermap.org/data/2.5/weather?q=Jinja,Uganda&appid=6b72756ad1ab174cd04a01ce9b1b3430&units=imperial").json()
       tm=time.localtime(weather['dt']+weather['timezone'])
       ss=time.localtime(weather['sys']['sunset']+weather['timezone'])
       myTime=time.time()
       print('New Data Read')
    display.set_pen(WHITE) 
    
    display.text('Welcome '+weather['name'],0,0,300,3)
    sr=time.localtime(weather['sys']['sunrise']+weather['timezone'])
    display.set_pen(WHITE) 

    display.text('Time: '+str(tm[3])+':'+str(tm[4]),0,18,)
    display.text('Date: '+str(tm[1])+'/'+str(tm[2])+'/'+str(tm[0]),0,33)
    display.text('Sunrise: '+str(sr[3])+':'+str(sr[4]),0,46)
    display.text('Sunset: '+str(ss[3]-12)+':'+str(ss[4])+' PM',0,64)
    display.update()
    #time.sleep(10)
    display.set_pen(WHITE) 
    #display.text('Welcome to '+weather['name'],0,82)
    display.text('Weather: ',0,82)
    display.text('Temp: '+str(weather['main']['temp'])+' F',0,96)
    display.text('Humidity: '+str(weather['main']['humidity'])+' %',0,112)
    display.text('BP: '+str(weather['main']['pressure']*0.0009869233)+' ATM',0,128)
    display.text('Wind: '+str(weather['wind']['speed'])+' MPH',0,144)
    display.update()
    #time.sleep(5)
    #dsp.fill(0)
    WHITE = display.create_pen(255, 255, 255)
    display.set_pen(WHITE)
    #display.#text('Welcome to '+weather['name'],0,178)
    display.text('Conditions: ',0,160)
    row=26
    for i in range(len(weather['weather'])):
        display.text(weather['weather'][i]['main'],0,176)
        row=row+10
        display.text(weather['weather'][i]['description'],0,192)
        row=row+10
    display.update()
    #time.sleep(5)
   ''' 
    

I would like the weather app update every 10 mins

how can i do this

thanks

r

The ` is on the key next to the 1 key. It also has the ~ on it. On an English keyboard anyway.

I’ve got a UK Pi Keyboard and the ’ is below the @ and the ~ is above the #.

The easiest way is to click the Preformatted Text option, </>.

modified the picoexplorer weather app so it can send weather alerts via sms, whatsapp or email.

r