Read RSSI when using esp-now

I am trying to obtain the RSSI of an ESP32 client and send it to the master.
I am getting the following error.
'esp_now_get_peer_rssi' was not declared in this scope
Any help is appreciated.
Attached is the code:

#include <esp_now.h>
#include <WiFi.h>

// Replace with your own MAC addresses
uint8_t receiverMAC[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};   // MAC address of the receiver (master) ESP32
uint8_t senderMAC[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; // MAC address of the sender (slave) ESP32

// Callback function to handle received data
void OnDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len) {
  Serial.print("Received data from MAC: ");
  for (int i = 0; i < 6; i++) {
    Serial.print(mac_addr[i], HEX);
    if (i < 5) Serial.print(':');
  }
  Serial.print(" Data: ");
  Serial.print(*data); // Assuming you are sending a single number
  Serial.print(" RSSI: ");
  Serial.println(esp_now_get_peer_rssi(*mac_addr)); // Print the received signal strength

  // Send the RSSI value back to the master ESP32
  if (esp_now_send(senderMAC, (uint8_t*)&esp_now_get_peer_rssi(*mac_addr), sizeof(int)) != ESP_OK) {
    Serial.println("Failed to send RSSI data");
  }
}

void setup() {
  Serial.begin(115200);
  delay(1000);

  // Initialize ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("ESP-NOW initialization failed");
    ESP.restart();
  }

  // Register the callback function for receiving data
  esp_now_register_recv_cb(OnDataRecv);

  // Add the receiver (master) to the peer list
  esp_now_peer_info_t peerInfo;
  memcpy(peerInfo.peer_addr, receiverMAC, 6);
  peerInfo.channel = 0; // Set the channel (0-13)
  peerInfo.encrypt = false; // No encryption
  if (esp_now_add_peer(&peerInfo) != ESP_OK) {
    Serial.println("Failed to add peer");
    ESP.restart();
  }
}

void loop() {
  // The slave can perform other tasks in the loop if needed
}

I dont have a clue myself, but if you were to mention which version of the Arduino IDE you were using as well as the ESP-NOW library your using, someone might spot your problem.

Thank you for your suggestion.
I am using Arduino version 1.8.18 because the higher versions don't work well with my sketches.
The board manager is esp32 by Espressif version 1.0.4 I have had issues after upgrading to 2.0.10

Where it's --

I think that should be && (not & ).

But I'm not sure what you're getting at there.

How about upgrading to IDE 1.8.19
and upgrading the ESP32-board to 2.0.11

You could install this as a portable IDE
like described here

google or duckduckgo is always worth a 5 minute search
https://www.reddit.com/r/esp32/comments/gzrd87/espnow_rssi/

Check whether a function with a similar name exists in the library.

I'am not sure how to implement w0.status('rssi') .
I am using the Arduino IDE and the search results seem to point to the Espressif IDE.
I tried updating the Arduino and the board with the same results.
It was worth a try.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.