Author Topic: Raspberry Pi wifi problem  (Read 1817 times)

Tim Hall

  • Victoria is my queen
Raspberry Pi wifi problem
« on: 10 December, 2023, 07:54:00 pm »
I have an old Raspberry Pi (Model B, 512MB ) which, as mentioned elsewhere I'm planning to use as a trailcam.  There's no built in WiFi, but I do have a PiHut USB WiFi dongle. This doesn't seem to work.  No connection to me homewifi. I've found a step by step troubleshooter here https://forums.raspberrypi.com/viewtopic.php?t=44044

Steps 1-3 all check out OK:
lsusb
Quote
Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
lsmod
Quote
rt2800usb              18171  0
rt2800lib             139752  1 rt2800usb
rt2x00usb              14609  1 rt2800usb
rt2x00lib              53280  3 rt2800lib,rt2800usb,rt2x00usb
mac80211              880872  3 rt2800lib,rt2x00lib,rt2x00usb
ifconfig -a
Quote
wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 00:0f:60:04:e1:6b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
/etc/network/interfaces just has this in it:
Code: [Select]
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source /etc/network/interfaces.d/*
Does that mean the interfaces file is looking for what ever is in /interfaces.d ?
interfaces.d is an empty directory. 
Reading further down the guide, it says
Quote
By default, Raspbian has in /etc/network/interfaces this line:

Code: Select all

wpa-roam /etc/wpa-supplicant/wpa_supplicant.conf
Well mine didn't, possibly because it's Raspberry Pi OS, the new name for Raspian , indicating that the guide is a bit out of date. Anyway, I modified /etc/network/interfaces to read as follows
Code: [Select]
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source /etc/network/interfaces.d/*
auto wlan0

auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
wpa_supplicant.conf has
Code: [Select]
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
        ssid="<redacted SSID>"
        psk="<redacted passkey>"
        key_mgmt=WPA-PSK
}

And it still doesn't work.  Any clues?

A wired connection works just fine.


There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

Re: Raspberry Pi wifi problem
« Reply #1 on: 11 December, 2023, 07:31:27 am »
Tim,
Network manager setup guide for Debian Bookworm (latest Rpi OS) should help:
https://www.abelectronics.co.uk/kb/article/31/set-a-static-ip-address-on-raspberry-pi-os-bookworm#:~:text=With%20the%20release%20of%20Raspberry,report%20on%20the%20network%20status.

Are you using an adapter as below?


IME even with a token external antenna they don't work very well over distance.
As I expect you are intending SSH over a flaky connection Mosh will be useful. https://mosh.org/

I spent far too long trying to get a Pi, albeit running MoodeOS, to connect using one.
Eventually gave up. £80 for a NOS Draytek mesh AP with four LAN ports that 'just works' with my router was money well spent.




Re: Raspberry Pi wifi problem
« Reply #2 on: 11 December, 2023, 08:12:04 am »
Another tip...  when you plug the adapter in run:

sudo dmesg

Also tail the system logs as you plug the adapter in.
In a terminal run   sudo journalctl -f     
Then plug adapter in

Tim Hall

  • Victoria is my queen
Re: Raspberry Pi wifi problem
« Reply #3 on: 13 December, 2023, 07:08:12 pm »
Sorry, been away, so only just round to trying these.

aidan, my adaptor is a tiny usb adaptor with no external antenna. At present I'm just trying to connect it to the network while it sits in the room next to the router. Following your link I ran
Code: [Select]
timsoldpi@raspberrypi:~ $ nmcli -p
Error: NetworkManager is not running.
A spot of googling suggested I run
Code: [Select]
timsoldpi@raspberrypi:~ $ sudo systemctl start NetworkManager
This then got the following result
Code: [Select]
eth0: connecting (configuring) to Wired connection 1
        "Microchip SMSC9512/9514"
        ethernet (smsc95xx), B8:27:EB:26:B5:4A, hw, mtu 1500

lo: unmanaged
        "lo"
        loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536

wlan0: unmanaged
        "Ralink RT5370"
        wifi (rt2800usb), 00:0F:60:04:E1:6B, hw, mtu 1500
Which I think is because the wlan0 adaptor is in /etc/network/interfaces
I'll look into that a bit more.

Meanwhile Scum, sudo dmesg says

Code: [Select]
[255624.188716] wlan0: authenticate with c8:99:b2:04:42:58
[255624.188866] wlan0: 80 MHz not supported, disabling VHT
[255624.249492] wlan0: send auth to c8:99:b2:04:42:58 (try 1/3)
[255624.307047] wlan0: send auth to c8:99:b2:04:42:58 (try 2/3)
[255624.348078] wlan0: send auth to c8:99:b2:04:42:58 (try 3/3)
[255624.403633] wlan0: authentication with c8:99:b2:04:42:58 timed out
Many many times. Off to look that up.
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

Re: Raspberry Pi wifi problem
« Reply #4 on: 13 December, 2023, 08:45:02 pm »
This post lists the nmcli commands to connect to a wifi network
https://yacf.co.uk/forum/index.php?topic=122318.msg2701605#msg2701605
although in your case use wlan0 rather than wlp2s0

Re: Raspberry Pi wifi problem
« Reply #5 on: 13 December, 2023, 08:53:51 pm »
If you are going to use network manager I think you should probably remove the auto wlan0 stuff from /etc/network/interfaces, but I'm not really sure.

vorsprung

  • Opposites Attract
    • Audaxing
Re: Raspberry Pi wifi problem
« Reply #6 on: 13 December, 2023, 09:26:39 pm »
Quote
jamie@raspberrypi:~ $ more /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
   ssid="FRITZ!Box 7530 HL"
   scan_ssid=1
   psk="supersecretlongnumberhere"
   key_mgmt=WPA-PSK
}
jamie@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID:   Debian
Description:   Debian GNU/Linux 11 (bullseye)
Release:   11
Codename:   bullseye

I also altered something at boot up but as you already get mac addresses out of the wifi stuff that should be ok

Tim Hall

  • Victoria is my queen
Re: Raspberry Pi wifi problem
« Reply #7 on: 13 December, 2023, 11:50:41 pm »
I *think* it's not authenticating when it submits the passkey.

Because of some old bit of kit (Buffalo Airstation) attached to the network, the router is set to WPA/WPA2 (TKIP).  I've been reading up on the "proto" argument in wpa_supplicant.conf.  If that's not defined it defaults to WPA RSN

So, progress of sorts.

I've edited wpa_supplicant_conf so it reads:
Code: [Select]
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
ssid="redacted SSID"
psk="redacted PSK"
proto=WPA
key_mgmt=WPA-PSK
}

But it still doesn't go. I get the impression that the wpa_supplicant.conf isn't being read on booting the Pi.  There's a wifi GUI built in to the Raspberry Pi OS which has all the fields empty.
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

vorsprung

  • Opposites Attract
    • Audaxing
Re: Raspberry Pi wifi problem
« Reply #8 on: 22 December, 2023, 08:31:35 pm »
copy the wpa_supplicant.conf to the boot partition, then reboot maybe?

dunno, think you are right and there is some weirdness required in the wpa_supplicant.conf file to make it work

vorsprung

  • Opposites Attract
    • Audaxing
Re: Raspberry Pi wifi problem
« Reply #9 on: 22 December, 2023, 08:39:54 pm »
also, does

iwlist wlan0 scanning

tell you anything?

Tim Hall

  • Victoria is my queen
Re: Raspberry Pi wifi problem
« Reply #10 on: 28 December, 2023, 09:23:13 pm »
Sorry, been busy. Christmas, stuff like that.

The desktop on the pi (running Raspberry PI OS) shows the available wifi networks.  Similarly "iwlist wlan0 scanning" brings up a list (with loads of other information) of available networks. This suggests the usb wifi dongle is working.

From the desktop I can select my home network and type in the password. It then fails to connect, failing to authenticate.

I went through the steps here https://gist.github.com/chatchavan/3c58511e3d48f478b0c2 as it relates to an old style Pi B, which is what I have.
I then edited /etc/wpa_supplicant/wpa_supplicant.conf as follows, as I'm using TKIP.

Code: [Select]
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1



network={
        ssid="PLUSNET-WKC2FS"
        key_mgmt=WPA-PSK
        pairwise=CCMP TKIP
        group=CCMP TKIP
        psk="REDACTED"
}
I then went to /etc/network/interfaces (not "interface" as it says in the referenced guide. where the guide says "Find the section about wlan0 and replace it with one of the following configuration (again, depending on your authentication type)."  /etc/network/interfaces only had this in it

Code: [Select]
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source /etc/network/interfaces.d/*
To my mind that says go and look in interfaces.d for configuration information.  There was nothing in interfaces.d so I created a file called wlan0 in which I put
Code: [Select]
auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
which is what the guide says should be added to /etc/network/interfaces.
Then I ran
Code: [Select]
sudo ifdown wlan0with the response
Code: [Select]
ifdown: interface wlan0 not configured
Which doesn't look good.
Code: [Select]
sudo ifup wlan0Says
Code: [Select]
wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
ifup: failed to bring up wlan0

(You might get the impression I know bugger all about what I'm doing. You would be right)
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

vorsprung

  • Opposites Attract
    • Audaxing
Re: Raspberry Pi wifi problem
« Reply #11 on: 28 December, 2023, 10:04:28 pm »
i guess you have buggered up the config of wpa_supplicant so it won't start

Re: Raspberry Pi wifi problem
« Reply #12 on: 03 January, 2024, 05:33:29 pm »
If you just put all the text config files back to default does it not work using the GUI ?
That should be able to do WPA2 with PSK.
Just click the WiFi icon on the desktop task bar
I think you'll find it's a bit more complicated than that.