Ping responce stops working after several hours
Port, board and/or hardware
Raspberry Pi Pico W with RP2040; Raspberry Pi Pico 2 W with RP2350
MicroPython version
MicroPython v1.24.0; MicroPython v1.25.0;
Reproduction
- Install RPI_PICO2_W-20250415-v1.25.0.uf2 on Raspberry Pi Pico 2 W.
- Create main.py with script below on device.
- Power on device with USB or batery.
- Wait 10 hours. Do not access the device over the network.
- On PC (in my case Windows 10) run command "ping 192.168.10.241 -t".
# main.py
import network
from time import sleep
from machine import Timer, Pin
led = machine.Pin("LED", machine.Pin.OUT);
wfssid = "xxxxxxxxxx"
wfpass = "xxxxxxxxxx"
wlan = network.WLAN(network.STA_IF);
wlan.active(True);
print(f'Connecting to "{wfssid}" AP. ', end="")
wlan.connect(wfssid, wfpass);
while wlan.isconnected() == False:
sleep(1.0);
print('.', end="");
print(' Done !');
print(wlan.ifconfig())
def cb1sec(timer):
# To be sure that the device is working
led.on()
sleep(0.001);
led.off()
timer1sec = Timer(period=1000, mode=Timer.PERIODIC, callback=cb1sec)
while True:
sleep(10.0);
Expected behaviour
Starts respond on pings immidiately.
Observed behaviour
Starts to respond after 10...60 unsuccessful pings.
Additional Information
The device stops responding to ping after a few hours of operation.
Powered by USB or battery, no USB connection (with USB connection it also sometimes "hangs")
The device "hangs" after 1...10 hours.
During this time, do not access the device over the network!
During "hanging":
- Unable to connect to FTP server on device.
- Ping from device continues to work!
When device is "frozen", you can "wake it up" using command:
ping 192.168.10.241 -t
Initially, the device does not respond to pings, but after 10...60 unsuccessful pings, device starts responding and normal operation of network interface is restored.
See:
Raspberry Pi Pico W network becomes inaccessible when not used for some time #9455
With network.PPP device hangs after several hours of operation #16340
#9455 and #16340 probably have the same root cause.
Not Reproducing on:
MicroPython v1.25.0 on 2025-04-15; ESP module with ESP8266. (ESP8266 Wemos D1 mini)
Code of Conduct
Yes, I agree
With network.PPP device hangs after several hours of operation
Port, board and/or hardware
rp2
MicroPython version
MicroPython v1.25.0-preview.72.g2e796d6c3.dirty on 2024-11-30; Raspberry Pi Pico W with RP2040
Reproduction
import time
import network
from machine import UART, Pin
import constants
class Modem:
def __init__(self, log):
self.log = log
self.uart = UART(0, 115200, rxbuf=1000)
self.power_pin = Pin(constants.MODEM_POWER_PIN, Pin.OUT)
self.status_pin = Pin(constants.MODEM_STATUS_PIN, Pin.IN)
self.ppp = None
def send_at_comm(self, command, timeout=5):
self.log.info("AT:", command)
compose = f"{command}\r\n".encode()
try:
self.uart.write(compose)
except:
self.log.info("Error occured while AT command writing to modem")
time.sleep(0.1)
return self.get_response(timeout)
def get_response(self, timeout=5):
response = ""
timer = time.time()
while True:
time.sleep(0.1)
if time.time() - timer < timeout:
while self.uart.any():
try:
response += self.uart.read(self.uart.any()).decode("utf-8")
except:
pass
return response
else:
return "timeout"
def connect_PPP(self):
self.reset()
time.sleep(2)
result = self.send_at_comm("ATZ")
self.log.info(result)
time.sleep(2)
result = self.send_at_comm("AT")
self.log.info(result)
time.sleep(2)
result = self.send_at_comm('AT+CGDCONT=1,"IP","super"')
self.log.info(result)
time.sleep(2)
operator = self.operator()
self.log.info(result)
time.sleep(2)
result = self.send_at_comm("ATDT*99#")
self.log.info(result)
time.sleep(2)
self.ppp = network.PPP(self.uart)
time.sleep(2)
self.ppp.connect()
while not self.ppp.isconnected():
self.log.info("connecting PPP")
time.sleep(2)
self.log.info("PPP connected", self.ppp.ifconfig())
return operator
def operator(self):
command = "AT+COPS?"
response = self.send_at_comm(command)
self.log.info(response)
operator = None
access_technology = None
response = self.preprocess_response(response)
pos = response.find("+COPS: ")
if pos:
splitted = response[pos:].split(",")
self.log.info(splitted)
operator = splitted[2]
if splitted[3] == "0":
access_technology = "GSM"
elif splitted[3] == "8":
access_technology = "LTE CAT M1"
elif splitted[3] == "9":
access_technology = "LTE CAT NB1"
return {"operator": operator, "access_technology": access_technology}
def power_toggle(self):
self.power_pin.high()
time.sleep(2)
self.power_pin.low()
def is_on(self):
value = self.status_pin.value()
if value == 0:
return True
return False
def reset(self):
self.log.info("reseting modem")
if self.is_on():
self.power_toggle()
time.sleep(2)
self.power_toggle()
def preprocess_response(self, data):
return data.replace("\r\n", ",")
Expected behaviour
PPP works until disconnect
Observed behaviour
Device hangs after several hours of operation. Im using Sixfab PicoLTE (Pico W integrated with Quectel BG95-M3 modem).
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree