ESP32 P2P-Communication

Dear Community,

in my current project I would like to install a temperature sensor in my greenhouse, as it can often get very cold in there in the winter or very hot during the summer time.

Unfortunately, my greenhouse is in the corner of my garden and gets very unreliable wifi. Now my idea would be to implement kind of a bridged network like the following:

HA (over WIFI) <--> ESP32 (WIFI + Bluetooth) <--> ESP32 (Bluetooth)

Therefore, I read the article about the Bluetooth Proxy of ESPHome but there is nothing mentioned how to build a peer-to-peer-communication between ESP32-nodes where the “last node” acts as a gateway and publishes everything in the LAN/WIFI on behalf of the nodes connected via Bluetooth.

Do you have an idea how to realize such a p2p-communication scenario?

Best regards,

I don’t think this is possible right now, as the bluetooth proxy sends bluetooth info over wifi, so you’d need a home assistant api proxy. Putting a wifi repeater at the place of the middle esp32 would make way more sense.

Maybe this could help if you’re set on doing it with esp only:

But you’d have to implement the devices on the last esp and send the information yourself, the proxy won’t do it for you.

Or just do Wifi repeating with an ESP :wink:
Wifi typically has a better ranger than BT

Apparently, HA is initiating the api connection to ESPHome, so a NAT router would work, here

1 Like

Sure? Wouldn’t be a client on the repeater actually “protected” by the NAT? But it should be possible to add a port forwarding so than HA should be capable to address one device in that repeater network.

Suggesting to try beethowen (esp-now) before bluetooth as it should give a greater range :signal_strength:

The work from @iphong doesn’t work anymore with recent esphome releases :put_litter_in_its_place:

Pretty much. ESPHome actually reboots if api is enabled and HA hasn’t connected in a while.
Besides, you nowhere indicates your HA IP in ESPHome, do you :wink:

I know that HA connects via native api to the esphome node (which acts as a server). :desktop_computer:

The question was that despite of the extra NAT (which is a poor mans firewall essentially) HA is capable connecting to the esphome node in that different subnet. :twisted_rightwards_arrows:

I remeber it worked for some users but only for exact one (= :one:) esphome node in that subnet (for now that would be sufficient for the OP). mDNS will be broken too so no auto discovery for example :bulb:

NAT only makes sense between different subnet.
It’s a basic of TCP/IP really (all your internet connections are using NAT unless you are fully IPV6), so, unless there is a known bug, it must work.

For sure.

That being said, that was the 1st project that popped doing a search. There might be projects doing Wifi bridge with ESP as well.

Do you have the option to dig a shallow trench with some conduit and a cat6 I would definitely look in to that. Then you could plug in a poe-switch, access point or what ever :slight_smile:

I’ve done this to my garage, about 20 meters from my router.

OpenMQTTGateway with a cheap 433mhz temp and humidity sensor with batteries could stretch further than wifi with the benefit of you would have to learn some new things.

1 Like

Haha - to be honest, I also thought of this solution and putting a ESP-32 with PoE :smiley:


What distance do you have between the greenhouse and the closest power source with a reliable Wifi connection ?

It’s about 40 meters from the house and the access points are in the basement and the first floor

That’s still into line of sight for BLE or 433mhz range. I would try an esp32 outside of the first floor with Wifi access and put a BLE temperature sensor into the green house or a 433mhz one.
For BLE the ESP32 should scan continuously to maximize the packets reception chances and be placed the highest possible.
The experiment should not be too expensive before going into other tech like ESP NOW or LORA with much more overhead.