Turn-off Wifi when connected to LAN - PiZero

General support for the Pi-Star System
Post Reply
PA2TSL
Posts: 13
Joined: Wed Apr 11, 2018 5:08 pm

Turn-off Wifi when connected to LAN - PiZero

Post by PA2TSL » Thu Aug 30, 2018 2:28 pm

Hello all,

I have a LAN to USB adapter in use with my PiZero - Jumbospot hotspot.
This works fine, and it is much more stable compared with the Wifi option.
This is, to my opinion, the best solution when the hotspot is on a fixed location.
However, it appears that the Wifi is not turned off when the LAN option is used...
So now I have 2 different IP addresses... which is not a disaster but I want to use only the LAN IP address when it is connected to it..
Is it possible to get the Wifi turned-off when the LAN port is used?? And, of course, will the Wifi be available again as soon as the LAN is disconnected?

M0GLJ

Re: Turn-off Wifi when connected to LAN - PiZero

Post by M0GLJ » Thu Aug 30, 2018 6:57 pm

You could write a script that looks for an ethernet connection and then disables wifi and then when if can't see the ethernet enables wifi

PA2TSL
Posts: 13
Joined: Wed Apr 11, 2018 5:08 pm

Re: Turn-off Wifi when connected to LAN - PiZero

Post by PA2TSL » Sat Sep 01, 2018 9:08 am

Maybe this could be an 'enhancement' in the Pi-Star image. Unfortunately, I do not have the expertise to create that script.

PA2TSL
Posts: 13
Joined: Wed Apr 11, 2018 5:08 pm

Re: Turn-off Wifi when connected to LAN - PiZero

Post by PA2TSL » Fri Apr 05, 2019 12:17 pm

CAUTION: I have found a serious problem when using the command rfkill, see my edit in the original post:

I have (I thought I had), finally, found a simple work-around to disable wifi when connected to LAN.
You have to use SSH access in the Expert mode, and typing the following command:

sudo rfkill block wifi

That's all! To enable wifi again just reboot (THIS DOES NOT WORK, WiFi REMAINS OFF AFTER A REBOOT/RESTART!!!), or use the following command:

sudo rfkill unblock wifi (this only works with the LAN connected!)

You can view the interface status in the Wireless Configuration screen.
Btw, the cmd 'rfkill' is only available in the beta version 4 of Pi-Star...

So, finally, this option to turn the wifi adapter temporary off is not useful: it corrupts something so that the wifi adapter will not turn on after rebooting or restarting... Still searching for a proper solution...

This situation is also applicable for the Raspberry Pi 3B (+) which has LAN and wifi.

Post Reply