Code Monkey home page Code Monkey logo

quickespnow's Introduction

Quick ESP-NOW

PlatformIO Registry

Introduction

This is a library for Arduino framework to be used with Espressif ESP8266 and ESP32 series microcontrollers.

ESP-NOW is a wireless communication protocol that allows two devices to send data to each other without the need for a wireless network. You can read more about it here: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_now.html

Benefits

Usage of ESP-NOW may not be straightforward. There are some restrictions that has to be considered, as limit of number of devices, WiFi channel selection, and other factors.

This library pretends to hide all that restrictions so that it can be used with just a few lines of code.

Besides, it removes some limitations:

  • No more 20 devices limit. You can use ESP-NOW with any number of devices. Library takes control of peer registration and makes it transparent to you.
  • Channel selection is not required for WiFi coexistence.
  • No need to assign a role to each device. Just use it for peer to peer communication.
  • RSSI information of every message.
  • Receiver can distiguish between broadcast and unicast messages.
  • Tested maximum througput, about 1500 kbps continuous with default parameters.
  • Encryption is not supported. Usage of ESP-NOW encryption restrict system to 6 devices. You can implement data encryption in a higher layer.

Usage

One just only needs to call begin and set a receivin callback function, if you need to receive data. Then you can use send function to send data to a specific device or use ESPNOW_BROADCAST_ADDRESS to send data to all listening devices in the same channel.

void dataReceived (uint8_t* address, uint8_t* data, uint8_t len, signed int rssi, bool broadcast) {
    Serial.printf("Received message: %.*s\n", len, data);
}

void setup () {
    Serial.begin (115200);
    WiFi.mode (WIFI_MODE_STA);
    WiFi.disconnect (false);
    quickEspNow.onDataRcvd (dataReceived);
    quickEspNow.begin (1); // If you are not connected to WiFi, channel should be specified
}

void loop () {
    String message = "Hello, world!";
    quickEspNow.send (DEST_ADDR, (uint8_t*)message.c_str (), message.length ());
    delay (1000);
}

quickespnow's People

Contributors

gmag11 avatar

Watchers

James Cloos avatar

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.