Program hangs after a short amount of time


I have a ESP32 setup to use two serial ports also connected via wifi to a mobile phone hotspot. we use the following code to output data using requests to a php script. All is working as expected apart from after sending data for a short while it just hangs? Does the ESP32 need to be connected to a terminal if print() is being called? Is there a memory leak?

I am unable to ‘import tracemalloc’ that was introduced in version 3.4?

import streams
import requests
from wireless import wifi

ser2 = streams.serial(SERIAL2,baud=38400,set_default=False)

from espressif.esp32net import esp32wifi as wifi_driver


print("Establishing Link...")
try:"SSID", wifi.WIFI_WPA2, "PASS")
except Exception as e:
    print("ooops, something wrong while linking :(", e)
    while True:
print("Link established")

device = 0
status = 0

while True:

    len = ser2.available()
    if len > 0:

        # Read a line of data.
        line = ser2.readline()
        line = str(line)

        if "Failed" in line:
        elif "aa->" in line:
        elif "Data" in line:
            # are the following be freed by the garbage collector?
            line = line.split('Data ')
            line = line[1].split(',')
            device = int(line[0],0)
            status = ord(line[1])

            #could it be these prints, when not connected to a terminal prg?
            print("device == ", device)
            print("state == ", status)

            payload = {'msg':str(device)+":"+str(status)}
                response = requests.get("", params=payload)
            except Exception as e:



Hi @nigelibrown,

have you come up with a solution?
There is no need to connect the ESP32 to a terminal when a print is called, while tracemalloc in not available in Zerynth, but you can take a look at the gc module to trace memory usage.