I’m currently working on an ESP-Now project where I’m creating a web server to control several relays.
I have the following error in the receiver code:
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\upesy_wroom\firmware.elf] Error 1
This is what my code looks like. I was looking into it and I’m not sure if its a driver issue or something in my code. I’m very new to all of this and don’t really know what I’m doing.
#include <Arduino.h>
#include <esp_now.h>
#include <WiFi.h>
#include <FS.h>
#include "ESPAsyncWebServer.h"
// Set to true to define Relay as Normally Open (NO)
#define RELAY_NO true
// Set number of relays
#define NUM_RELAYS 8
// Assign each GPIO to a relay
int relayGPIOs[NUM_RELAYS] = {19, 18, 5, 17, 16, 4, 2, 15};
// Structure example to receive data
// Must match the sender structure
typedef struct struct_message {
char a[32];
int b;
float c;
bool d;
} struct_message;
// Create a struct_message called myData
struct_message myData;
// callback function that will be executed when data is received
void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {
memcpy(&myData, incomingData, sizeof(myData));
Serial.print("Bytes received: ");
Serial.println(len);
Serial.print("Char: ");
Serial.println(myData.a);
Serial.print("Int: ");
Serial.println(myData.b);
Serial.print("Float: ");
Serial.println(myData.c);
Serial.print("Bool: ");
Serial.println(myData.d);
Serial.println();
}
void setup() {
// Initialize Serial Monitor
Serial.begin(115200);
// Set device as a Wi-Fi Station
WiFi.mode(WIFI_STA);
// Init ESP-NOW
if (esp_now_init() != ESP_OK) {
Serial.println("Error initializing ESP-NOW");
return;
}
// Once ESPNow is successfully Init, we will register for recv CB to
// get recv packer info
esp_now_register_recv_cb(OnDataRecv);
}