Esphome Web Server in Access Point Mode without home

Hi @OttoWinter
I built my weather station a year ago and now I want to replace the anemometer, but I would like to do a calibration that is a bit precise compared to the previous one.
I programmed an ESP32 by inserting web server and in Access point and sensor mode to perform tests away from home.
At home everything works, but outside, not finding the wifi, the esp32 creates its ap network, I connect to 192.168.4.1, I enter the web server but I do not see the sensor.
Is it possible to read the data on the web server outside the home? if so how?
Thanks in advance

2 Likes

Confused by your question as by default if you activated the web server in ESPHome, when you access it it displays status of all sensors, switches,… defined in ESPHome sketch and you have also logs displayed under :wink:
Can you share your sketch ?

1 Like

here is the sketch

esphome:
  name: anemometro-mobile
  platform: ESP32
  board: esp32dev

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "4d73955a081fc357774f5d4278"

wifi:

  ssid: "Home"
  password: "12345678"
  ap:
    ssid: "Anemometro-Mobile"
    password: "12345678"

captive_portal:

web_server:
  port: 80

    
sensor:

#------------------ FOLLATE VENTO ----------------------------------------- OK
  - platform: pulse_counter
    pin:
      number: GPIO13
      mode: INPUT_PULLUP
    name: "VelocitĂ  Vento Follate mobile"
    unit_of_measurement: 'km/h'
    icon: 'mdi:weather-windy'
    count_mode:
      rising_edge: DISABLE
      falling_edge: INCREMENT
    internal_filter: 13us
    update_interval: 8s
    accuracy_decimals: 1
    filters:
      - multiply: 0.04
      - debounce: 15ms


if I am at home connected to the wifi “Home” set by default
I connect to the web server and see the sensors.
if I am far from home I connect to the ESP32 in ap mode, but I don’t see any sensor.
The web server offers me the wifi that can be reached within its range but I don’t see the sensor

1 Like

It’s normal ! The AP mode in ESPHome is only to setup the ESP and get it connect at a Wifi without changing immediately the sketch :wink: If you want to do such thinks you’ll need to use alternative fw such as Tasmosta or ESPeasy :slight_smile:

1 Like

Hi @Michele184

I just jumped onto the ESPHome world yesterday, and I wanted to put together a simple setup with one relay, just to have something that “works”.
I also wanted it to work without Home Assistant, as a first “test”, as I don’t want to touch my Home Assistant installation until I have all set up correctly and working.

What I learnt yesterday, is that if you only want a device that works without HA, you NEED two things:

  • Disable the Captive portal, or the only thing that you’ll see is a list of the networks, and an option to load an OTA update
  • Set the webserver as local: true, or it won’t work as it will point you to JS and CSS files hosted online.

Then, after you connected to the ESPHome wifi ap, you can open up your browser manually and navigate to 192.168.4.1 and see all your sensors and logs!

Here you are the YAML that I’m using:

wifi:
  ap:
    ssid: "Espino1"
    ap_timeout: 1s

#captive_portal:

web_server:
  local: true

(I also set the timeout for the ap to 1 second, so I don’t have to wait the default 60s to connect to the ESP board)

Hope this helps!

7 Likes

I followed your advice and now I have a D1 mini broadcasting data from a BMP280. I can see it in a web browser at 192.168.4.1 - now what can I do with it? What are you doing with your relay (I assume turning it on and/or off) but what did you use to interface with it (computer, cell phone, etc) and what program or app do you use? Ideally I want to show a graph on my Android phone or a tablet while I am out in the wild. This forum is the closest I have come to anything practical. I may have come across some Arduino stuff but that’s totally foreign to me. I like ESPHome because I (sort of) understand it. Thanks for any advice or recommendations

This certainly gave me some hope. Has something changed in an update? I still only get the captive portal with the option to select a network or upload a file.

My config is as below:

esphome:
  name: esp32-wifi-webserver-test
  friendly_name: esp32-wifi-webserver-test

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

ota:
  password: !secret OTA_password

web_server:
  local: true

wifi:

# Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-Wifi-Webserver-Test"
    password: !secret OTA_password
    ap_timeout: 1s

# captive_portal:

switch:
  - platform: template
    name: "Test switch"  
    optimistic: true

Any ideas?

Hi @DaveW1,
And sorry for the (extremely) late reply.
What I personally did with the relay was simply verifying that it just worked.
The next day, I turned it on and off a couple of times and experimented with some other options of the ESPHome configuration.
The next week, I attached the relay in parallel to my house thermostat and verified that I could turn on my home heating device.
Then, I attached a BME680 to it, and displayed the values on the local AP, monitoring them with my smartphone’s browser against some other sensors. I even attached a USB battery to it and brought it around (at work, to other houses, …).
It took me some months of trial and error to find out the correct placement for the BME680 in the house to get good readings, and to find out the correct temperature offset. Advice: the BME680 MUST be placed the most far away that you can from the ESP (using long and thin wires), or it will be heated by it, and you can’t do nearly anything to correct it in outdoor conditions.

The final usage has always been the connection of the ESP to Home Assistant, which I host on a Raspberry 3B+ using Home Assistant OS, and this is the point where I am now.
I have 2 ESPs, each one with its BME680, and I have built my personal weather station with them (one internal, the other external). Home Assistant collects the data from the BME680s, and let me see statistics and graphs of the temperatures and other values. I look at graphs and data both using a browser on my PC, and both using the Home Assistant App on my Android smartphone.
The internal ESP also works as a thermostat, which I can turn on even remotely connecting through a VPN to my house (this could be done without Home Assistant and with the help of a home router which has integrated VPN support (I use an ASUS one)).

The captive portal to upload an update file is always visible for me too.
The only thing to be aware is that the

web_server:
  local: true

has been broken in ESPHome 2022.10. So, use 2022.9 or 2022.11 and later.

Then, your configuration seems nearly OK wrt mine.
I don’t know about the template switch that you added, I may suggest you first experiment with a relay-like switch, and if that works, go ahead with some more changes.

Here is my start-up configuration:

##### HW CONFIGURATION #####
esphome:
  name: espino1-in

esp32:
  board: az-delivery-devkit-v4
  framework:
    type: arduino

##### Enable logging #####
logger:
#  level: VERBOSE

##### Enable Home Assistant API #####
api:
  # ESPHome will reboot if Home Assistant or any other client won't access it within the indicated
  # timeout in reboot_timeout, as a "watchdog" condition.
  # If you need to use ESPHome standalone, set reboot_timeout to something greater than the default
  # 15min
  reboot_timeout: 24h

ota:
  password: ""

##### Wi-Fi SETUP #####
wifi:
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "espino1-in"
#    password: ""
    # Reduce fallback hotspot timeout if you want to use ESPHome standalone, so it becomes available
    # sooner
#    ap_timeout: 1s

#captive_portal:

##### LOCAL WEB SERVER #####
web_server:
# WARNING: in order to have web_server working, it is MANDATORY that the option
# captive_portal is NOT enabled, or it will have priority and web_server will be ignored!

  # local: true working in ESPHome 2022.4 and 2022.9.4
  # WARNING: NOT working anymore in ESPHome 2022.10.0 and 2022.10.1
  # Working again in ESPHome 2022.11.0
  local: true


##### PERIPHERALS #####

### Relay for heater enable
switch:
  - platform: gpio
    name: "ComandoCaldaia"
    id: "rele_comando_caldaia"
    pin: GPIO13


1 Like

Thanks for the reply - I usually don’t check for them but I was searching for an answer to another question today. I have a lot of new projects I’m tinkering with and the D1 mini I set up for this one is gone. When I find the time (and initiative) I will try the “web_server” option - currently had captive_portal. As I stated, I can access the data a single time at the IP 192.168.4.1, but it isn’t very usable. Hopefully the web_server local will update the readings. Possibly need some type of app (Android) to display as a graph or gauge - is that what you are doing? I know I can see results through Home Assistant, but want to be able to where there is no Wifi or internet.

No, as I said

The final usage has always been the connection of the ESP to Home Assistant

I never thought of using any app at all.

Actually, I wanted to do all of this through Home Assistant (there was a BME680 integration once upon a time), but they deprecated the needed functionality some months before I bought the Raspberry Pi, so I needed to use ESPHome, as the Home Assistant team told us to do.

1 Like

I still haven’t found the time to play with this again - other projects almost complete though (maybe). Am I understanding you that you can set Home Assistant to connect to 192.168.4.1 - the address being broadcast from BME680? I tried turning off wifi on my Android and setting up an additional server (manually) in Home Assistant app pointing to 192.168.4.1 (even though I don’t have the 680 broadcasting there yet) , but it wouldn’t; said “… please check that URL is a valid Home Assistant URL”. I tried adding 8123 as a port but no dice. So there are 3 possibilities - #1 it just won’t work; #2 that it won’t work unless I have wifi on, but I don’t know how to add a server while it is - HA just connects to the server (wifi) I have set up; #3 I need BME 680 (D1 mini) to be broadcasting on 192.168.4.1 - with or without wifi enabled on the phone. Possibly a #4 Need to adjust Yaml to incorporate the settings you mentioned and try again. This of course doesn’t affect anything until I try option 3. Maybe I am incorrect and you are connecting to the BME680 through wifi via home router (ie phone app connects to HA server at 192.168.1 (or 0). xxx:8123 which contains the ESPHome integration with BME680.
To sum this all up and make it easier to understand (hopefully): Can you disconnect from cellular data and the wifi provided from your router and still use Home Assistant to the BME680? In my case could I be away from home and in an area without cell service and connect to the BME680 (which will be physically present /close to my Android) and use the companion app to connect through the D1 mini ap - 192.168.4.1? If not (option #1) there is no sense in my continuing to try; rather starting up again.
Thanks for your patience and support.
I wish the OP had followed up if this worked for them

Update: I tried again, but couldn’t find the BME I used. Had a spare DHT11 and a used D1 mini so I used these. I can connect via web browser as long as my Android wifi is connected to the mini’s ap (192.168.4.1) - just like before. There is a message every time it updates and a current reading, but I don’t know how to use the updates as a graph - if at all possible. Still can’t use HA; wondering if our circumstances are different. Thanks again

You are doing it wrong.
When everyone says Home Assistant, including me, we are talking about a software entity that’s in execution on some server.

In my case, Home Assistant is installed and executing on a Raspberry Pi 3B+ that’s connected through Ethernet to my home router.
ESPHome is installed on my ESP32, which is connected via WiFi to my home router, so the ESPHome and Home Assistant (executing on the Raspberry) are in the same network.

What you are naming Home Assistant it’s actually the Home Assistant Companion App, that’s in execution on your smartphone. You cannot use the Home Assistant Companion App to connect to ESPHome, as that’s not meant to connect to it.

ESPHome (executing on your ESP device) is meant to be connected to Home Assistant (executing on some server, which is definitely not your smartphone).

I can connect with my smartphone to the WiFi network provided by ESPHome, and can access ESPHome using the internet browser on my smartphone, but definitely cannot use the Home Assistant Companion App to connect to any ESPHome.

You can connect to it, but not using the Home Assistant Companion App. That app is only meant to connect to Home Assistant, and not to ESPHome.

Great. You did it!

That’s all that you’ll get from ESPHome, nothing more.

Our circumstances are the same as when I brought my ESP32 roaming around, powered with a USB battery, in order to test the BME680.
No graphs, only that interface, exactly as yours, even with the No internet connection warning from my browser.

I never ever tried to use the Home Assistant Companion App to connect to ESPHome, that’s what you are trying to do, but that’s wrong, and you cannot succeed. Stop, that’s not possible.

ESPHome is meant to be a dumb, slave device, that hosts some sensors or has some hardware outputs, and then communicates and interacts with Home Assistant.

1 Like

Thanks again. You got me to try again at least. I’m sure there is some way to get Tasker or something like it to take the information being sent from the ESP device and turn it into a graph or hopefully a dial so I can mimick a barometer. I bought one for fishing but it was terrible. I know even less about Tasker - it seems there are PUT-GET commands plus JSON, HTTP, etc. I was born about 20 (30?) years before anybody who learned this in school. They had courses in Fortran when I was in High School and I didn’t take them either.

To stay in-topic, yes you could use the ESPHome Web Server API with an external application to plot your graph.
Going off-topic, yes it seems that Tasker can do the job. There is at least one example with Tasky that queries the openwheather API to plot some weather charts; you can adapt it to query your ESPHome device and to what you want.

Going even more off-topic, you could buy your ESP a hardware display and plot a chart on that (see the ESPHome Display component, there is a discussion here), so even no need of WiFi or a smartphone at all.

Going extremely off-topic, you can follow this tutorial where the guy plots a chart on a smartphone that’s connected to the ESP device with a browser (without even using ESPHome, it’s using the Arduino IDE).

You should really create your own question, you’ll surely get more halp that way.

Going back on-topic, you are done with the Web Server component, you activated it correctly and unlocked its power! :smiley:

1 Like

I think I saw the Arduino tutorial before - just can’t seem to follow that as easily as ESPHome. The display component looks promising if I ever want to figure out a new gadget. I’m seriously questioning why I need a portable barometer - the one I bought that didn’t seem to work/be accurate was unnecessary. Thought it would help catch fish LOL. Just thought I could make one better and I did … sort of. Now that I think of it, it just showed current pressure reading too - no graph: https://www.amazon.com/Camco-Adjustable-Color-Coded-Calibrates-69200/dp/B002L9DHX0/ref=asc_df_B002L9DHX0/?tag=hyprod-20&linkCode=df0&hvadid=309722128548&hvpos=&hvnetw=g&hvrand=10901871850804043954&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9030803&hvtargid=pla-434607793659&psc=1&mcid=6abbecf9babe3c37a1356ce55a3d7115&tag=&ref=&adgrpid=65401905081&hvpone=&hvptwo=&hvadid=309722128548&hvpos=&hvnetw=g&hvrand=10901871850804043954&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9030803&hvtargid=pla-434607793659&gclid=Cj0KCQiA3uGqBhDdARIsAFeJ5r3__eQ2pxIJ8n4Hu7xj4rjoNrgWu-idGLiB5UlwOpnBq9BRPMPMupUaAoaiEALw_wcB

Check out the work from @veli - looks like it does what you want (graph sensors in the web ui).

2 Likes

There’s also this: Prometheus Component — ESPHome