Go Down

Topic: esp_now_send, Error sending 5 array values, 4 photo resistors, 1 GY-511 angle (Read 1 time) previous topic - next topic

knightridar

I have 4 photoresistor values and 1 angle value from a GY-511 module that I'm getting via I2C connection.

I'm trying to send them as an array using the esp_now_send protocol.
esp_now_send protocol limited to 250 bytes???

I first calibrated the values using this example: https://www.arduino.cc/en/tutorial/calibration
In my case I'm tracking the sun, so I took the void setup () portion of code and put it into my void loop () code area since the light will be constantly changing through out the day.

I didn't want the initial values it establishes as base zero values in the morning and use those same values as the calibrated values for the rest of the time periods of the day. I hope I understood the calibration method properly. If anyone disagrees or has feedback regarding this please let me know.

Right now I'm getting this error:

Code: [Select]
exit status 1
invalid conversion from 'uint16_t {aka short unsigned int}' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]


at this portion of my code:
Code: [Select]
 //For each sensor
  for (int i = 0; i < 4; i++) {
    esp_now_send(analogRead(SensorArray[i]));
    Serial.println(SensorArray[i]);
  }


I'm not sure if it has to do with code I found online for the GY-511 module.
Up at the top of the code I declared these variables:
Code: [Select]
const int MPU_addr = 0x19;
int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ;


Although I don't have uint16_t variable declared throughout my code.
I tried finding it.

Also is my approach correct regarding the array inside the void sendData() block of code?
Thanks!
Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

knightridar

Code too long here it is:

Code: [Select]

/**
   ESPNOW - Basic communication - Master
   Date: 26th September 2017
   Author: Arvind Ravulavaru <https://github.com/arvindr21>
   Purpose: ESPNow Communication between a Master ESP32 and a Slave ESP32
   Description: This sketch consists of the code for the Master module.
   Resources: (A bit outdated)
   a. https://espressif.com/sites/default/files/documentation/esp-now_user_guide_en.pdf
   b. http://www.esploradores.com/practica-6-conexion-esp-now/

   << This Device Master >>

   Flow: Master
   Step 1 : ESPNow Init on Master and set it in STA mode
   Step 2 : Start scanning for Slave ESP32 (we have added a prefix of `slave` to the SSID of slave for an easy setup)
   Step 3 : Once found, add Slave as peer
   Step 4 : Register for send callback
   Step 5 : Start Transmitting data from Master to Slave

   Flow: Slave
   Step 1 : ESPNow Init on Slave
   Step 2 : Update the SSID of Slave with a prefix of `slave`
   Step 3 : Set Slave in AP mode
   Step 4 : Register for receive callback and wait for data
   Step 5 : Once data arrives, print it in the serial monitor

   Note: Master and Slave have been defined to easily understand the setup.
         Based on the ESPNOW API, there is no concept of Master and Slave.
         Any devices can act as master or slave.
*/

//allows you to communicate with I2C
#include<Wire.h>

//Libs for espnow and wifi
#include <esp_now.h>
#include <WiFi.h>

// Global copy of slave
esp_now_peer_info_t slave;
#define CHANNEL 3
#define PRINTSCANRESULTS 0
#define DELETEBEFOREPAIR 0

const int MPU_addr = 0x19;
int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ;

//values for determining correct angle with accelerometer
int minVal = 85;
int maxVal = 402;

double x;
int ElevationAngle; //elevation angle
double z;

//top left photoresistor sensor pin = PinTopLeft
int PinTopLeft = 33;
int PinBottomLeft = 35;
int PinTopRight = 32;
int PinBottomRight = 34;

// The sensor value
int TopLeft = 0;
int BottomLeft = 0;
int TopRight = 0;
int BottomRight = 0;

// As photoresistor approaches minimum sensor value more light is seen by it
int MinTopLeft = 0;
int MinBottomLeft = 0;
int MinTopRight = 0;
int MinBottomRight = 0;

int MaxTopLeft = 4096;
int MaxBottomLeft = 4096;
int MaxTopRight = 4096;
int MaxBottomRight = 4096;

Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

knightridar

Code: [Select]

/***************************Void functions**********************************/

// Init ESP Now with fallback
void InitESPNow() {
  WiFi.disconnect();
  if (esp_now_init() == ESP_OK) {
    Serial.println("ESPNow Init Success");
  }
  else {
    Serial.println("ESPNow Init Failed");
    // Retry InitESPNow, add a counte and then restart?
    // InitESPNow();
    // or Simply Restart
    ESP.restart();
  }
}

// Scan for slaves in AP mode
void ScanForSlave() {
  int8_t scanResults = WiFi.scanNetworks();
  // reset on each scan
  bool slaveFound = 0;
  memset(&slave, 0, sizeof(slave));

  Serial.println("");
  if (scanResults == 0) {
    Serial.println("No WiFi devices in AP Mode found");
  } else {
    Serial.print("Found "); Serial.print(scanResults); Serial.println(" devices ");
    for (int i = 0; i < scanResults; ++i) {
      // Print SSID and RSSI for each device found
      String SSID = WiFi.SSID(i);
      int32_t RSSI = WiFi.RSSI(i);
      String BSSIDstr = WiFi.BSSIDstr(i);

      if (PRINTSCANRESULTS) {
        Serial.print(i + 1);
        Serial.print(": ");
        Serial.print(SSID);
        Serial.print(" (");
        Serial.print(RSSI);
        Serial.print(")");
        Serial.println("");
      }
      delay(10);
      // Check if the current device starts with `Slave`
      if (SSID.indexOf("Slave") == 0) {
        // SSID of interest
        Serial.println("Found a Slave.");
        Serial.print(i + 1); Serial.print(": "); Serial.print(SSID); Serial.print(" ["); Serial.print(BSSIDstr); Serial.print("]"); Serial.print(" ("); Serial.print(RSSI); Serial.print(")"); Serial.println("");
        // Get BSSID => Mac Address of the Slave
        int mac[6];
        if ( 6 == sscanf(BSSIDstr.c_str(), "%x:%x:%x:%x:%x:%x%c",  &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5] ) ) {
          for (int ii = 0; ii < 6; ++ii ) {
            slave.peer_addr[ii] = (uint8_t) mac[ii];
          }
        }

        slave.channel = CHANNEL; // pick a channel
        slave.encrypt = 0; // no encryption

        slaveFound = 1;
        // we are planning to have only one slave in this example;
        // Hence, break after we find one, to be a bit efficient
        break;
      }
    }
  }

  if (slaveFound) {
    Serial.println("Slave Found, processing..");
  } else {
    Serial.println("Slave Not Found, trying again.");
  }

  // clean up ram
  WiFi.scanDelete();
}

// Check if the slave is already paired with the master.
// If not, pair the slave with master
bool manageSlave() {
  if (slave.channel == CHANNEL) {
    if (DELETEBEFOREPAIR) {
      deletePeer();
    }

    Serial.print("Slave Status: ");
    const esp_now_peer_info_t *peer = &slave;
    const uint8_t *peer_addr = slave.peer_addr;
    // check if the peer exists
    bool exists = esp_now_is_peer_exist(peer_addr);
    if ( exists) {
      // Slave already paired.
      Serial.println("Already Paired");
      return true;
    } else {
      // Slave not paired, attempt pair
      esp_err_t addStatus = esp_now_add_peer(peer);
      if (addStatus == ESP_OK) {
        // Pair success
        Serial.println("Pair success");
        return true;
      } else if (addStatus == ESP_ERR_ESPNOW_NOT_INIT) {
        // How did we get so far!!
        Serial.println("ESPNOW Not Init");
        return false;
      } else if (addStatus == ESP_ERR_ESPNOW_ARG) {
        Serial.println("Invalid Argument");
        return false;
      } else if (addStatus == ESP_ERR_ESPNOW_FULL) {
        Serial.println("Peer list full");
        return false;
      } else if (addStatus == ESP_ERR_ESPNOW_NO_MEM) {
        Serial.println("Out of memory");
        return false;
      } else if (addStatus == ESP_ERR_ESPNOW_EXIST) {
        Serial.println("Peer Exists");
        return true;
      } else {
        Serial.println("Not sure what happened");
        return false;
      }
    }
  } else {
    // No slave found to process
    Serial.println("No Slave found to process");
    return false;
  }
}

void deletePeer() {
  const esp_now_peer_info_t *peer = &slave;
  const uint8_t *peer_addr = slave.peer_addr;
  esp_err_t delStatus = esp_now_del_peer(peer_addr);
  Serial.print("Slave Delete Status: ");
  if (delStatus == ESP_OK) {
    // Delete success
    Serial.println("Success");
  } else if (delStatus == ESP_ERR_ESPNOW_NOT_INIT) {
    // How did we get so far!!
    Serial.println("ESPNOW Not Init");
  } else if (delStatus == ESP_ERR_ESPNOW_ARG) {
    Serial.println("Invalid Argument");
  } else if (delStatus == ESP_ERR_ESPNOW_NOT_FOUND) {
    Serial.println("Peer not found.");
  } else {
    Serial.println("Not sure what happened");
  }
}

// send data
uint8_t data = 0;

//Sends analog values in this format: i.e. {380,148,224,260,45}
int SensorArray[5] = {TopLeft, BottomLeft, TopRight, BottomRight, ElevationAngle};

void sendData() {
  data++;

  const uint8_t *peer_addr = slave.peer_addr;
  Serial.print("Sending: "); Serial.println(data);
  esp_err_t result = esp_now_send(peer_addr, &data, sizeof(data));
  Serial.print("Send Status: ");
  if (result == ESP_OK) {
    Serial.println("Success");
  } else if (result == ESP_ERR_ESPNOW_NOT_INIT) {
    // How did we get so far!!
    Serial.println("ESPNOW not Init.");
  } else if (result == ESP_ERR_ESPNOW_ARG) {
    Serial.println("Invalid Argument");
  } else if (result == ESP_ERR_ESPNOW_INTERNAL) {
    Serial.println("Internal Error");
  } else if (result == ESP_ERR_ESPNOW_NO_MEM) {
    Serial.println("ESP_ERR_ESPNOW_NO_MEM");
  } else if (result == ESP_ERR_ESPNOW_NOT_FOUND) {
    Serial.println("Peer not found.");
  } else {
    Serial.println("Not sure what happened");
  }

  //For each sensor
  for (int i = 0; i < 4; i++) {
    esp_now_send(analogRead(SensorArray[i]));
    Serial.println(SensorArray[i]);
  }
}

// callback when data is sent from Master to Slave
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  char macStr[18];
  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.print("Last Packet Sent to: "); Serial.println(macStr);
  Serial.print("Last Packet Send Status: "); Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}

/***************************End of Void functions**********************************/
Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

knightridar

Code: [Select]

void setup() {

  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);
  Wire.write(0);
  Wire.endTransmission(true);

  Serial.begin(115200);
  //Set device in STA mode to begin with
  WiFi.mode(WIFI_STA);
  Serial.println("ESPNow/Basic/Master Example");
  // This is the mac address of the Master in Station Mode
  Serial.print("STA MAC: "); Serial.println(WiFi.macAddress());
  // Init ESPNow with a fallback logic
  InitESPNow();
  // Once ESPNow is successfully Init, we will register for Send CB to
  // get the status of Transmitted packet
  esp_now_register_send_cb(OnDataSent);
}
void loop() {
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr, 14, true);

  AcX = Wire.read() << 8 | Wire.read();
  AcY = Wire.read() << 8 | Wire.read();
  AcZ = Wire.read() << 8 | Wire.read();

  int xAng = map(AcX, minVal, maxVal, -180, 180);
  int yAng = map(AcY, minVal, maxVal, -180, 180);
  int zAng = map(AcZ, minVal, maxVal, -180, 180);

  ElevationAngle = RAD_TO_DEG * (atan2(xAng, zAng));

  // Using example from: https://www.arduino.cc/en/tutorial/calibration
  // Calibrate during the first five seconds
  while (millis() < 5000) {
    TopLeft = analogRead(PinTopLeft);
    BottomLeft = analogRead(PinBottomLeft);
    TopRight = analogRead(PinTopRight);
    BottomRight = analogRead(PinBottomRight);

    // Record the maximum sensor value
    if (TopLeft > MaxTopLeft) {
      MaxTopLeft = TopLeft;
    }
    if (BottomLeft > MaxBottomLeft) {
      MaxBottomLeft = BottomLeft;
    }
    if (TopRight > MaxTopRight) {
      MaxTopRight = TopRight;
    }
    if (BottomRight > MaxBottomRight) {
      MaxBottomRight = BottomRight;
    }

    // Record the minimum sensor value
    if (TopLeft < MinTopLeft) {
      MinTopLeft = TopLeft;
    }
    if (BottomLeft < MinBottomLeft) {
      MinBottomLeft = BottomLeft;
    }
    if (TopRight < MinTopRight) {
      MinTopRight = TopRight;
    }
    if (BottomRight < MinBottomRight) {
      MinBottomRight = BottomRight;
    }
  }

  // Read the sensor
  TopLeft = analogRead(PinTopLeft); // Top left sensor
  BottomLeft = analogRead(PinBottomLeft);
  TopRight = analogRead(PinTopRight);
  BottomRight = analogRead(PinBottomRight);

  // Apply the calibration to the sensor reading
  TopLeft = map(TopLeft, MinTopLeft, MaxTopLeft, 0, 1023);
  BottomLeft = map(BottomLeft, MinBottomLeft, MaxBottomLeft, 0, 1023);
  TopRight = map(TopRight, MinTopRight, MaxTopRight, 0, 1023);
  BottomRight = map(BottomRight, MinBottomRight, MaxBottomRight, 0, 1023);

  // In case the sensor value is outside the range seen during calibration
  TopLeft = constrain(TopLeft, 0, 1023);
  BottomLeft = constrain(BottomLeft, 0, 1023);
  TopRight = constrain(TopRight, 0, 1023);
  BottomRight = constrain(BottomRight, 0, 1023);

  // In the loop we scan for slave
  ScanForSlave();
  // If Slave is found, it would be populate in `slave` variable
  // We will check if `slave` is defined and then we proceed further
  if (slave.channel == CHANNEL) { // check if slave channel is defined
    // `slave` is defined
    // Add slave as peer if it has not been added already
    bool isPaired = manageSlave();
    if (isPaired) {
      // pair success or already paired
      // Send data to device
      sendData();
    } else {
      // slave pair failed
      Serial.println("Slave pair failed!");
    }
  }
  else {
    // No slave found to process
  }
  delay(5000);
}
Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

knightridar

Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

pert

It will be easier for us to look into this if we have the full error message, rather than a snippet of it.

When you encounter an error you'll see a button on the right side of the orange bar in the Arduino IDE "Copy error messages" (or the icon that looks like two pieces of paper in the Arduino Web Editor). Click that button. Paste the error in a reply here using code tags.

 If the text exceeds the forum's 9000 character limit, save it to a .txt file and post it as an attachment. If you click the "Reply" button here, you will see an "Attachments and other settings" link.

knightridar

Hi, here is the full error message:

Code: [Select]
Arduino: 1.8.7 (Windows 10), Board: "DOIT ESP32 DEVKIT V1, 80MHz, 115200, None"

C:\Users\User\Dropbox\ARDUINO SOLAR TRACKING\DUAL_AXIS_SOLAR_TRACKING_BTS7960_TRANSMIT_ESP32_R1\DUAL_AXIS_SOLAR_TRACKING_BTS7960_TRANSMIT_ESP32_R1.ino: In function 'void sendData()':

DUAL_AXIS_SOLAR_TRACKING_BTS7960_TRANSMIT_ESP32_R1:262:28: error: invalid conversion from 'uint16_t {aka short unsigned int}' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]

     esp_now_send(analogRead(SensorArray[i]));

                            ^

DUAL_AXIS_SOLAR_TRACKING_BTS7960_TRANSMIT_ESP32_R1:262:44: error: too few arguments to function 'esp_err_t esp_now_send(const uint8_t*, const uint8_t*, size_t)'

     esp_now_send(analogRead(SensorArray[i]));

                                            ^

In file included from C:\Users\User\Dropbox\ARDUINO SOLAR TRACKING\DUAL_AXIS_SOLAR_TRACKING_BTS7960_TRANSMIT_ESP32_R1\DUAL_AXIS_SOLAR_TRACKING_BTS7960_TRANSMIT_ESP32_R1.ino:36:0:

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0/tools/sdk/include/esp32/esp_now.h:197:11: note: declared here

 esp_err_t esp_now_send(const uint8_t *peer_addr, const uint8_t *data, size_t len);

           ^

In file included from C:\Users\User\Dropbox\ARDUINO SOLAR TRACKING\DUAL_AXIS_SOLAR_TRACKING_BTS7960_TRANSMIT_ESP32_R1\DUAL_AXIS_SOLAR_TRACKING_BTS7960_TRANSMIT_ESP32_R1.ino:33:0:

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\Wire\src/Wire.h: In function 'void loop()':

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\Wire\src/Wire.h:98:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int, int)

     uint8_t requestFrom(int address, int size, int sendStop);

             ^

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\Wire\src/Wire.h:93:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint16_t, uint8_t, bool)

     uint8_t requestFrom(uint16_t address, uint8_t size, bool sendStop);

             ^

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\Wire\src/Wire.h:98:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int, int)

     uint8_t requestFrom(int address, int size, int sendStop);

             ^

C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\Wire\src/Wire.h:93:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint16_t, uint8_t, bool)

     uint8_t requestFrom(uint16_t address, uint8_t size, bool sendStop);

             ^

Multiple libraries were found for "WiFi.h"
 Used: C:\Users\User\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.0\libraries\WiFi
 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1
invalid conversion from 'uint16_t {aka short unsigned int}' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

knightridar

hi, i attached the full message since it exceeds the 9000 character limit and a separate attachment of the code. thanks.

I put code tags around the snippets of code embedded in the text file. Hope it helps.


Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

gfvalvo

I'm looking at the source code for esp_now.h here: https://github.com/espressif/esp-idf/blob/master/components/esp32/include/esp_now.h

The prototype for the esp_now_send function is:
Code: [Select]
esp_err_t esp_now_send(const uint8_t *peer_addr, const uint8_t *data, size_t len);
Your code is providing neither the proper type nor number of arguments.
No technical questions via PM. They will be ignored. Post your questions in the forum so that all may learn.

knightridar

Can you please clarify for me?

https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/network/esp_now.html

From website:

Quote
esp_err_tesp_now_send(const uint8_t *peer_addr, const uint8_t *data, size_t len)
Send ESPNOW data.

Attention
1. If peer_addr is not NULL, send data to the peer whose MAC address matches peer_addr
Attention
2. If peer_addr is NULL, send data to all of the peers that are added to the peer list
Attention
3. The maximum length of data must be less than ESP_NOW_MAX_DATA_LEN
Attention
4. The buffer pointed to by data argument does not need to be valid after esp_now_send returns
Return
When I look at the sample master and slave codes.
I thought the *data variable is for sending the number of packets.

How can I include an array inside this function?

Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

gfvalvo

I'm not at all familiar with esp-now. All I can tell you is what's required by the function's prototype. You must supply to the esp_now_send() function 3 arguments:

* A pointer to a uint8_t that contains the peer address

* A pointer to your data buffer (cast as a uint8_t * if required)

* Length of your data buffer in bytes.
No technical questions via PM. They will be ignored. Post your questions in the forum so that all may learn.

knightridar

I found this link in the esp now master code:

http://www.esploradores.com/practica-6-conexion-esp-now/

I can't believe I overlooked it so easily. It's using an ESP8266 but in my case I'm using an ESP32.
The example is doing part of what I want and that is sending an analog value from one ESP module to another via the ESP Now protocol.

Quote
esp_now_send (uint8_t * da, uint8_t * data,  uint8_t * len)
 Parameters:

uint8_t * da : array of the MAC address of the pair to which the data packet is sent. If the address is  NULL, the data is sent to all the addresses in the Communication Table.
uint8_t * data : array with the data package to send.
uint8_t len : length of the data packet array.
So I have to figure out how I'm going to put my five values into the data array.
I'm confused as to how to count my data packets length.


Here is a snippet of code from the website above:
 //***DATOS A ENVIAR***//
  ESTRUCTURA_DATOS ED;                     
    ED.potenciometro = analogRead(A0);
    Serial.print("Dato potenciometro: "); Serial.print(ED.potenciometro);
    delay(20);
    ED.tiempo = millis();
    Serial.print(". Dato tiempo: "); Serial.print(ED.tiempo);
 
  //***ENVÍO DE LOS DATOS***//
    //uint8_t *da=NULL;   //NULL envía los datos a todos los ESP con los que está emparejado
    uint8_t da[6] = {0x5C, 0xCF, 0x7F, 0x16, 0x50, 0xB9};
    uint8_t data[sizeof(ED)]; memcpy(data, &ED, sizeof(ED));
    uint8_t len = sizeof(data);
  esp_now_send(da, data, len);

Can someone show me how I can substitute my array in place of the example above?
I didn't use code tags because I couldn't include the red highlighted text in them.

Here is what I'm trying:

Code: [Select]
//Sends analog values in this format: i.e. {380,148,224,260,45}
uint8_t data[5] = {TopLeft, BottomLeft, TopRight, BottomRight, ElevationAngle};
uint8_t i;

void sendData() {

for (i = 0; i < 5; i = i++) {
//data++; commented this part of code out
data[i];
  const uint8_t *peer_addr = slave.peer_addr;
  Serial.print("Sending: "); Serial.println(data);
  esp_err_t result = esp_now_send(peer_addr, &data, sizeof(data));
  Serial.print("Send Status: ");
  if (result == ESP_OK) {
    Serial.println("Success");
  } else if (result == ESP_ERR_ESPNOW_NOT_INIT) {
    // How did we get so far!!
    Serial.println("ESPNOW not Init.");
  } else if (result == ESP_ERR_ESPNOW_ARG) {
    Serial.println("Invalid Argument");
  } else if (result == ESP_ERR_ESPNOW_INTERNAL) {
    Serial.println("Internal Error");
  } else if (result == ESP_ERR_ESPNOW_NO_MEM) {
    Serial.println("ESP_ERR_ESPNOW_NO_MEM");
  } else if (result == ESP_ERR_ESPNOW_NOT_FOUND) {
    Serial.println("Peer not found.");
  } else {
    Serial.println("Not sure what happened");
  }
}
}


I get an error saying:

Quote
exit status 1
no matching function for call to 'println(uint8_t [5])'
Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

knightridar

I managed to successfully compile this, hoping this works....

Code: [Select]
//Sends analog values in this format: i.e. {380,148,224,260,45}
uint8_t data[5] = {TopLeft, BottomLeft, TopRight, BottomRight, ElevationAngle};
uint8_t i;

void sendData() {

  for (i = 0; i < 5; i = i++) {
    const uint8_t *peer_addr = slave.peer_addr;
    Serial.print("Sending: "); Serial.println(data[i]);
    esp_err_t result = esp_now_send(peer_addr, &data[i], sizeof(data[i]));
    Serial.print("Send Status: ");
    if (result == ESP_OK) {
      Serial.println("Success");
    } else if (result == ESP_ERR_ESPNOW_NOT_INIT) {
      // How did we get so far!!
      Serial.println("ESPNOW not Init.");
    } else if (result == ESP_ERR_ESPNOW_ARG) {
      Serial.println("Invalid Argument");
    } else if (result == ESP_ERR_ESPNOW_INTERNAL) {
      Serial.println("Internal Error");
    } else if (result == ESP_ERR_ESPNOW_NO_MEM) {
      Serial.println("ESP_ERR_ESPNOW_NO_MEM");
    } else if (result == ESP_ERR_ESPNOW_NOT_FOUND) {
      Serial.println("Peer not found.");
    } else {
      Serial.println("Not sure what happened");
    }
  }
}
Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

knightridar

Hmm.... :(

It didn't work. I should be getting various analog inputs. I can't remember if my angle number was supposed to have a negative value or not. I think I was trying to keep the value from -90 to 90 degrees.

Transmitter side serial output:

Code: [Select]
Last Packet Sent to: 30:ae:a4:f3:14:95
Last Packet Send Status: Delivery Success
Send Status: Success
Sending: 0



Receiver side serial output:
Code: [Select]
Last Packet Recv from: 30:ae:a4:ef:bf:1c
Last Packet Recv Data: 0


Since the code is longer than 9000 characters.
I attached both the transmit and receive codes as separate text files.

Also I extended the delay time to 7000 ms. Above the current millis time of 5000 but the data on the serial monitor keeps being output really fast. I don't get why it's not transmitting every 2 seconds or 7 seconds.

Useful CAD/ 3D model files for
Arduino, hobbyist, and engineering projects

https://grabcad.com/has-2

Go Up