W5100S-EVB-Pico hangs after consecutive requests (MicroPython)


I’m trying to send a simple HTTP GET request every 5 seconds, but after 4 requests, the board hangs/crashes without giving an error. I have to reboot the board before I can work with it again. Am I creating a stack overflow or something?

I’m using the example including urequests.py from:

import network
import urequests
import time
from machine import Pin, Timer

timer = Timer()

def w5x00_init():
    nic = network.WIZNET5K(machine.SPI(0), machine.Pin(17), machine.Pin(20))
    nic.active(True) # DHCP
    while not nic.isconnected():
def request(timer):
    r = urequests.get("")

    print('Status: ' + str(r.status_code))

def main():
    timer.init(period=5000, callback=request)

if __name__ == "__main__":

If I execute w5x00_init() every time before the request, the requests will continue to be executed. But we don’t want to send a DHCP request at every HTTP request to the gateway :). Static IP-addresses is a no-go too since this has to become a plug-and-play device.

I’ve found a solution! Do a gc.collect() right after each request to free up some memory. Don’t forget to import gc at the top of your script.

1 Like

Thank you for replying to your own issue with a solution. This saved my bacon!

1 Like