Octoprint on Raspberry Pi 4 will not work on wifi

I am unable to connect to my Raspberry Pi running Octoprint 1.4.0, Octopi 0.17.0. The wireless adapter is able to see the network and connect to the network from a Pi 3 (dont have mico hdmi adapters). The wireless only address is 169.254.166.16 which is not a valid address.

I have tried googling around for more information. The only way I can connect to the pi remotely is by having the ethernet plugged in. I have attempted disabling dhcpcd (dont it breaks and you have to rescue it with a monitor), looking at the network settings, tried moving the country code to above the network block in the octopi-wpa-supplicant.txt file. I have also attempted to set a static IP on the router for the pi

Logs (syslog, dmesg, ... no logs, no support)
Not sure which logs will be useful but I keep seeing multiple lines that seem to point to a configuration issue, just not sure where:
Apr 23 20:54:22 octopi dhcpcd[676]: wlan0: using IPv4LL address 169.254.166.16
Apr 23 20:54:22 octopi avahi-daemon[309]: Joining mDNS multicast group on interface wlan0.IPv4 with address 169.254.166.16.
Apr 23 20:54:22 octopi avahi-daemon[309]: New relevant interface wlan0.IPv4 for mDNS.
Apr 23 20:54:22 octopi dhcpcd[676]: wlan0: adding route to 169.254.0.0/16
Apr 23 20:54:22 octopi avahi-daemon[309]: Registering new address record for 169.254.166.16 on wlan0.IPv4.

This is the route information:
route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.1 0.0.0.0 UG 202 0 0 eth0
link-local 0.0.0.0 255.255.0.0 U 303 0 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 202 0 0 eth0

The network is functioning fine, all other devices have valid IP addresses. When the Pi is plugged in with ethernet it seems to get a valid IP address. Overall to me, this seems to point to an issue wit dhcpcd but the config file looks to be just the base config file.

Any help is appreciated. If more logs are needed, I will happily grab them.

Thanks for any advice.

Post your octopi-wpa-supplicant.txt file, please.

Here is the octopi-wpa-supplicant.txt file. I removed the header part with the instructions to save space. As stated above, I have tried with the country above and below in this file and dont seem to have any luck.

country=US # United States

## WPA/WPA2 secured
network={
  ssid="MyNetwork"
  psk="MyNetworkPassword"
}

## Open/unsecured
#network={
#  ssid="put SSID here"
#  key_mgmt=NONE
#}

## WEP "secured"
##
## WEP can be cracked within minutes. If your network is still relying on this
## encryption scheme you should seriously consider to update your network ASAP.
#network={
#  ssid="put SSID here"
#  key_mgmt=NONE
#  wep_key0="put password here"
#  wep_tx_keyidx=0
#}

# Uncomment the country your Pi is in to activate Wifi in RaspberryPi 3 B+ and above
#country=GB # United Kingdom
#country=CA # Canada
#country=DE # Germany
#country=FR # France
#country=US # United States

### You should not have to change the lines below #####################

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

Assuming that "MyNetwork" and "MyNetworkPassword" are replaced with the real thing then I'm afraid I can't think of anything else. I don't have a Raspberry Pi 4 but I am running OctoPi 0.17.0 and OctoPrint 1.4.0 on a 3B without any problems. I have an RPi 3B+ as well.

I'd like to buy a Raspberry Pi 4 but I want to make sure I get the latest hardware revision.

Thanks for looking. I think it is a config issue somewhere just need to trace it down. might be something with the way dhcpcd is handling the connection stuff. The interesting part to me is the address assignment of the 169.x.x.x address which is the reserved address range for not being able to reach the internet. Odd thing is that I can see the 169 address in the router as an attached device.

That IP address range you got is the basic "I am an island" type of private address. It's what I would get here on my MacBook if I took it to the desert and fired it up.

Plug the ethernet cable in, remote into it and scan for your wifi zone(s).

sudo iwlist wlan0 scan

Note that the Pi 4B supports 5Ghz zones so perhaps your router isn't properly configured on that side of things.

I am able to see the 2.4 Ghz network SSID. As you mentioned, I am also able to see the 5 Ghz network from the Pi. I have other devices that use these networks that are functioning fine.

Oddly, once I unplugged the ethernet cord while the PI was connected to the network, I am able to access the pi over the network on its assigned IP address. To me, this may indicated a configuration issue some where along the lines that is trying to get an IP address on eth0, which it cant, then binding it to all the interfaces. Seems to be working now though.

It's probably just that the default gateway setting is wrong when the Ethernet cable is attached.