GoPiGo O/S: Read WiFi connection status and type?


Is it possible to determine, programmatically, what state the WiFi is in?

Seeing as it can be in one of several possible states:

  1. Access Point mode, disconnected.
  2. Access Point mode, connected.
  3. Networked mode, disconnected.
  4. Networked mode, connected.
  5. Completely disabled.

it would be nice to know what state it’s in, and - just as important - when or if it changes state.


Obviously, since the software driving the WiFi LED can tell four of those, the answer lies in finding the source code for the wifi service. I figured it out on Raspbian For Robots, but since I keep my GoPiGo OS card in “unaltered” state, it is a royal pain to get connected every time.

In R4R the antena_wifi.service runs this file every 10 seconds to set the LED based on the bot autodetect code and

iwgetid --scheme

returning the SSID of a network connection:

more ../Dexter/GoPiGo3/Install/
# 1 Detect if we are on a GoPiGo3
# 2 Detect if we have Wifi connection
# 3 Throw a yellow-orangey LED or turn it off

# If detected_robot exists and it contains GoPiGo3, or 
# if it doesn't exist at all on standalone Raspbian
if [ -f "/home/pi/Dexter/detected_robot.txt" ] && grep -q GoPiGo3 /home/pi/Dexter/detected_robot.txt  || [  ! -f "/home/pi/Dexter/detected_robot.txt" ]
    if iwgetid --scheme
        python -c "import gopigo3;GPG=gopigo3.GoPiGo3();GPG.set_led(GPG.LED_WIFI,3,1,3)"
        python -c "import gopigo3;GPG=gopigo3.GoPiGo3();GPG.set_led(GPG.LED_WIFI,0,0,0)"

On R4R, autodetect source is here (I’m pretty sure it is also in the gopigo3 python site packages):
$ find …/Dexter | grep auto_detect


auto_detect_rpi (version 3 or 4) is also there.