Я новичок и впервые пробую esp. У меня есть две платы Adafruit QT Py ESP32-C3, и я пытаюсь заставить одну плату отправлять сообщение, а вторую плату печатать по серийному номеру, что она получила сообщение.
Хотя все моя конфигурация, кажется, проходит успешно (я никогда не получаю кодов ошибок ESP), все, что я получаю из своих отладочных сообщений, это то, что каждый раз, когда запускается обратный вызов отправки, в результате он вызывается с «сбоем».
Кроме того, мой получатель никогда не выполняет обратный вызов получения, поэтому его последовательный журнал просто постоянно молчит.
До сих пор я пытался установить канал Wi-Fi узла в отправителе, чтобы убедиться, что он соответствует получатель, меняя местами, какая плата является отправителем, а какая - получателем, переходя с платформы IO на Arduino IDE, отключая светодиодные индикаторы и оставляя активными только сообщения последовательного порта.
Я также пробовал код прямо из некоторых руководств Я просмотрел эту тему, но все сообщения по-прежнему не отправляются.
Уроки, которые я использовал:
dronebotworkshop
randomnerd< /p>
volosproject
Есть идеи, почему все мои отправляемые сообщения не работают/ничего не получается? Спасибо!!
Вот как выглядит последовательный порт отправителя (COM4):
34:85:18:17:DC:2C
ESP-NOW init OK
send callback registered OK
Peer added
Wifi channel:
1
Attempting to send 0
esp_now_send sent complete
Failed to send
Attempting to send 1
Callback invoked with status: 1
esp_now_send sent complete
Failed to send
а вот последовательный порт на ресивере (COM3):
34:85:18:17:EA:28
ESP-NOW init OK
receive calback registered OK
Wifi channel:
1
КОД ОТПРАВИТЕЛЯ:
#include
#include
#include
// #include
#include "controllerGlobals.h"
// Adafruit_NeoPixel strip(NUM_PIXELS, LED_PIN, NEO_GRB + NEO_KHZ800); // create led strip
// Helper function to set color
// void setLEDColor(uint8_t red, uint8_t green, uint8_t blue) {
// strip.setPixelColor(0, strip.Color(red, green, blue)); // Set color for first pixel
// strip.show();
// }
esp_now_peer_info_t peerInfo;
uint8_t data = 0;
uint8_t sentFailed= 1; // 0 = success, 1 = failed
void sendDataCb(const uint8_t* macAddress, esp_now_send_status_t sentStatus) {
Serial.printf("Callback invoked with status: %d\n", sentStatus);
if(sentStatus == ESP_NOW_SEND_SUCCESS)
{
sentFailed = 0;
}
else
{
//ERROR: FAILED TO SEND
sentFailed = 1;
}
}
void blinkSendResult()
{
if(sentFailed)
{
//ERROR: FAILED TO SEND
Serial.println("Failed to send");
// for(short i = 0; i < 3; i++)
// {
// setLEDColor(LED_RED);
// usleep(250*1000); //sleep 250ms
// setLEDColor(LED_OFF);
// usleep(250*1000); //sleep 250ms
// }
}
else
{
// successful send!
Serial.println("Successful send!");
// for(short i = 0; i < 2; i++)
// {
// setLEDColor(LED_GREEN);
// usleep(500*1000); //sleep 250ms
// setLEDColor(LED_OFF);
// usleep(500*1000); //sleep 250ms
// }
sentFailed = 1; //reset sentfailed flag for next loop
}
}
void setup() {
// start serial port
Serial.begin(CONFIG_MONITOR_BAUD_OTHER_VAL); //115200
//INITIALIZE LED
// strip.begin(); // Initialize the Neopixel library
// strip.setBrightness(10); // Set brightness (0 to 255; 50 is about 20% brightness)
// strip.show(); // Turn off all LEDs initially
// initialize wifi module in station mode
WiFi.mode(WIFI_STA);
// WiFi.disconnect();
WiFi.channel(1);
// print mac address to serial port
// sleep(5);
delay(5000);
// Serial.printf("%s\n", String(WiFi.macAddress()).c_str());
Serial.println(String(WiFi.macAddress()));
// initialize esp-now protocol
if(esp_now_init() == ESP_OK)
{
Serial.println("ESP-NOW init OK");
}
if (esp_now_register_send_cb(sendDataCb) == ESP_OK){
Serial.println("send callback registered OK");
}
//register esp-now peer
memcpy(peerInfo.peer_addr, receiverAddr, 6);
peerInfo.channel = 1;
peerInfo.encrypt = false;
// Add peer
if (esp_now_add_peer(&peerInfo) != ESP_OK){
Serial.println("Failed to add peer");
return;
}
else
{
Serial.println("Peer added");
}
Serial.println("Wifi channel:");
Serial.println(WiFi.channel());
}
void loop() {
Serial.printf("Attempting to send %d\n", data);
// sleep(3);
// delay(500);
// setLEDColor(LED_YELLOW);
// sleep(3);
// delay(1000);
// setLEDColor(LED_OFF);
// sleep(3);
delay(1000);
if(esp_now_send(peerInfo.peer_addr, (uint8_t*)&data, sizeof(data)) != ESP_OK)
{
Serial.println("esp_now_send failed");
}
else
{
Serial.println("esp_now_send sent complete");
}
blinkSendResult();
data = (data) ? 0 : 1;
}
КОД ПОЛУЧАТЕЛЯ:
#include
#include
#include
#include
#include "controllerGlobals.h"
Adafruit_NeoPixel strip(NUM_PIXELS, LED_PIN, NEO_GRB + NEO_KHZ800); // create led strip
// Helper function to set color
void setLEDColor(uint8_t red, uint8_t green, uint8_t blue) {
strip.setPixelColor(0, strip.Color(red, green, blue)); // Set color for first pixel
strip.show();
}
uint8_t data = 2;
void recvDataCb(const uint8_t * mac, const uint8_t *incomingData, int len) {
Serial.println("Callback invoked");
memcpy(&data, incomingData, sizeof(data));
if(data == 0)
{
// reset data value
data = 2;
setLEDColor(LED_GREEN);
sleep(1);
}
else if(data == 1)
{
// reset data value
data = 2;
setLEDColor(LED_BLUE);
sleep(1);
}
else
{
// reset data value
data = 2;
setLEDColor(LED_RED);
sleep(1);
}
}
void setup() {
// start serial port
Serial.begin(CONFIG_MONITOR_BAUD_OTHER_VAL); //115200
//INITIALIZE LED
strip.begin(); // Initialize the Neopixel library
strip.setBrightness(10); // Set brightness (0 to 255; 50 is about 20% brightness)
strip.show(); // Turn off all LEDs initially
// initialize wifi module in station mode
WiFi.mode(WIFI_STA);
// WiFi.disconnect();
// print mac address to serial port
sleep(5);
Serial.println(String(WiFi.macAddress()));
// initialize esp-now protocol
if(esp_now_init() == ESP_OK)
{
Serial.println("ESP-NOW init OK");
}
// esp_err_t cbregistration = esp_now_register_recv_cb(recvDataCb);
if(esp_now_register_recv_cb(recvDataCb) == ESP_OK)
{
Serial.println("receive calback registered OK");
}
Serial.println("Wifi channel:");
Serial.println(WiFi.channel());
}
void loop() {
// Serial.println("Waiting LED ON");
// setLEDColor(LED_YELLOW);
// usleep(250*1000); //sleep 250ms
// Serial.println("Waiting LED OFF");
// setLEDColor(LED_OFF);
// delay(1000);
}
controllerGlobals.h
#include
#define LED_PIN 2 // Neopixel data pin (GPIO 2 for QT Py ESP32-C3)
#define NUM_PIXELS 1 // Number of LEDs (typically 1 for the built-in Neopixel)
// color definitions for LED
#define LED_RED 255,0,0
#define LED_GREEN 0,255,0
#define LED_BLUE 0,0,255
#define LED_YELLOW 255,255,0
#define LED_OFF 0,0,0
const uint8_t receiverAddr[] = {0x34, 0x85, 0x18, 0x17, 0xEA, 0x28}; //receiver -- com3
// const uint8_t receiverAddr[] = {0x34, 0x85, 0x18, 0x17, 0xDC, 0x2C}; //sender -- com4
Подробнее здесь: https://stackoverflow.com/questions/792 ... -receiving
Esp Сейчас не отправляю и не получаю ⇐ C++
Программы на C++. Форум разработчиков
1734309490
Anonymous
Я новичок и впервые пробую esp. У меня есть две платы Adafruit QT Py ESP32-C3, и я пытаюсь заставить одну плату отправлять сообщение, а вторую плату печатать по серийному номеру, что она получила сообщение.
Хотя все моя конфигурация, кажется, проходит успешно (я никогда не получаю кодов ошибок ESP), все, что я получаю из своих отладочных сообщений, это то, что каждый раз, когда запускается обратный вызов отправки, в результате он вызывается с «сбоем».
Кроме того, мой получатель никогда не выполняет обратный вызов получения, поэтому его последовательный журнал просто постоянно молчит.
До сих пор я пытался установить канал Wi-Fi узла в отправителе, чтобы убедиться, что он соответствует получатель, меняя местами, какая плата является отправителем, а какая - получателем, переходя с платформы IO на Arduino IDE, отключая светодиодные индикаторы и оставляя активными только сообщения последовательного порта.
Я также пробовал код прямо из некоторых руководств Я просмотрел эту тему, но все сообщения по-прежнему не отправляются.
Уроки, которые я использовал:
dronebotworkshop
randomnerd< /p>
volosproject
Есть идеи, почему все мои отправляемые сообщения не работают/ничего не получается? Спасибо!!
Вот как выглядит последовательный порт отправителя (COM4):
34:85:18:17:DC:2C
ESP-NOW init OK
send callback registered OK
Peer added
Wifi channel:
1
Attempting to send 0
esp_now_send sent complete
Failed to send
Attempting to send 1
Callback invoked with status: 1
esp_now_send sent complete
Failed to send
а вот последовательный порт на ресивере (COM3):
34:85:18:17:EA:28
ESP-NOW init OK
receive calback registered OK
Wifi channel:
1
[b]КОД ОТПРАВИТЕЛЯ:[/b]
#include
#include
#include
// #include
#include "controllerGlobals.h"
// Adafruit_NeoPixel strip(NUM_PIXELS, LED_PIN, NEO_GRB + NEO_KHZ800); // create led strip
// Helper function to set color
// void setLEDColor(uint8_t red, uint8_t green, uint8_t blue) {
// strip.setPixelColor(0, strip.Color(red, green, blue)); // Set color for first pixel
// strip.show();
// }
esp_now_peer_info_t peerInfo;
uint8_t data = 0;
uint8_t sentFailed= 1; // 0 = success, 1 = failed
void sendDataCb(const uint8_t* macAddress, esp_now_send_status_t sentStatus) {
Serial.printf("Callback invoked with status: %d\n", sentStatus);
if(sentStatus == ESP_NOW_SEND_SUCCESS)
{
sentFailed = 0;
}
else
{
//ERROR: FAILED TO SEND
sentFailed = 1;
}
}
void blinkSendResult()
{
if(sentFailed)
{
//ERROR: FAILED TO SEND
Serial.println("Failed to send");
// for(short i = 0; i < 3; i++)
// {
// setLEDColor(LED_RED);
// usleep(250*1000); //sleep 250ms
// setLEDColor(LED_OFF);
// usleep(250*1000); //sleep 250ms
// }
}
else
{
// successful send!
Serial.println("Successful send!");
// for(short i = 0; i < 2; i++)
// {
// setLEDColor(LED_GREEN);
// usleep(500*1000); //sleep 250ms
// setLEDColor(LED_OFF);
// usleep(500*1000); //sleep 250ms
// }
sentFailed = 1; //reset sentfailed flag for next loop
}
}
void setup() {
// start serial port
Serial.begin(CONFIG_MONITOR_BAUD_OTHER_VAL); //115200
//INITIALIZE LED
// strip.begin(); // Initialize the Neopixel library
// strip.setBrightness(10); // Set brightness (0 to 255; 50 is about 20% brightness)
// strip.show(); // Turn off all LEDs initially
// initialize wifi module in station mode
WiFi.mode(WIFI_STA);
// WiFi.disconnect();
WiFi.channel(1);
// print mac address to serial port
// sleep(5);
delay(5000);
// Serial.printf("%s\n", String(WiFi.macAddress()).c_str());
Serial.println(String(WiFi.macAddress()));
// initialize esp-now protocol
if(esp_now_init() == ESP_OK)
{
Serial.println("ESP-NOW init OK");
}
if (esp_now_register_send_cb(sendDataCb) == ESP_OK){
Serial.println("send callback registered OK");
}
//register esp-now peer
memcpy(peerInfo.peer_addr, receiverAddr, 6);
peerInfo.channel = 1;
peerInfo.encrypt = false;
// Add peer
if (esp_now_add_peer(&peerInfo) != ESP_OK){
Serial.println("Failed to add peer");
return;
}
else
{
Serial.println("Peer added");
}
Serial.println("Wifi channel:");
Serial.println(WiFi.channel());
}
void loop() {
Serial.printf("Attempting to send %d\n", data);
// sleep(3);
// delay(500);
// setLEDColor(LED_YELLOW);
// sleep(3);
// delay(1000);
// setLEDColor(LED_OFF);
// sleep(3);
delay(1000);
if(esp_now_send(peerInfo.peer_addr, (uint8_t*)&data, sizeof(data)) != ESP_OK)
{
Serial.println("esp_now_send failed");
}
else
{
Serial.println("esp_now_send sent complete");
}
blinkSendResult();
data = (data) ? 0 : 1;
}
[b]КОД ПОЛУЧАТЕЛЯ:[/b]
#include
#include
#include
#include
#include "controllerGlobals.h"
Adafruit_NeoPixel strip(NUM_PIXELS, LED_PIN, NEO_GRB + NEO_KHZ800); // create led strip
// Helper function to set color
void setLEDColor(uint8_t red, uint8_t green, uint8_t blue) {
strip.setPixelColor(0, strip.Color(red, green, blue)); // Set color for first pixel
strip.show();
}
uint8_t data = 2;
void recvDataCb(const uint8_t * mac, const uint8_t *incomingData, int len) {
Serial.println("Callback invoked");
memcpy(&data, incomingData, sizeof(data));
if(data == 0)
{
// reset data value
data = 2;
setLEDColor(LED_GREEN);
sleep(1);
}
else if(data == 1)
{
// reset data value
data = 2;
setLEDColor(LED_BLUE);
sleep(1);
}
else
{
// reset data value
data = 2;
setLEDColor(LED_RED);
sleep(1);
}
}
void setup() {
// start serial port
Serial.begin(CONFIG_MONITOR_BAUD_OTHER_VAL); //115200
//INITIALIZE LED
strip.begin(); // Initialize the Neopixel library
strip.setBrightness(10); // Set brightness (0 to 255; 50 is about 20% brightness)
strip.show(); // Turn off all LEDs initially
// initialize wifi module in station mode
WiFi.mode(WIFI_STA);
// WiFi.disconnect();
// print mac address to serial port
sleep(5);
Serial.println(String(WiFi.macAddress()));
// initialize esp-now protocol
if(esp_now_init() == ESP_OK)
{
Serial.println("ESP-NOW init OK");
}
// esp_err_t cbregistration = esp_now_register_recv_cb(recvDataCb);
if(esp_now_register_recv_cb(recvDataCb) == ESP_OK)
{
Serial.println("receive calback registered OK");
}
Serial.println("Wifi channel:");
Serial.println(WiFi.channel());
}
void loop() {
// Serial.println("Waiting LED ON");
// setLEDColor(LED_YELLOW);
// usleep(250*1000); //sleep 250ms
// Serial.println("Waiting LED OFF");
// setLEDColor(LED_OFF);
// delay(1000);
}
[b]controllerGlobals.h[/b]
#include
#define LED_PIN 2 // Neopixel data pin (GPIO 2 for QT Py ESP32-C3)
#define NUM_PIXELS 1 // Number of LEDs (typically 1 for the built-in Neopixel)
// color definitions for LED
#define LED_RED 255,0,0
#define LED_GREEN 0,255,0
#define LED_BLUE 0,0,255
#define LED_YELLOW 255,255,0
#define LED_OFF 0,0,0
const uint8_t receiverAddr[] = {0x34, 0x85, 0x18, 0x17, 0xEA, 0x28}; //receiver -- com3
// const uint8_t receiverAddr[] = {0x34, 0x85, 0x18, 0x17, 0xDC, 0x2C}; //sender -- com4
Подробнее здесь: [url]https://stackoverflow.com/questions/79283424/esp-now-not-sending-or-not-receiving[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия