How to connect external ESP32 to my HA instance?

Hi,

how can I send sensor data from an external ESP32 (configured with ESPHome) to my Home Assistant instance?
The Problem is that the ESP is not in the same network with my Home Assistance Raspberry Pi.

I don’t know if there is a way so send the sensor data from the ESP with webhooks to my HA? I’m using the home assistant cloud.

Or is it possible to send data from the ESP to my home assistant mqtt broker over the cloud? If yes, where can I find infromation about it?

Or is there another way to send the data?

Thanks for your help

Well if you use the ESPHome API connection is initiated from HA, so basically if you are able to get your ESP visible from your HA instance in term of IP routing and the port 6053 you should be good :wink: so long it doesn’t mean exposing your ESPs on Internet as ESP is not really designed for that (security problems then to take into account) !

That sounds like a very complicate solution.

And is it also not possible to send the data from the ESP to a public MQTT broker and from there the home assistant grab the data?

MQTT would work.

Can you give me some more information, please?

You need to have an mqtt server that both HA and the esp can access.

Have a look at these sites. That should help you.

1 Like

Sorry that I have to ask again.
So I need a public mqtt Server like flespi.io? So the ESP sent the data to flespi sever and home assistant can read the data from flespi server?

#api:

mqtt:
  broker: mqtt.flespi.io
  username: myToken

Hello,

I’m trying to connect external ESP32 to HA as well. Does anybody find a nice solution for this?
I have a VPS with mosquito and i was able to send the data from esp32 to VPS. But what I’m still not sure, how to make HA to communicate with this external broker. Also i found that you can’t have two mqtt brokers. I’m not using local mqtt broker but how is it with ESPhome? Isn’t it also kind of mqtt? Or it is a different communication so mqtt broker in cloud will not gonna interfere or block it. Thx

Esphome only uses mqtt if you tell it to.

for use mqtt in esphome you have to remove the ap: and insert the code instead:

mqtt:
  broker: ip_your_broker
  port: 1883
  client_id: client_id
  username: mqtt_login
  password: mqtt_pass
  keepalive: 15s
  birth_message:
    topic: esphome/client_id
    payload: online
  will_message:
    topic: esphome/client_id
    payload: offline  
  id: mqtt_client_client_id


you also need to have a statistical IP, and forward port 1883 on your router to the home assistant server. all entities will automatically appear in home assistant. also, you will not be able to update the firmware from esphom, but only through the device’s web interface.