Wifi not connecting Pi Zero W

First try with Balena. So far I had been using Raspotify with no issue on the same board but was eager to have Airplay and BT as well.
The pi does not connect to my wifi. The green LED flashes 4 times (alternating with a longer led-ON, not a longer “pause” as described in the tutorial :frowning: )

I know it is not the same issue as Unable to connect to WiFi on RPi Zero W because as I said this board works just fine with Raspotify.

I am of course specifying the 2.4GHz SSID , not the 5GHz one. Yes I have double checked my credentials in resin-wifi-01
I don’t have a mini HDMI cable sadly so don’t know what the error message could be.
Is a log actually created by Balena that I could access on the SD CArd?

Hi, by default logging in BalenaOS is performed to memory, so before being able to access the logs from the SD card you need to enable persistent logging. You can do this by pre-configuring the image before flashing it to the device by using the balena CLI. For example from a Linux shell you can execute:

sudo balena config write --type raspberrypi persistentLogging True

Please modify the device type (raspberrypi) above to your specific device type.
After flashing the image and booting, please leave it some type for the logs to be flushed into the card. You can then use a disk reader and access the logs in the resin-data partition of your SD card, under root-overlay/var/log/journal.
Please note that if the device manages to connect to BalenaCloud, the persistent logging setting will be synched to the cloud configuration which is off by default. If this happens you will see the device automatically rebooting after the remote setting is applied.
You will then be able to point a journalctl tool running on a Linux machine to read the logs with;

sudo journalctl --directory /path/to/sdcard/resin-data/root-overlay/var/log/journal/

THX Alex

Could you please provide more details? I have a linux PC from which I Dowload the .img which I then dd to the micro sd card.
Installing Balena CLI seems beyond my reach.

PS: I have tried 2.54.2 and 2.48.0, “prod” or “dev”.
I have tried using my Guest Wifi SSID instead of my main one (both 2.4)
I have setup my router in wpa2 and wpa+wpa2

hey there

also, out of curiosity, have you tried balenaSound? https://sound.balenalabs.io/

You can use it with airplay and BT.

Thanks Rahul

Using BalenaSound is indeed the purpose of me trying to get my pi to connect to wifi!

Without it connecting - I cannot do anything of it - I cannot serial-com into it to run the command above.

I’ll try the zip package from my linux laptop with the -d option, thanks.

Hi
Thanks for letting us know how it works out.

Logging setup :slight_smile:

peter@X220:/usr/bin/balena-cli$ sudo /usr/bin/balena-cli/balena config write --drive /dev/sdb --type raspberrypi persistentLogging True
Setting persistentLogging to True
Done

Pi did as usual the 4 green flash cycle. let it run for a few minutes then turned it off.

no folder as per your instructions : (

peter@X220:/usr/bin/balena-cli$ cd /media/peter/resin-
resin-boot/  resin-data/  resin-rootA/ resin-rootB/ resin-state/ 
peter@X220:/usr/bin/balena-cli$ cd /media/peter/resin-data/
peter@X220:/media/peter/resin-data$ ls -lapeter@X220:/usr/bin/balena-cli$ cd /media/peter/resin-
resin-boot/  resin-data/  resin-rootA/ resin-rootB/ resin-state/ 
peter@X220:/usr/bin/balena-cli$ cd /media/peter/resin-data/
peter@X220:/media/peter/resin-data$ ls -la
total 20
drwxr-xr-x   5 root root  1024 Apr 16 02:31 .
drwxr-x---+  7 root root  4096 Sep  8 22:12 ..
-rw-r--r--   1 root root     3 Apr 16 02:31 apps.json
drwx--x--x  15 root root  1024 Apr 16 02:31 docker
drwx------   2 root root 12288 Feb 14  2020 lost+found
drwxr-xr-x   3 root root  1024 Apr 16 02:31 resin-data
peter@X220:/media/peter/resin-data$ cd resin-data/
peter@X220:/media/peter/resin-data/resin-data$ ls
resin-supervisor
peter@X220:/media/peter/resin-data/resin-data$ 
total 20
drwxr-xr-x   5 root root  1024 Apr 16 02:31 .
drwxr-x---+  7 root root  4096 Sep  8 22:12 ..
-rw-r--r--   1 root root     3 Apr 16 02:31 apps.json
drwx--x--x  15 root root  1024 Apr 16 02:31 docker
drwx------   2 root root 12288 Feb 14  2020 lost+found
drwxr-xr-x   3 root root  1024 Apr 16 02:31 resin-data
peter@X220:/media/peter/resin-data$ cd resin-data/
peter@X220:/media/peter/resin-data/resin-data$ ls
resin-supervisor
peter@X220:/media/peter/resin-data/resin-data$

there is a folder with this name under resin-state but nothing inside

peter@X220:/media/peter/resin-state$ cd root-overlay/
peter@X220:/media/peter/resin-state/root-overlay$ ls -la
total 5
drwxr-xr-x 5 root root 1024 Jan 28  2020 .
drwxr-xr-x 4 root root 1024 Jan 28  2020 ..
drwxr-xr-x 8 root root 1024 Jan 28  2020 etc
drwxr-xr-x 3 root root 1024 Jan 28  2020 home
drwxr-xr-x 3 root root 1024 Jan 28  2020 var
peter@X220:/media/peter/resin-state/root-overlay$ cd var
peter@X220:/media/peter/resin-state/root-overlay/var$ ls -la
total 3
drwxr-xr-x 3 root root 1024 Jan 28  2020 .
drwxr-xr-x 5 root root 1024 Jan 28  2020 ..
drwxr-xr-x 6 root root 1024 Jan 28  2020 lib
peter@X220:/media/peter/resin-state/root-overlay/var$ cd lib/
peter@X220:/media/peter/resin-state/root-overlay/var/lib$ ls
bluetooth  chrony  NetworkManager  systemd
peter@X220:/media/peter/resin-state/root-overlay/var/lib$ cd NetworkManager/
peter@X220:/media/peter/resin-state/root-overlay/var/lib/NetworkManager$ ls
NetworkManager-intern.conf  timestamps
peter@X220:/media/peter/resin-state/root-overlay/var/lib/NetworkManager$ cat timestamps 
[timestamps]
a8bb4cc8-7318-401a-a51f-03f3ab6994bd=1586968586
ca006e81-1b55-4c10-9298-1e74b427c948=1586969486
708d7284-c4e3-450b-a67f-c50b08bd04a3=1586968300
peter@X220:/media/peter/resin-state/root-overlay/var/lib/NetworkManager$ cat NetworkManager-intern.conf 
# Internal configuration file. This file is written and read
# by NetworkManager and its configuration values are merged
# with the configuration from 'NetworkManager.conf'.
#
# Keys with a ".set." prefix specify the value to set.
# A corresponding key with a ".was." prefix records the value
# of the user configuration at the time of storing the file.
# The value from internal configuration is rejected if the corresponding
# ".was." key no longer matches the configuration from 'NetworkManager.conf'.
# That means, if you modify a value in 'NetworkManager.conf', the internal
# overwrite no longer matches and is ignored.
#
# Certain sections can only be overwritten whole, not on a per key basis.
# Such sections are marked with a ".was" key that records the user configuration
# at the time of writing.
#
# Internal sections of the form [.intern.*] cannot
# be set by user configuration.
#
# CHANGES TO THIS FILE WILL BE OVERWRITTEN
peter@X220:/media/peter/resin-state/root-overlay/var/lib/NetworkManager$

the rpi zero W only supports 2.4GHz networks - just to make sure this is not the issue, can you make sure you are not configuring it against a 5GHz access point?

Thx.
I confirm this is a 2.4 network.

Hi, it seems persisten logging was not set on the device - can you inspect config.json in resin-boot and see what is the value for persistentLogging ?

Indeed it was still false, although as per earlier the balena cli apparently “worked”

peter@X220:/usr/bin/balena-cli$ sudo /usr/bin/balena-cli/balena config write --drive /dev/sdb --type raspberrypi persistentLogging True
Setting persistentLogging to True
Done

I cold have set it to true in the json file directly would have been simpler than using the balena cli :frowning:

Hi

Now that you have persistent logging enabled, I think we can start the debugging process for the wifi. Once you have kept the device on for a bit, it will have tried to connect to the configured wifi. When it fails, it will have logs written to file that you can access by connecting the SD card to your laptop/PC.

Can you share those logs? They should be in the /var/log/journal folder

https://pastebin.pl/view/b1649453

Thanks for the logs. Taking a look now

THX

Hi

So I compared the logs you shared with one of my devices which connects to wifi.

This is the part where the logs for NetworkManager service diverged -

Sep 09 04:21:20 21512a8 NetworkManager[1362]: <info>  [1599625280.2909] manager: NetworkManager state is now CONNECTED_LOCAL
Sep 09 04:21:20 21512a8 NetworkManager[1362]: <info>  [1599625280.2952] policy: set-hostname: set hostname to '21512a8' (from system configuration)
Sep 09 04:21:20 21512a8 NetworkManager[1362]: <info>  [1599625280.2955] device (supervisor0): Activation: successful, device activated.
Sep 09 04:21:20 21512a8 NetworkManager[1362]: <info>  [1599625280.8320] policy: auto-activating connection 'resin-wifi-01' (a58e405d-fdc2-3649-9339-5bbaea740c76)
Sep 09 04:21:20 21512a8 NetworkManager[1362]: <info>  [1599625280.8346] device (wlan0): Activation: starting connection 'resin-wifi-01' (a58e405d-fdc2-3649-9339-5bbaea740c76)
Sep 09 04:21:20 21512a8 NetworkManager[1362]: <info>  [1599625280.8352] device (wlan0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Sep 09 04:21:20 21512a8 NetworkManager[1362]: <info>  [1599625280.8369] manager: NetworkManager state is now CONNECTING
Sep 09 04:21:20 21512a8 NetworkManager[1362]: <info>  [1599625280.8685] device (wlan0): set-hw-addr: reset MAC address to 48:A4:93:04:99:9A (preserve)

So looks like network manager is having trouble finding the creds in resin-wifi-1. Your logs show no mention of that at all - which is suspect. Can you see if your resin-boot partition has indeed the requisite file?

I have tried with quotes around the SSID and psk as well.

Yeah that looks good to me.
I have pinged the engineer who works with the wifi related stuff for figuring how to debug this further

THX