I’m trying to move my ESP Now receiver to the RobotDyn ESP-Mega, because the R32 I want to use doesn’t reach the kitchen. The D1 Mini does, but it only has one analog pin. The R32 has four usable analog pins, and I have three analog sensors.
But this is about the receiver. I haven’t gotten ESP-Now (or really much of anything) to work on this (piece of crap) toy. But it has an antenna. I think it can pick up ESP Now from the R32 with this antenna.
This function is literally pasted in from a the working ESP-32 receiver script.
// Callback function that will be executed when data is received
void OnDataRecv(const uint8_t *mac_addr, const uint8_t *incomingData, int len)
{
char macStr[18];
Serial.print("Packet received from: ");
snprintf(macStr, sizeof(macStr), "%02x:%02x:%02x:%02x:%02x:%02x",
mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
Serial.println(macStr);
memcpy(&myData, incomingData, sizeof(myData));
board["id"] = myData.id;
board["temperature"] = myData.temperature;
board["humidity"] = myData.humidity;
// board["pressure"] = myData.pressure;
board["counter"] = String(myData.counter);
String jsonString = JSON.stringify(board);
events.send(jsonString.c_str(), "new_readings", millis());
Serial.printf("Board ID %u: %u bytes\n", myData.id, len);
Serial.printf("t value: %4.2f \n", myData.temperature);
Serial.printf("h value: %4.2f \n", myData.humidity);
Serial.printf("p value: %4.2f \n", myData.pressure);
Serial.print("ID:");
Serial.print(myData.counter);
Serial.println();
}
and later:
// Once ESPNow is successfully Init, we will register for recv CB to
// get recv packer info
esp_now_set_self_role(ESP_NOW_ROLE_SLAVE);
esp_now_register_recv_cb(OnDataRecv);
}
void loop()
How can I get this to work? It's esp_now.h instead of espnow.h.
src\main.cpp: In function 'void setup()':
src\main.cpp:90:28: error: invalid conversion from 'void (*)(const uint8_t*, const uint8_t*, int)' {aka 'void (*)(const unsigned char*, const unsigned char*, int)'} to 'esp_now_recv_cb_t' {aka 'void (*)(unsigned char*, unsigned char*, unsigned char)'} [-fpermissive]
90 | esp_now_register_recv_cb(OnDataRecv);
| ^~~~~~~~~~
| |
| void (*)(const uint8_t*, const uint8_t*, int) {aka void
(*)(const unsigned char*, const unsigned char*, int)}
In file included from src\main.cpp:14:
C:\Users\joema\.platformio\packages\framework-arduinoespressif8266\tools\sdk\include/espnow.h:50:48: note: initializing argument 1 of 'int esp_now_register_recv_cb(esp_now_recv_cb_t)'
50 | int esp_now_register_recv_cb(esp_now_recv_cb_t cb);