W5500 MQTT Issues ([Errno 13] EACCES)

Hi,

I found this tutorial online to connect my W5500 via ethernet to MQTT with mqttsimple: https://github.com/Wiznet/RP2040-HAT-MicroPython/tree/main/examples/MQTT/Publish. I am having issues when the pico tries to connect to the broker and it it prompting me with the error [Errno 13] EACCES when running it on Thonny. The pico does seem to be setting itself a public IP (I can ping it from another device in the network). It seems to be a socket issue with the W5500 board, but I am having difficulties solving the issue. Any pointers would be greatly appreciated.

Here’s the code I am using:

from umqttsimple import MQTTClient
from usocket import socket
from machine import Pin,SPI
import network
import time

#mqtt config
mqtt_server = ‘192.168.1.3’
client_id = ‘monitor’
topic_pub = b’monitor/pipicotest’
topic_msg = b’Hello Pico’

last_message = 0
message_interval = 5
counter = 0

#W5x00 chip init
def w5x00_init():
spi=SPI(0,2_000_000, mosi=Pin(19),miso=Pin(16),sck=Pin(18))
nic = network.WIZNET5K(spi,Pin(17),Pin(20)) #spi,cs,reset pin
nic.active(True)

#None DHCP
nic.ifconfig((‘192.168.1.10’,‘255.255.255.0’,‘192.168.1.1’,‘8.8.8.8’))

#DHCP
#nic.ifconfig(‘dhcp’)
print(‘IP address :’, nic.ifconfig())

while not nic.isconnected():
time.sleep(1)
#print(nic.regs())
print(“Not connected”)
print(“Connected”)

def mqtt_connect():
client = MQTTClient(client_id, mqtt_server, keepalive=60)
client.connect()
print(‘Connected to %s MQTT Broker’%(mqtt_server))
return client

#reconnect & reset
def reconnect():
print(‘Failed to connected to MQTT Broker. Reconnecting…’)
time.sleep(5)
machine.reset()

def main():
w5x00_init()
try:
client = mqtt_connect()
except OSError as e:
reconnect()

while True:
client.publish(topic_pub, topic_msg)
time.sleep(3)
print(“published”)

client.disconnect()

if name == “main”:
main()

EACCESS is “permission denied”. Either to the file or to any other resource.