My ESP-NOW integration library - enable direct communication between your esphome devices even without wifi router

I recently wrote a custom addon that enable esp-now integration for your esp-home devices. This add direct communication capability and you can use it along side with existing homeassistant.

So in case your wifi router disconnects, or your raspberry pi stops working, your home automations will still be able to work.

Check it out at https://github.com/iphong/esphome-espnow and let me know what you think.

In progress homeassistant config for my actual home project

Cheers!!

3 Likes

that’s great,
it was a missing part of the ESPHome project that would be very handy for a lot of people!
why don’t you submit a PR for the next ESPHome release?

Hi. Good work. I am working on same idea. I have a lot of espnow devices. And i won’t to create espHome gateway. That will bind with this esphome devices and send proper information to home-assistant. Any ideas how to do it?
In my case I need two esp modules. One for esphome api to send data to HomeAssistant. Another to receive data from espnow devices

1 Like

I have a similar idea and plan to use the esp-now protocol for battery powered esphome nodes.

According to some stats I read esp-now only needs around 20% of CPU time compared to connecting to a WiFi access point with WPA2.

So in theory a charge of battery will last 5 times longer with this protocol. At least one esphome node (not battery powered) would be needed to work as the access point for the esp-now devices and forwads their messages via the classic WiFi to home assistant.

Only thing here is that this wouldn’t work with the native api of esphome because technically home assistant connects to the esphome nodes…

Simply awesome :tada: I will try it out soon!

What do thinking about integrating this directly into esphome?

we just need to add entities with esphome and pass entity id

Here I am again.

I build a setup up with a existing esphome node (still connected “normally” via wifi and api) and added a new esphome node without wifi but only esp-now. I put logging on both sides to VERBOSE but can’t see anything happen regarding esp-now.

The device d1button features a button and only uses esp-now for connections:

esphome:
  platform: ESP8266
  board: d1_mini
  name: $devicename
  arduino_version: LATEST
  includes:
  - esp_now_connect.h

logger:
  level: VERBOSE

custom_component:
- lambda: |-
    ESPNow.begin(2);
    return {};

binary_sensor:
  - platform: gpio
    pin:
      number: D3
      mode: INPUT_PULLUP
      inverted: True
    name: "${upper_devicename} Button"
    filters:
      - delayed_off: 3s
    on_press:
      - lambda: ESPNow.send("my_remote on");
    on_release:
      - lambda: ESPNow.send("my_remote off");

the button presses are perfectly recognized in the logs but I don’t see anything regarding esp-now.

The other device features a led which turns on manually but doesn’t get triggered from d1button

esphome:
  platform: ESP8266
  board: d1_mini
  name: $devicename
  arduino_version: LATEST
  includes:
  - esp_now_connect.h

custom_component:
- lambda: |-
    ESPNow.begin(2);
    ESPNow.on("my_remote on", []() {
      id(my_light)->turn_on().perform();
    });
    ESPNow.on("my_remote off", []() {
      id(my_light)->turn_off().perform();
    });
    return {};

output:
- platform: gpio
  pin: D7
  id: my_output

light:
- platform: binary
  output: my_output
  id: my_light
  name: "${upper_devicename} LED"

Any ideas what’s wrong? I sticked a close as possible to the github examples :thinking:

What has got my attention was that i coud get it to work along side with Home Assistant. A Single device can be both connected to Home Assistant while listenning to espnow messages at the same time. So if HA somehow turned off, things will continue to work, you just wont be able to control your devices using HA frontend.

And the boot up time is extremely fast. It can wakeup, send a few messages, and go back to sleep in just a blink of an eye. I’ve made a few sensors with espnow, let see how it performs… only time will tell.

Make sure you use the latest version of arduino. It uses some of the new features of espnow in the espresif arduino library.

arduino_version: LATEST

I’ve managed to get EspNow working along side with Home Assistant on a single device. Now i get the best of both worlds.

1 Like

Make sure you use the latest version of arduino. It uses some of the new features of espnow in the espresif arduino library.

arduino_version: LATEST

I have this line inside.

I also tried now with removing all (classical) wifi configuration (don’t know if that is related in any way). Still I see nothing happen?

Is it normal there is no logging? What else could I try? :thinking:

By the way there are a small update to the library. It can now send data as argument. For example:

EspRC.on("bedroom light", [](String state) {
  if (state.equals("on")) {
    // do something
  } else {
    // do some thing else
  }
});
EspRC.on("bedroom temp", [](Int value) {
  // Do something with int value
});
EspRC.send("bedroom light", "on");
EspRC.send("bedroom temp", 28);
2 Likes

What version of esphome are you using for your custom addon @iphong?

I tried with stable (1.14.5 at the moment) and never where able to get esp-now working with it…
A beta (1.15.0b3) is also available as well as the dev branch :thinking:

same problem. Home Assistant part working perfect, espnow part doesn’t work at all. When using esp_rc.h logger doesn’t working.
Try to catch espnow messages with simple espnow code from arduino and see that first device send espnow messages. But another devices doesn’t respond for that. Also in logs doesn’t see espnow initialization.

I used the exact examples like on github and can’t get anything working. Tried with 1.14 and 1.15 beta versions

Hey guys, sorry for the late reply!!! I’ve just push a few updates so it should be working properly now.

Since esp-now still rely on wifi signal to function, so your wifi mode must be something other than OFF. It can be either STATION or AP mode or both.

Let me know if you guys need help. I will put a tutorial video up soon and explain more on how to get everything working.

1 Like

I’ve just did a quick simple test and it works perfectly

logger:
  baud_rate: 115200
esphome:
  name: test
  board: d1_mini_pro
  platform: esp8266
  arduino_version: LATEST
  includes:
  - EspRC.h

custom_component:
  lambda: |-
    EspRC.begin(1);
    EspRC.on("$M", [](String msg) {
    	ESP_LOGD("esprc", "received: %s", msg.c_str());
    });
    return {};
      

The esphome version doesn’t matter. What matters is the arduino version, it should be super recent, just use LATEST for now.