I have a short code written in micropython on pico pi W. This codes sets up a server and is mainly supposed to display a website on which you can check the states of all the GPIO pins. Now when I go through each Pin from 0 to 28 I get all the values but if I try to send the values of pins 23 and 25 I get OSError -1.
Error message(if I dont skip 23 and 25):
Traceback (most recent call last):
File "<stdin>", line 134, in <module>
OSError: -1
Getting states of pins:
gpio_html = ""
for pin_number in range(0, 29):# Adjust based on your setup
if pin_number in (23,25): # I use this to not get error
continue
pin = Pin(pin_number, Pin.IN) # Set GPIO as input
state = pin.value() # Read GPIO state
gpio_html += f"""
{space}<tr>
{space}<td>{pin_number}</td>
{space}<td>{state}</td>
{space}</tr>"""
Sending response:
# Generate HTML response
response = webpage(random_value, state)
# Send the HTTP response and close the connection
conn.send('HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n') # line 134
conn.send(response.encode('utf-8'))
conn.close()
I was looking through the pi pico W diagram again and realized that that pins 23 24 25 are not actual pins. Maybe that is way the code did not work. Not sure but I will stick with this explanation for my self.
You can see the functions of the three pins in the table below the diagram: