<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Simple Example of ESP-NOW Communication Between StickC Plus and M5Core Basic]]></title><description><![CDATA[<p dir="auto">I am working on a project that requires wireless communication between a StickC Plus and an M5Core Basic using the ESP-NOW protocol. I am new to this and would greatly appreciate it if someone could provide me with a simple example to establish this communication.</p>
<p dir="auto">I have found some tutorials on ESP-NOW, but I would like to see a specific example for these devices. Any help or example code would be greatly appreciated.</p>
]]></description><link>https://community.m5stack.com/topic/6738/simple-example-of-esp-now-communication-between-stickc-plus-and-m5core-basic</link><generator>RSS for Node</generator><lastBuildDate>Sat, 14 Mar 2026 14:19:50 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/6738.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Aug 2024 18:33:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Simple Example of ESP-NOW Communication Between StickC Plus and M5Core Basic on Wed, 28 Aug 2024 19:31:09 GMT]]></title><description><![CDATA[<p dir="auto">Hi <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/7508">@teastain</a> .<br />
I don’t know how to program in C++, that’s why I have fun with the Uiflow blocks.<br />
I am very grateful for your intention to help me and I will try to test the code, although modifying it will be my problem.<br />
Thanks</p>
]]></description><link>https://community.m5stack.com/post/26263</link><guid isPermaLink="true">https://community.m5stack.com/post/26263</guid><dc:creator><![CDATA[Robertof]]></dc:creator><pubDate>Wed, 28 Aug 2024 19:31:09 GMT</pubDate></item><item><title><![CDATA[Reply to Simple Example of ESP-NOW Communication Between StickC Plus and M5Core Basic on Wed, 28 Aug 2024 01:44:39 GMT]]></title><description><![CDATA[<p dir="auto">I wrote this VERY terse, simplistic code to demonstrate ESP-NOW. You simply copy this code to an empty Arduino IDE sketch and change the particulars: I.e. Mac address LED pin and Button pin<br />
Both M5Stack units, regardless of type use the same code except for the particulars, especially the MAC address. The demo sends a boolean single bit signal when its button is pressed and the other receives it and turns on its LED: You can easily convert it to send and receive an int or a float, whatever! It was written for two StickC Plus, but any ESP32 will do.</p>
<pre><code>#include &lt;Arduino.h&gt;
#include &lt;esp_now.h&gt;
#include &lt;WiFi.h&gt;
#define LED 10  // or whatever you have
#define Button 37
//Below is the address of the other unit
uint8_t broadcastAddress[] = { 0x94, 0xB9, 0x7E, 0x8C, 0x7C, 0xE8 };

String success;

typedef struct struct_message {
  bool State;
} struct_message;

// Create a struct_message to hold outgoing button
struct_message TxButton;
// Create a struct_message to hold incoming button (to turn on this LED)
struct_message RxButton;  //I.E. = incomingReadings

// Register peer
esp_now_peer_info_t peerInfo;

void setup() {
  Serial.begin(115200);
  pinMode(LED, OUTPUT);
  digitalWrite(LED, HIGH);
  pinMode(Button, INPUT);
  WiFi.mode(WIFI_STA);
  // Init ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }
  // get the status of Trasnmitted packet
  esp_now_register_send_cb(OnDataSent);

  memcpy(peerInfo.peer_addr, broadcastAddress, 6);
  peerInfo.channel = 0;
  peerInfo.encrypt = false;
  // Add peer
  if (esp_now_add_peer(&amp;peerInfo) != ESP_OK) {
    Serial.println("A- Failed to add peer");
    return;
  }
  // Register for a callback function that will be called when data is received
  esp_now_register_recv_cb(OnDataRecv);
  delay(1000);
}

void loop() {
  TxButton.State = digitalRead(Button);  //***this is where you tramsmit this units button state
  esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *)&amp;TxButton, sizeof(TxButton));
  if (result == ESP_OK) {
    Serial.println("Sent with success");
  } else {
    Serial.println("Error sending the data");
  }
  delay(500);
}

// OnDataRecv when data is received, LED is controlled here
void OnDataRecv(const uint8_t *mac, const uint8_t *incomingData, int len) {
  memcpy(&amp;RxButton, incomingData, sizeof(RxButton));
  Serial.print("Bytes received: ");
  Serial.println(len);
  digitalWrite(LED, RxButton.State);  //***this is where you receive the state of the other unit's button
}

void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  Serial.print("\r\nA- Last Packet Send Status:\t");
  Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
  if (status == 0) {
    success = "Delivery Success :)";
  } else {
    success = "Delivery Fail :(";
  }
}

</code></pre>
]]></description><link>https://community.m5stack.com/post/26250</link><guid isPermaLink="true">https://community.m5stack.com/post/26250</guid><dc:creator><![CDATA[teastain]]></dc:creator><pubDate>Wed, 28 Aug 2024 01:44:39 GMT</pubDate></item></channel></rss>