Webserver without WiFi access (just using own AP)

I know that it is possible to define an AP but that is only used for inserting the WiFi credentials, right?
It would be possible to have access to the Webserver using just the AP connection (no WiFi besides the ESP)?
Regards

You could ask: but what is the purpose of accessing the ESP webserver using AP?

Well, imagine a scenario where the ESP have no WiFi networks surrounding it and I want to toggle some output. One way could pass by having an AP that I could connect from my smartphone and on it open a browser to access the Webserver page where I could toggle the output.

I know that I could create on the smartphone a Hotspot with credentials known by the ESP and after its connection I could access from a browser the IP of the ESP on that network, but this seems more time consuming (first I would need to figure out the IP given to the ESP), besides forcing a data connection (4G?) of my smartphone (otherwise I think I cannot create the Hotspot).

How can you do this without WiFi?

I m completely baffled to understand what you want to do.

Can’t I have a relay connect to the ESP without WiFi?
Can’t I have WiFi access to the ESP using its own AP (even without an external WiFi network)?
What I need is that after accessing the AP, besides having the webpage to insert the surrounding SSID credentials (that I don’t have in this particular remote location), I could have access to the page that the ESP shows through its webserver and where I can toggle the relay!

What webserver? I have dozens of ESP devices around my home and none of them have a webserver. They will start as an Access Point if they can’t connect to a WiFi network, but that is not a webserver.

Perhaps you are thinking of Tasmota which does provide a server API for each device, but you still need a local network to connect to it, plus an MQTT broker on the same network.

Home Assistant doesn’t work without a local network that connects everything together. You do not need internet access after Home Assistant is installed, but you do need a local network.

This area is related with ESPHome, right?
I don’t need Home Assistant for this since my ESP will be alone in its remote location!

ESPHome have a Webserver (Web Server Component — ESPHome).
Here is an example of mine Webserver:

I’m completely baffled that you do not know that functionality!?!

What I need is to be able to access it even with just an AP access.
That could be perfectly possible since the page to insert the SSID credentials is itself a webserver!
But I understand that this possibility is not (yet) implemented in ESPHome.
I wanted just to check that!

What happens if you omit the WiFi details for the device to connect to and only include an AP config? Does ESPHOME compile?

E.g.:

wifi:
  ap:
    ssid: "Some AP"
    password: !secret ap_password

1 Like

Yes, it compiles and because of that when it boots immediately the AP is used and I am able to access it and in http://192.168.4.1 I get the usual page to insert the WiFi settings but no page to access my ESPHome components (like the one I showed in my last post).

For moments I thought that this could be the solution!
Thanks for the tip anyway!

I think I found the way to accomplish what I needed!
If I remove the captive_portal section of the yaml file (besides with the WiFi details), instead of the WiFi settings page now I got the page to access through the ESP AP its components!

Thanks to @parautenbach for putting me in the right path!

1 Like

It would be great if you can post your code to help other people in the future. Thank you!

The wifi bit is already posted above, and then you just remove the captive_portal: section as the OP said. There’s nothing more to it.

1 Like

Yes precisely!
Nevertheless here is a possible yaml file:

esphome:
  name: espweb

esp8266:
  board: d1_mini

logger:

api:

# The main requirements are:
# - wifi section with just the AP credentials
# - no captive_portal section
wifi:
  ap:
    ssid: "hotspot_ssid"
    password: "hotspot_password"

web_server:
  port: 80

binary_sensor:
  - platform: gpio
    pin:
      number: D6
      inverted: true
      mode:
        input: true
        pullup: true
    name: "Button"

light:
  - platform: binary
    name: "LED"
    output: led

output:
  - platform: gpio
    pin: D8
    inverted: false
    id: led
3 Likes

It is not working for me on esphome v2022.9.4, additionality isn’t api part creating 15 minutes reboot cycle by default?

Only way I can see web server is to prepare config for defined hot spot and use my android phone to create WiFI with SSID and password defined in yaml while I’m near + set reboot_timeout

esphome:
  name: espweb

esp8266:
  board: d1_mini

logger:

wifi:
  ssid: "hotspot_ssid"
  password: "hotspot_password"
  reboot_timeout: 0s

web_server:
  local: True

binary_sensor:
  - platform: gpio
    pin:
      number: D6
      inverted: true
      mode:
        input: true
        pullup: true
    name: "Button"

light:
  - platform: binary
    name: "LED"
    output: led

output:
  - platform: gpio
    pin: D8
    inverted: false
    id: led

Did you find a solution to this?

It’s just what I need to do also. Additionally, I need to find a way to use a binary sensor to disable the webserver as it’s too memory-hungry.

I’m sure it’s possible with skills that are above my paygrade!

I ended up with what I’ve had posted above… Only thing api/wifi connection issues are by default trigger for restart, so it can turn out it will work but it will hang from time to time and esphome won’t restart device…