2
$\begingroup$

I recently installed Octopi on my Raspberry Pi 4 and noticed some unusual behavior in that I lose the Wifi connection every 5-10 minutes immediately after boot. Once disconnected, I cannot re-establish the connection because my network's SSID doesn't even appear in the network list anymore. The only way I can re-establish the connection is to reboot the device.

With that said, I did find a troubleshooting discussion of similar problems at octoprint.org: OctoPi losing network connection mid-print.

Following the various advice, I must have tried about 12 different things, but none of them have fixed my issue. At first, I thought that wifi power-save mode was the most likely culprit. iw wlan0 get power_save indicated that power-save mode was turned on, but then I turned it off with iw wlan0 set power_save off and the wifi still disconnects.

Going a step further, I set up a script to run the iw command right after boot so that the change is made permanent, but that didn't work either.

Other troubleshooting attempts I tried:

  • Verified there is adequate power
  • Configured with settings for hidden SSID (even though mine is not hidden)
  • Set up a reconnection script that doesn't work because it can't find the network
  • Properly set up regional settings

I am at my wit's end.

As for my setup, I have an 8 GB Raspberry Pi 4 and am using an image of OctoPi 0.18.0 with OctoPrint 1.7.3. This I downloaded and imaged onto a 128 GB micro-SD card using the Raspberry Pi Imager. My wifi network is 2.5 GHz secured with WPA2 with a visible SSID and is definitely within close range. One way that I know that it is not a hardware issue is because I have another image with the Raspberry Pi OS 64-bit version and wifi works just fine when I run that.

As for Octopi, one atypical difference is that I am running it with a desktop. It may be that, for whatever reason, perhaps that particular distribution of RPi OS has a major bug in it? If so, then maybe I do have a solution, but I don't want to run without a desktop because I have a nice setup on my 3D printer that includes a touch screen. Given that is the case, could I maybe use the 64-bit Raspberry Pi OS and just load OctoPrint onto it with sudo apt-get [package-name] or something like that?

Any additional troubleshooting advice is much appreciated, but I suspect that not much else will work. I am not a greenhorn when it comes to linux-bases systems, but this is my first time trying out an image using Octopi.

$\endgroup$
3
  • 1
    $\begingroup$ It's probably something awful with whatever desktop-environment-integrated network manager you installed. These days a number of them (particularly whatever Android and ChromeOS are using, but I wouldn't surprise me if it's some of the same underlying software logic) are outright malicious about aggressively disconnecting and shadow-blocking networks they've decided are "low quality". $\endgroup$ Commented Apr 27, 2022 at 13:52
  • $\begingroup$ @R..GitHubSTOPHELPINGICE Yikes! I have a 1GB fiber connection and regularly get speeds in excess of 250 mbps over my wifi connection so I would not have guessed it could be a network manager doing such things. Any command that I could run to check and see? $\endgroup$ Commented Apr 27, 2022 at 20:56
  • $\begingroup$ I'd love to know so I could get Google devices to stop doing it... It doesn't seem to be a matter of bandwidth, but of how often the radio signal experiences disruption, and also something to do with WPA rekeying intervals. It's been over a year since I dug into it and didn't get anywhere solving the problem. $\endgroup$ Commented Apr 27, 2022 at 23:47

1 Answer 1

3
$\begingroup$

I think I have a solution for this. Please follow the steps mentioned in this Github page of mine for the Wifi connectivity issue. I rarely have any issues with the wifi signal dropping randomly.


Wi-Fi connectivity issue

  • Ensure that you have set up a static IP address for your Raspberry Pi.

  • Ensure that the command sudo ifconfig wlan0 up and sudo ifconfig wlan0 down works without the user password requirement.

  • To run the aforementioned commands without a password, do the following steps:

    sudo nano /etc/sudoers.d/010_pi-nopasswd
    
    • Add the following line to the file

      pi ALL=(ALL) NOPASSWD: /sbin/ifconfig wlan0 up, /sbin/ifconfig wlan0 down
      

      Here pi indicates the username of the Raspberry; update it as per your name.

  • Try running the commands sudo ifconfig wlan0 up and sudo ifconfig wlan0 down, it shouldn't ask for a password.

  • Beware before running the previous command ensure that you have not recently typed the password for any other sudo command or else try this in a new terminal.

  • To know more about this search the command sudo visudo

check_wifi.sh - script to check if Raspberry Pi is still connected to the wifi or not. If not then it restarts the wlan0.

#!/bin/sh
# keep wifi alive
if ping -c3 192.168.0.1 #router ip address
then
    echo "......"
    echo "No network connection, restarting wlan0"

    sudo ifconfig wlan0 down
    sleep 30
    sudo ifconfig wlan0 up

else
    echo "Wifi working normally."
fi
  • Add a cron job to check the WiFi connectivity every 5 minutes - sudo crontab -e

    # cron job for checking the wifi connection every 5 minutes
    */5 * * * * /home/pi/Octopi_Setting/check_wifi.sh > /dev/null 2>&1
    

Additional resources:

$\endgroup$
2
  • $\begingroup$ I have made some formatting changes to be more in line with the site's guidelines. Please review your answer to make sure I didn't mess anything up. $\endgroup$
    – agarza
    Commented Aug 24, 2022 at 1:26
  • $\begingroup$ I added in a disclosure; going forward, please remember to always mention when you are linking to a resource of your own as per the promotion policy. $\endgroup$
    – tripleee
    Commented Aug 24, 2022 at 4:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .