Code Monkey home page Code Monkey logo

esp-now-gateway's Introduction

ESP-NOW gateway for ESP8266/ESP32

Gateway for data exchange between ESP-NOW devices and MQTT broker via WiFi/LAN.

Features

  1. Creates an access point named "ESP-NOW gateway XXXXXXXXXXXX" with password "12345678" (IP 192.168.4.1).
  2. Possibility a device search through the Windows Network Environment via SSDP (at ESP_NOW_WIFI mode).
  3. Periodically transmission of system information to the MQTT broker (every 60 seconds), availability status to the ESP-NOW network and to the MQTT broker (every 10 seconds) and current date and time to the ESP-NOW network (every 10 seconds).
  4. Automatically adds gateway configuration to Home Assistan via MQTT discovery as a binary_sensor.
  5. Automatically adds supported ESP-NOW devices configurations to Home Assistan via MQTT discovery.
  6. Automatically adds supported nRF24 devices configurations to Home Assistan via MQTT discovery.
  7. Possibility firmware update over OTA (at ESP_NOW_LAN mode via access point only).
  8. Web interface for settings (at ESP_NOW_LAN mode via access point only).
  9. 3 operating modes:
ESP_NOW       ESP-NOW node only. Default mode after flashing.
ESP_NOW_WIFI  Gateway between ESP-NOW devices and MQTT broker via WiFi.
ESP_NOW_LAN   Gateway between ESP-NOW devices and MQTT broker via Ethernet. Preferred mode.

Notes

  1. ESP-NOW mesh network based on the library ZHNetwork.
  2. Regardless of the status of connections to WiFi or MQTT the device perform ESP-NOW node function.
  3. For restart the device (without using the Web interface and only if MQTT connection established) send an "restart" command to the device's root topic (example - "homeassistant/espnow_gateway/70039F44BEF7").
  4. W5500 connection:
ESP8266 (GPIO05 - CS, GPIO14 - SCK, GPIO12 - MISO, GPIO13 - MOSI).
ESP32   (GPIO05 - CS, GPIO18 - SCK, GPIO19 - MISO, GPIO23 - MOSI).

Attention

  1. ESP-NOW network name must be set same of all another ESP-NOW devices in network.
  2. If encryption is used, the key must be set same of all another ESP-NOW devices in network.
  3. Upload the "data" folder (with web interface) into the filesystem before flashing.
  4. At ESP_NOW_WIFI mode WiFi router must be set on channel 1.

Tested on

  1. NodeMCU 1.0 (ESP-12E Module). ESP_NOW_WIFI mode. Unstable work.
  2. AZ-Delivery ESP-32 Dev Kit C V4. ESP_NOW_WIFI mode. Stable work.
  3. NodeMCU 1.0 (ESP-12E Module) + W5500. ESP_NOW_LAN mode. Stable work.
  4. AZ-Delivery ESP-32 Dev Kit C V4 + W5500. ESP_NOW_LAN mode. Stable work.

Supported devices

  1. RF Gateway
  2. ESP-NOW Switch
  3. ESP-NOW Light/Led Strip
  4. ESP-NOW Window/Door Sensor
  5. ESP-NOW Water Leakage Sensor

To Do

  • Automatically add ESP-NOW devices configurations to Home Assistan via MQTT discovery.
  • LAN connection support.
  • nRF24 device support (via RF Gateway).
  • BLE device support (via BLE Gateway).
  • LoRa device support (via LoRa Gateway).

Any feedback via e-mail would be appreciated. Or... Buy me a coffee.

esp-now-gateway's People

Contributors

azholtikov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

esp-now-gateway's Issues

Adding encryption?

Hello,
This is not an issue but feature request.

I have been following your "ZHNetwork" since last month. its been great to see and follow along with the development. I have one basic question regarding esp-now communication protocol, do you intend to add encryption to the communication in future?

Best regards,
Chandan

'ARDUINO_EVENT_WIFI_STA_DISCONNECTED' was not declared in this scope

Hello I am getting the following error while building

Processing esp32 (platform: espressif32; board: az-delivery-devkit-v4; framework: arduino) -------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via -v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/az-delivery-devkit-v4.html
PLATFORM: Espressif 32 (2.0.0) > AZ-Delivery ESP-32 Dev Kit C V4
HARDWARE: ESP32 240MHz, 520KB RAM, 16MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:

  • framework-arduinoespressif32 @ 3.10004.201016 (1.0.4)
  • tool-esptoolpy @ 1.20600.0 (2.6.0)
  • toolchain-xtensa32 @ 2.50200.80 (5.2.0)
    LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 36 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- ZHNetwork @ 1.3.0+sha.506acf1
    | |-- WiFi @ 1.0
    |-- ZHConfig @ 0.0.0+20221229164550.sha.13c981e
    |-- ArduinoJson @ 6.20.0
    |-- ESP Async WebServer @ 1.2.3
    | |-- AsyncTCP @ 1.1.1
    | |-- FS @ 1.0
    | |-- WiFi @ 1.0
    |-- AsyncMqttClient @ 0.9.0
    | |-- AsyncTCP @ 1.1.1
    |-- ESP32SSDP @ 1.2.1
    | |-- ESP32 Async UDP @ 1.0.0
    | |-- WiFi @ 1.0
    |-- ArduinoOTA @ 1.0
    | |-- Update @ 1.0
    | |-- WiFi @ 1.0
    | |-- ESPmDNS @ 1.0
    | | |-- WiFi @ 1.0
    |-- SPIFFS @ 1.0
    | |-- FS @ 1.0
    |-- Ticker @ 1.1
    Building in release mode
    Compiling .pio\build\esp32\src\main.cpp.o
    Generating partitions .pio\build\esp32\partitions.bin
    Compiling .pio\build\esp32\lib361\WiFi\ETH.cpp.o
    Compiling .pio\build\esp32\lib361\WiFi\WiFi.cpp.o
    Compiling .pio\build\esp32\lib361\WiFi\WiFiAP.cpp.o
    Compiling .pio\build\esp32\lib361\WiFi\WiFiClient.cpp.o
    Compiling .pio\build\esp32\lib361\WiFi\WiFiGeneric.cpp.o
    Compiling .pio\build\esp32\lib361\WiFi\WiFiMulti.cpp.o
    Compiling .pio\build\esp32\lib361\WiFi\WiFiSTA.cpp.o
    Compiling .pio\build\esp32\lib361\WiFi\WiFiScan.cpp.o
    Compiling .pio\build\esp32\lib361\WiFi\WiFiServer.cpp.o
    Compiling .pio\build\esp32\lib361\WiFi\WiFiUdp.cpp.o
    Compiling .pio\build\esp32\lib869\ZHNetwork\ZHNetwork.cpp.o
    Compiling .pio\build\esp32\lib70c\AsyncTCP\AsyncTCP.cpp.o
    Compiling .pio\build\esp32\lib9e7\FS\FS.cpp.o
    Compiling .pio\build\esp32\lib9e7\FS\vfs_api.cpp.o
    src\main.cpp: In function 'void onWifiEvent(system_event_id_t)':
    src\main.cpp:133:10: error: 'ARDUINO_EVENT_WIFI_STA_DISCONNECTED' was not declared in this scope
    case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
    ^
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_WIFI_READY' not handled in switch [-Wswitch]
    switch (event)
    ^
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_SCAN_DONE' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_STA_START' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_STA_STOP' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_STA_CONNECTED' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_STA_DISCONNECTED' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_STA_AUTHMODE_CHANGE' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_STA_GOT_IP' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_STA_LOST_IP' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_STA_WPS_ER_SUCCESS' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_STA_WPS_ER_FAILED' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_STA_WPS_ER_TIMEOUT' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_STA_WPS_ER_PIN' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_STA_WPS_ER_PBC_OVERLAP' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_AP_START' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_AP_STOP' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_AP_STACONNECTED' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_AP_STADISCONNECTED' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_AP_STAIPASSIGNED' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_AP_PROBEREQRECVED' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_GOT_IP6' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_ETH_START' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_ETH_STOP' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_ETH_CONNECTED' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_ETH_DISCONNECTED' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_ETH_GOT_IP' not handled in switch [-Wswitch]
    src\main.cpp:127:12: warning: enumeration value 'SYSTEM_EVENT_MAX' not handled in switch [-Wswitch]
    src\main.cpp: In function 'void connectToWifi()':
    src\main.cpp:453:10: warning: unused variable 'hidden' [-Wunused-variable]
    bool hidden;
    ^
    Archiving .pio\build\esp32\lib361\libWiFi.a
    Compiling .pio\build\esp32\lib3b4\ESP Async WebServer\AsyncEventSource.cpp.o
    Compiling .pio\build\esp32\lib3b4\ESP Async WebServer\AsyncWebSocket.cpp.o
    Compiling .pio\build\esp32\lib3b4\ESP Async WebServer\SPIFFSEditor.cpp.o
    *** [.pio\build\esp32\src\main.cpp.o] Error 1
    ================================================================ [FAILED] Took 11.45 seconds ================================================================
    Environment Status Duration

esp32 FAILED 00:00:11.452
=========================================================== 1 failed, 0 succeeded in 00:00:11.452 ===========================================================`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.