Git Product home page Git Product logo

esp-idf-espnow-gateway's Introduction

esp-idf-espnow-gateway

Gateway between esp-now and MQTT using esp-idf.

I was inspired by this.

スライド1

ESP-NOW can be used with ESP8266/8285, but we cannot use WiFi at the same time.
This project transfers the data received by ESP-NOW to MQTT.

Battery life

ESP8266/8285 + battery + ESP-NOW + DeelSpeep enables long-time operation.
This is a comparison of battery consumption between Wifi and ESP-NOW.

スライド1

スライド2

Battery life after 112 days using ESP-NOW

スライド1


Installation

git clone https://github.com/nopnop2002/esp-idf-espnow-gateway
cd esp-idf-espnow-gateway
idf.py set-target esp32
idf.py menuconfig
idf.py flash monitor

Configuration

You have to set this config value using menuconfig.

  • CONFIG_STA_WIFI_SSID
    SSID of your wifi.
  • CONFIG_STA_WIFI_PASSWORD
    PASSWORD of your wifi.
  • CONFIG_STA_MAXIMUM_RETRY
    Maximum number of retries when connecting to wifi.
  • CONFIG_BROKER_URL
    URL of MQTT broker.
  • CONFIG_ESPNOW_ENABLE_LONG_RANGE
    Enable long-range ESP-NOW.
    When enable long range, the PHY rate of ESP32 will be 512Kbps or 256Kbps.

config-main

config-app


ESP8266 Example Sketch

There is two example.
Replace the remote MAC address with your ESP32 MAC address.

uint8_t remoteDevice[] = {0x24, 0x0a, 0xc4, 0xef, 0xaa, 0x65};

When you run this project on the ESP32, you will see ESP32 MAC address:
mac

  • espnow-controller
    Publish every 10 seconds.
    I used broker.emqx.io as MQTT broker.
$ mosquitto_sub -v -h broker.emqx.io -p 1883  -t "/mqtt/espnow" | ts "%y/%m/%d %H:%M:%S"
21/08/11 16:52:25 /mqtt/espnow Hello 10001 2968
21/08/11 16:52:35 /mqtt/espnow Hello 20002 2966
21/08/11 16:52:45 /mqtt/espnow Hello 30003 2966
21/08/11 16:52:55 /mqtt/espnow Hello 40004 2965
21/08/11 16:53:05 /mqtt/espnow Hello 50005 2966
21/08/11 16:53:15 /mqtt/espnow Hello 60006 2965
  • espnow-controller-deepSleep
    Wake up from Deep Sleep every 60 seconds and publish.
    You need to connect Resets and GPIO16.
    I used broker.emqx.io as MQTT broker.
$ mosquitto_sub -v -h broker.emqx.io -p 1883  -t "/mqtt/espnow" | ts "%y/%m/%d %H:%M:%S"
21/08/11 16:40:32 /mqtt/espnow Hello 66 2904
21/08/11 16:41:30 /mqtt/espnow Hello 68 2908
21/08/11 16:42:29 /mqtt/espnow Hello 67 2908
21/08/11 16:43:29 /mqtt/espnow Hello 67 2907
21/08/11 16:44:28 /mqtt/espnow Hello 68 2911
21/08/11 16:45:27 /mqtt/espnow Hello 67 2906

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.