Moving ESP32 with ESPHome to a 2nd Wifi Network

I’m working in 2 buildings, our house, and our barn. We have a guest bedroom, my wife’s studio, and my workshop in the barn. I also do a lot of my development work in my study, in my house. The two buildings are over 300’ apart, through a heavily wooded forest, so they are out of wifi range. They both use the same DNS and are on the same LAN, but the wifi networks in the two buildings are separate.

I set up an ESP32 with ESPHome in my house, where the wifi is “TangoHouse,” and got the initial config done there last night. Now I have it in my workshop, where the wifi is “TangoBarn.”

I can’t see anything in the yaml file for my device that specifies the wifi SSID or password. Best option would be to be able to add this 2nd wifi SSID to the config for this ESPHome device, so it can operate on both networks without a problem and without the need to change the config as I switch the chip’s location. If that’s not possible, then I do need a way to change the config to at least use another wifi netowrk.


Adding: Both wifi networks share the same password. (There are reasons for the different SSIDs but not changing the password - but it’s a long story.) So if the password is encrypted somewhere, I would think I can copy and paste it for the 2nd LAN.

Take a look at

https://esphome.io/components/wifi#connecting-to-multiple-networks

For now I just want to get things working and make sure I have proof-of-concept of what I’m testing, so I’m not yet storing the wifi info in Secrets. I’ve added this to my configuration for the device:

wifi:
  networks:
    - ssid: TangoHouse
      password: And 5678
    - ssid: TangoBarn
      password: And 5678

(I hope it’s obvious I’m not using real SSIDs or passwords. My understanding is that yaml doesn’t use spaces as delimiters.)
I tried it with quotations around the passwords and without. I save the configuration (within the ESPHome addon to HA), then click INSTALL. I wait for it to be compiled, then download it, go to the ESPHome website, click “INSTALL,” upload my file, and wait. When it’s done, I try to ping the ESP32 and get nothing. To be sure, I reboot the chip and there is still no response for the ping command. (I have set my DHCP server, on a pfSense firewall, to use a fixed IP address for this chip’s MAC address.)

(Once I have this working and verify the ESP32 is controlling what I want it to, then I’ll worry about redoing this so the pw is in the Secrets config file. Just one question on that: When the ESPHome addon compiles the config file for the chip, am I right that during compiling it will reference and use values in secrets.yaml? So those will be included in the binary installed on the chip?

The docs show no quotes, looking at my own nodes they are in quotes. I think either will work. During compile the value of the secret variables are brought in. Check the ip table in the router jic. You can try adding fast_connect: true.

Your indentation is off. The ‘-’ should be underneath the ‘n’ of network, just like the docs show.

Thanks!

New wifi config - the entire wifi section:

wifi:
  networks:
  - ssid: TangoHouse
    password: And 5678
  - ssid: TangoBarn
    password: And 5678

I compile and install and here are the logs:

[00:23:44][D][wifi:482]: Starting scan...
[00:23:44][D][esp32.preferences:114]: Saving 2 preferences to flash...
[00:23:44][D][esp32.preferences:143]: Saving 2 preferences to flash: 0 cached, 2 written, 0 failed
[00:23:44][W][component:157]: Component wifi set Warning flag: scanning for networks
[00:23:44][D][esp32_ble:284]: Enabling BLE...
[00:23:44][D][esp32_ble_server:077]: BLE server setup successfully
[00:23:44][D][esp32_improv.component:077]: Creating Improv service
[00:23:44][D][wifi:497]: Found networks:
[00:23:44][D][wifi:546]: - 'TangoBarn' (01:02:03:04:05:06)▂▄▆█
[00:23:44][D][wifi:546]: - '' (06;08:09:0A:0B:0C)▂▄▆█
[00:23:44][D][wifi:546]: - 'TangoBarn' (01:02:03:04:05:06)▂▄▆█
[00:23:44][D][wifi:546]: - '' (06;08:09:0A:0B:0C)▂▄▆█
[00:23:44][W][wifi:551]: No matching network found!
[00:23:44][D][wifi:482]: Starting scan...
[00:23:44][D][wifi:497]: Found networks:
[00:23:44][D][wifi:546]: - 'TangoBarn' (01:02:03:04:05:06)▂▄▆█
[00:23:44][D][wifi:546]: - '' (06;08:09:0A:0B:0C)▂▄▆█
[00:23:44][D][wifi:546]: - 'TangoBarn' (01:02:03:04:05:06)▂▄▆█
[00:23:44][D][wifi:546]: - '' (06;08:09:0A:0B:0C)▂▄▆█
[00:23:44][W][wifi:551]: No matching network found!
[00:23:44][D][wifi:482]: Starting scan...
[00:23:47][D][wifi:497]: Found networks:
[00:23:47][D][wifi:546]: - '' (06;08:09:0A:0B:0C)▂▄▆█
[00:23:47][D][wifi:546]: - 'TangoBarn' (01:02:03:04:05:06)▂▄▆█
[00:23:47][D][wifi:546]: - 'TangoBarn' (01:02:03:04:05:06)▂▄▆█
[00:23:47][D][wifi:546]: - '' (06;08:09:0A:0B:0C)▂▄▆█
[00:23:47][W][wifi:551]: No matching network found!
[00:23:52][D][wifi:482]: Starting scan...
[00:23:56][D][wifi:497]: Found networks:
[00:23:56][D][wifi:546]: - '' (06;08:09:0A:0B:0C)▂▄▆█
[00:23:56][D][wifi:546]: - 'TangoBarn' (01:02:03:04:05:06)▂▄▆█
[00:23:56][D][wifi:546]: - 'TangoBarn' (01:02:03:04:05:06)▂▄▆█
[00:23:56][D][wifi:546]: - '' (06;08:09:0A:0B:0C)▂▄▆█
[00:23:56][W][wifi:551]: No matching network found!
[00:24:01][D][wifi:482]: Starting scan...
[00:24:04][D][wifi:497]: Found networks:
[00:24:04][D][wifi:546]: - 'TangoBarn' (01:02:03:04:05:06)▂▄▆█
[00:24:04][D][wifi:546]: - '' (06;08:09:0A:0B:0C)▂▄▆█
[00:24:04][D][wifi:546]: - '' (06;08:09:0A:0B:0C)▂▄▆█
[00:24:04][D][wifi:546]: - 'TangoBarn' (01:02:03:04:05:06)▂▄▆█
[00:24:04][W][wifi:551]: No matching network found!
[00:24:04][D][wifi:697]: Retrying with hidden networks...
[00:24:09][I][wifi:313]: WiFi Connecting to 'TangoHouse'...
[00:24:13][W][wifi:663]: WiFi network can not be found anymore.

Notes on the log:

  • When I copied it and pasted it into a text editor, it used [redacted] for the SSIDs and [redacted] for the hex numbers after it (that, to me, look like a MAC address) I replaced the [redacted] for the SSID with TangoBarn and put in 2 different hex strings, making sure the 01:02… was used to always replace the same string and the 07:08… always replaced the other string. (Only 2 hex strings showed in the logs).
  • It says it found TangoBarn, but seems to find it twice on each scan, but it also finds a wifi network with no name (using two single quotes to enclose a string of 0 length).
  • Odd that I have TangoHouse in my config first, and it doesn’t try that until the end, can’t find it, and doesn’t keep trying to connect to it.

My guess on what I see on the log is that it sees TangoBarn, so tries to log in, but can’t. (Why doesn’t it say it’s trying to log in, though?) I don’t know what the hex strings are or what the no-name SSID could be. I know various devices sometimes have their own wifi networks. My Switch, for instance, uses its own wifi network with a QR code to send screenshots to my phone.

I’m hoping this log and that it seems to at least see the wifi in the barn help with a clue as to what I’m doing wrong.

I have some reading issues/disabilities. Generally they don’t get in the way, but it makes it VERY easy for me to think I have something letter perfect, but have missed something. (Like the indentation issue pointed out earlier.) So I’m betting it’s something absurdly simple I’m missing.

Well, I hate to say it, but it came down to a typo. That reading issue I mentioned? Yeah, transposed two letters. I checked it many times, but I don’t always see something like that. I finally went into another app and copied and pasted the wifi SSID and password from there into the editor, on the next line, exactly below what I had and had to do a character by character comparison before I could actually perceive it.

So it’s working now.

So easy to do. We’ve all been there.

1 Like