Display Wifi infomation on a PLC touch screen

I have a plc wired to my raspberry pi and it is comunicating over TCP IP. Now I want to show on the display of the plc that the pi is connected to WiFi and the strength of the signal. I used Wifi scanner but now I don't see which network is connected. Is there another possibility to do this in node-red?

To check the signal strength you can use:
iwlist scan wlan0

However, I think this can only be done with sudo, you cannot execute privileged commands with node-red unless you run it as root (not recommended).

There is another command that doesn't require root.

nmcli dev wifi

(perhaps you need to install it first, I'm not using a Pi at the moment:sudo apt-get install network-manager)

1 Like

Yes you can :wink:

All you need to do is to run the command visudo and add the iwlist command as allowed from sudo without requiring a password. Then you can happily call sudo iwlist scan wlan0 from an exec node.

You could also allow all commands to use sudo without a password prompt though that is obviously less secure.

Either way, the user id being used still has to be in the correct group which gives admin access.

The first option is a reasonable suggestion when you must run a command which would otherwise require the sudo password. In the OP's case running nmcli dev wifi | grep \* (as suggested by @bakman2) and parsing the output is better.

The second option is a terrible idea IMO. Never do this. Yes, this is how Raspbian is shipped, but that doesn't make it any better. Don't assume that just because its small and has a cute name that a Pi can't totally p*wn your network and (potentially) all the machines on it. It's just as capable of acting as a backdoor as any system. Stay safe!

1 Like

I think NASA has learned this the hard way ...

1 Like

hello everyone thank you very much for your responses.

I did the following because I could not fully follow your answers.

  1. Enterd "sudo visudo" in the commendline behind pi@raspberrypi:~$
  2. All the way at the bottom I enterd "myuser ALL=(root) NOPASSWD: /sbin/iwlist wlan0 scan"
  3. Ctrl x
  4. J
  5. Enter
  6. Reboot
  7. Open the command line and enterd "sudo iwlist wlan0 scan"

Now a lot of information about wlan0 appeared on the screen.

  1. Open the command line and enterd "iwlist wlan0 scan"

Now only the information of the connected wifi conection is show.

  1. In node-red I used an inject node an exec node and three debug nodes.
  2. In the exec node I enterd "sudo iwlist wlan0 scan"

This unfortunately does not work out as I had hoped. As you can see I am not very familiar with this material. can you give me some tips please?

Where do I have to enter nmcli dev wifi | grep \* ?

in the exec node - DON'T - put sudo... try the iwlist version without sudo.
(the whole point is that the exec node won't exec things as sudo ... :slight_smile:

1 Like
iwlist wlan0 scanning | egrep 'Cell |Encryption|Quality|Last beacon|ESSID'

Gives you good info about the ap you are connected to

sudo iwlist wlan0 scanning | egrep 'Cell |Encryption|Quality|Last beacon|ESSID'

Gives the same plus all other ap that are within the reach

1 Like

It worked now I just have to filter out the ESSID and the signal level. With this information I can show a wifi sign on the plc just like on your phone. in this way I can build a nice debug mode.


Urm, it does Dave :slight_smile: - reboots, restarts of NR, all sorts. It just needs a little encouragement.

To those who've pointed out about allowing sudo without p/w for all commands. Yes, it is certainly poor security as is leaving the default Pi user in place, especially with the default password. But still handy for testing. Put the devices on their own network (preferably a different VLAN) for a little more security.

Even worse if you forget and then allow inbound connections from the Internet as some people discovered not so long ago.

1 Like

But in this case it is not necessary as iwlist without sudo will do what the OP wants.


Yes - out of the box it won't.... so beginners try it and it doesn't...

I use the exec node to set the system date & time from a GPS via sudo date -s. This works because I have nodered ALL=(ALL) NOPASSWD: /bin/date in my /etc/sudoers file ("nodered" being the user account which Node-RED runs under).