I am trying to run an awesome project i found online:
(https://www.instructables.com/ISS-Tracker-Using-a-Raspberry-Pico/)
and wondered if anyone would have any knowledge on the below error codes i get when trying to run the main code on my pico 2w through thonny?
Traceback (most recent call last):
File “”, line 153, in
File “”, line 113, in showLatLon
File “”, line 78, in getPos
File “requests/init.py”, line 201, in get
File “requests/init.py”, line 79, in request
OSError: -2
Any help appreciated.
The OSError: -2 error that you’ve encountered is generally as a result of not being connected to WiFi, you will need to make sure that you have added your SSID and password to the secrets.py for the project, and also your current coordinates, below is how it should look.
Hi @Dan & @Robert93820
Thank you for the reply, i do run the secrets code along with the coordinates and it runs without throwing up a complaint, i then run main and get the below error
Traceback (most recent call last):
File “”, line 153, in
File “”, line 113, in showLatLon
File “”, line 78, in getPos
File “requests/init.py”, line 201, in get
File “requests/init.py”, line 79, in request
OSError: -2
on the pico display 2 i do get a black display coming up and text saying starting in the corner but nothing loads.
i have added the files to my pico
Thanks for the update! The OSError: -2 usually means the Pico W can’t resolve the API’s hostname — which almost always points to a Wi-Fi connection issue.
To help diagnose, try running this minimal test script on your Pico W to confirm it can connect to Wi-Fi and reach the ISS API:
import network
import urequests
import time
def connect():
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("YOUR_SSID", "YOUR_PASSWORD")
max_wait = 10
while wlan.status() != 3 and max_wait > 0:
print('Waiting for connection...')
time.sleep(1)
max_wait -= 1
if wlan.status() != 3:
raise RuntimeError('Wi-Fi connection failed')
else:
print('Connected:', wlan.ifconfig())
connect()
resp = urequests.get("http://api.open-notify.org/iss-now.json")
print(resp.json())
Replace "YOUR_SSID" and "YOUR_PASSWORD" with your actual Wi-Fi credentials. If it fails with the same error, the Pico isn’t successfully connecting to your network. A successful execution of the code should show the connection status messages and then the ISS position JSON printer.
Further things to check if this fails are:
try running this without Thonny connected (just run as main.py and reset the Pico) because sometimes the REPL interferes with networking.
Double-check your secrets.py file name, and contents, and that it’s in the same folder as your main script.
Hi @Ryan, thank you for this, i have run this test and comes back successful with below reply:
{‘message’: ‘success’, ‘iss_position’: {‘longitude’: ‘171.9577’, ‘latitude’: ‘-7.2601’}, ‘timestamp’: 1751831641}
I have taken a pic of how i have secrests set up with my lon and lat removing my ssid an password details and attached to this i have also attached a pic of the screen i receive on my display pack and the error it throws up on when i run main script, i can connect to wifi through it as proven with below test, thanks very much for help so far from the community
okay just realised World.jpg should be all lower case so changed it and main now runs without throwing up any errors however i am still on getting the starting text on black background as shown in above pic.
[Errno2] ENOENT is a file access problem - the file doesn’t exist, the path is wrong, the file permission is not correct or something similar. Line 90 in method showMap() is j.open_file("world.jpg")
so the problem is associated with finding or opening that file. Make sure that “world.jpg” exists, is at the default file access location for the script and has the permissions necessary to allow access from your script.
Hi all, this is now running, i made the adjustments with the help i have received from the community so big thank you from me for your help
Only issue i have now is getting it to fit my Pico Display 2, have tried adjusting to 320 x 240 & 320 x 160 but world map is to zoomed in and missing quite a large bit of the world.
I am sure i will get there.
Thanks again.
Is that the display you have adjusted, or the image? Note that the image available for downloading is smaller than the image in the example of the display, as it is chopped off between about Anchorage and Darwin, and is only 180x120. I can’t tell what scaling option the code is using (jpegdec.jpegdec?) but the best starting assumption would be unscaled, so your world map should match the display size.
I agree with Jeff, sounds like the map image is too small for your Pico Display 2, which has a resolution of 320x240 pixels.
To fix this, resize the map image to match your display resolution (320x240). You can do this using an image editor or with a simple Python script on your computer, for example: