Switch Wifi On and Off

Hey Guys, i build a Dashboard and i want to have a button to switch the Raspberrys wifi on and off.

Is there a way to do that?

Best regards

If you can work out how to do that on the Pi from the command line then you can run that command from an Exec node.

Hey Colin, thank you very much! I dont inow that i can do run that in node red the same way as in the command line!

There are multiple ways to do that with the raspberry, when my new one come tomorrow, i will test:

sudo rfkill block wifi = off
sudo rfkill unblock wifi = on

In that case you can configure an exec node with that as the command line (uncheck the box for Append Payload.
There is an issue though if you need to enter the password when you run that command, if you do need to enter a password then you can change that by using sudo visudo and adding a line to say that the node red user does not need to enter a password for the rfkill command. If you need to do that and google doesn't help you work out how then ask again. If you already don't need to enter a password then you don't need to do that obviously.

You have to do the visudo thing, you can't call sudo from an exec node..

I thought that the exec node could run commands as sudo??
If not, why does sudo reboot in a exec node reboot a pi, whilst simply reboot doesn't?

The standard Raspbian OS install allows the user pi to use sudo without entering a password, therefore any sudo command can be run from an exec node.
Personally I believe that can be a security issue so I always disable that and change the default user name.


Like Colin said it works without the visudo thing, only the exec node with the command works fine =).

Thank you very much!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.