Skip to content

ESP-NOW automatic pairing library for ESP32

License

Notifications You must be signed in to change notification settings

void-ref/PeaPod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PeaPod

ESP-NOW utility library for automatic pairing with ESP32 SOCs.

The pairing process is simple and fast, and does not require prior knowledge or hardcoding of peer details.

Note: this library assumes a peapod contains only two peas.

Features

  • Simple pairing between two ESP32s
  • Callbacks for pairing and transmission operations
  • Persistent storage of pairing data
  • No need to know peer MAC addresses beforehand
  • No required designation of server/client roles

Usage

Two ESP32s can be flashed with the following program. Once they are paired, the repeated message "Hello there!" can be observed with a UART/serial monitor.

#include "peapod/PeaPod.h"
#include <freertos/FreeRTOS.h>

#include <string>

const char *message = "Hello there!";

class Callbacks: pp::PeaPodCallbacks {
    virtual void on_receive(const uint8_t* rx_data, std::size_t data_len) override {
        std::string rx_str((const char*)rx_data, data_len);
        Serial.println(rx_str.c_str());
    }
};

void setup() {
    Serial.begin();
    PeaPod.begin();
    PeaPod.set_callbacks(new Callbacks());

    if (!PeaPod.is_paired()) {
        Serial.println("Pairing now");
        PeaPod.pairing()->start();
    }
}

void loop() {
    vTaskDelay(pdMS_TO_TICKS(1000));
    if (!PeaPod.is_paired())
        continue;

    PeaPod.pea().send(message);
}

About

ESP-NOW automatic pairing library for ESP32

Resources

License

Stars

Watchers

Forks

Languages