Changing AP ip address

I’m trying to change the ip address of the access point from the default 192.168.4.1.

I have this:

wifi: # comment out two lines below for wifi free operation
  # ssid: !secret wifi_ssid
  # password: !secret wifi_password
  reboot_timeout: 0s
  ap:
    ssid: ${ap_ssid}
    password: !secret OTA_password
    manual_ip:
      static_ip: 192.168.0.123
      gateway: 192.168.0.1
      subnet: 255.255.255.0

It compiles fine, but when I try to access 192.168.0.123 having connected to the AP, regardless of browser, I get a “You are not connected to the Internet” message.

I appreciate that this will mainly be down to my lack of understanding of all things network, and I would appreciate any help to point me in the right direction.

I am genuinely going to make a response to try and help,
but why are you doing this?

Your computer/browser test if you have internet access by trying to connect to some server on the internet and that will of course fail here.
This does not mean you do not have WiFi access to the ESPHome device’s AP.

You are getting confused between two different uses of the ESPhome WLAN component and radio:

  • WLAN client - connects an ESPhome device to your WLAN network in the same manner as a phone or tablet.
    The ESPhome device will usually get an IPv4 address from your network’s DHCP server (although static addressing is supported).

  • WLAN AP (Access Point) - if the ESPhome device can’t connect to a WLAN AP (sometimes called a “hotspot” or “server”), it can configure itself as an AP so you can temporarily connect a phone to it and change the configuration through a captive portal
    The ESPhome AP includes a WLAN AP, DHCP server, and Web server to allow a phone to connect, and change config via HTTP.
    The IPv4 range used by the ESPhome DHCP server is irrelevant - this is only used to change the configuration and connect the device to the “proper WLAN AP”.

Setting the temporary captive portal DHCP server to the same IPv4 range as your “proper” LAN may be confusing for client devices, but should work as they are two different physical networks.


ESPhome wifi: => “Proper LAN AP”


ESPhome ap: <= “Captive portal”


wifi:
  # Connect to an existing wifi access point
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${name} Fallback Hotspot"
    password: !secret fallback_ap_password

# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:

If this helps, :heart: this post!

It’s normal, when you set your Esp in AP mode, there is no internet.
Explain what you try to accomplish, Esphome doesn’t allow simultaneous Station (connected to internet) and AP modes.
And if you try to setup web server, don’t enable captive_portal mentioned above.

Thanks for the replies.

I don’t use captive portal.

I’m using this as a standalone device without any connection to any wifi.

I just connect to the AP using 192.168.4.1 (the ESPHome default) and I then access the webserver to make changes as required or upload new firmware via OTA.

This all works great.

I am trying to simply change the IP address from 192.168.4.1 (the ESPHome default) to something of my choosing.

Is this possible?

That’s what I would have thought, but I can’t access the device. I just see the “You are not connected to the internet” message when entering the defined IP address.

From my reading of the docs, this should be possible, though I may be misunderstanding it.

ap** (Optional): Enable an access point mode on the node.*

ssid** (*Optional*, string): The name of the access point to create. Leave empty to use the device name.*
password** (*Optional*, string): The password for the access point. Leave empty for no password.*
channel** (*Optional*, int): The channel the AP should operate on from 1 to 14. Defaults to 1.*
manual_ip** (*Optional*): Manually set the IP options for the AP. Same options as manual_ip for station mode.

That is your browser, which blocks the connection.
Try another browser, f you do not know how to bypass that page.

You should get the same warning for internet even with default 192.168.4.1
Maybe your mobile device tries to connect to previous ip-address saved in memory for that ssid?

I don’t get the warning with 192.168.4.1 and I’ve tried both Chromium and Safari with the same result.

Is there a way around this?

Does the configuration that I tried look OK?

not really…
try:

ap:
  ssid: ${ap_ssid}
  password: !secret OTA_password
  manual_ip: 192.168.0.123
     

or

ap:
  ssid: ${ap_ssid}
  password: !secret OTA_password
  manual_ip:
    static_ip: 192.168.0.123

That’s weird… Maybe you got the first time you connected…

Edit:
Did you upload the yaml through USB?

I’m not a real network expert but you define:

manual_ip:
      static_ip: 192.168.0.123
      gateway: 192.168.0.1
      subnet: 255.255.255.0

As to my understanding, an AP is its own gateway. So you should choose perhaps 192.169.0.1 for the static ip. (As to my understanding a gateway is a router or something similar, i.e. a second device which you don’t have).

Regards,

mabe

That’s how I see it also.
I don’t think I have ever been defining gateway for Esp in AP mode (not tried in Esphome).
The issue of OP might be something else though.

Thanks for all the suggestions.

@mabe I gave this a try. Same result. “No internet” message

@Karosm Yes, I uploaded via USB. Both gateway and subnet are mandatory for compilation.

As soon as I revert back to an ‘unconfigured’ AP and use the default 192.168.4.1 all is fine.

The docs suggest that this is doable but I’m clearly missing something. I get the same "No internet’ message with three different browsers and two different devices.

There’s something about the way the AP is working when manually configured that is stopping this from working.

From the docs:

The ap_timeout option suggests that I could start the access point from a binary_sensor, which would be a viable alternative, but there’s no more info on how to do this.

  ap:
    ssid: ${ap_ssid}
    password: !secret OTA_password
    ap_timeout: 0s

It suggests that setting the ap_timeout to 0s disables the AP until it is manually started.

Any ideas?

I was curious and set up a Wemos D1 mini (ESP8266) for testing with LED and button to toggle the LED.

I used an old phone to test the AP: Everything is as expected. I get the same webpage as with the default AP network and toggling the LED with the button works as well:

esphome:
  name: eh-test

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: ""

ota:
  - platform: esphome
    password: ""

wifi:
#  ssid:
#  password:
  reboot_timeout: 0s

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Eh-Test Fallback Hotspot"
    password: "password"
    manual_ip:
      static_ip: 192.168.42.1
      subnet: 255.255.255.0
      gateway: 192.168.42.1

captive_portal:

output:
  - platform: gpio
    pin: GPIO14 #D5
    id: LED

light:
  - platform: binary
    id: redLED
    name: "red LED"
    output: LED

  - platform: status_led
    name: "Status"
    pin:
      number: GPIO2
      inverted: true
    restore_mode: ALWAYS_ON

binary_sensor: 
  - platform: gpio
    id: button
    pin:
      number: GPIO4 #D2
      inverted: true
      mode: 
        input: true
        pullup: true
    filters:
      - delayed_on: 50ms
    on_click:
      max_length: 1000ms
      then:
        - light.toggle: redLED
        - logger.log: "Button pressed!"

sensor:
  - platform: wifi_signal
    name: "WiFi Signal Sensor"
    update_interval: 10s



I don’t understand where your problem is, but I wouldn’t use that message as an indicator for it. I get that message when I first time connect to any AP that doesn’t offer internet connection.Even if I connect successfully.

I now have this working.

Sadly, not through the ESPHome config though. Maybe there’s a bug.

I had to resort to lambda.

      - lambda: |-
          static IPAddress local_ip(192,168,4,58);
          static IPAddress gateway(192,168,4,58);
          static IPAddress subnet(255,255,255,0);
          const char* ssid           = "xxxxx"; 
          const char* password       = "xxxxx"; 
          const int   channel        = 10;                        
          const bool  hide_SSID      = true;                     
          const int   max_connection = 2;
          WiFi.mode(WIFI_AP);
          WiFi.softAPConfig(local_ip, gateway, subnet);
          WiFi.softAP(ssid, password, channel, hide_SSID, max_connection);

However, it’s now working as expected.

This tutorial was a great help.

My testprogram works also with:

manual_ip:
      static_ip: 192.168.42.123
      subnet: 255.255.255.0
      gateway: 192.168.42.123

I use esphome version 2024.9.1 on the command line of a debian bookworm system (manual install using pip3 in a virtual environment).