send euler angles

I'm relatively new to Arduino and coding but for a project, I need to send MPU6050 data over nrf24 radio modules.
the code I have is pieced together using examples but unable to get it function, the part that I'm struggling with is the euler[0], which will not allow me to send over.

transmitter code.

 mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetEuler(euler, &q);
            Serial.print("euler\t");
            Serial.print(euler[0] * 180/M_PI);
            Serial.print("\t");
            Serial.print(euler[1] * 180/M_PI);
            Serial.print("\t");
            Serial.println(euler[2] * 180/M_PI);
         
                //send to reciever start here
            radio.write(&euler[0], sizeof(euler[0]));
            radio.write(&euler[1], sizeof(euler[1]));

Receiver code.

  delay(5);
  radio.startListening();
  if ( radio.available()) {
    while (radio.available()) {
      digitalWrite(gLed, HIGH);
      int euler[0] = 0;
      int euler[1] = 0;
      radio.read(&euler[0], sizeof(euler[0]));
      radio.read(&euler[1], sizeof(euler[1]));
      myServo1.write(euler[0]);
      myServo2.write(euler[1]);
    }
    delay(5);
    radio.stopListening();
receiver:34: error: array must be initialized with a brace-enclosed initializer

       int euler[0] = 0;

                      ^

receiver:35: error: conflicting declaration 'int euler [1]'

       int euler[1] = 0;

                  ^

C:\Users\Ricky Burton\Desktop\transmitter\receiver\receiver.ino:34:11: note: previous declaration as 'int euler [0]'

       int euler[0] = 0;

           ^

and this is the error received i am assuming its to do with the brackets

 int euler[2] = {0, 0}; //create the array
      

//put things into it
 euler[0] = 5*5;
 euler[1] = 9766;

Thank you,

the new code is

void loop() {
  delay(5);
  radio.startListening();
  if ( radio.available()) {
    while (radio.available()) {
      digitalWrite(gLed, HIGH);
      int euler[2] = {0,0};
      
      radio.read(&euler[0], sizeof(euler[0]));
      radio.read(&euler[1], sizeof(euler[1]));
      myServo1.write(euler[0]);
      myServo2.write(euler[1]);
    }
    delay(5);
    radio.stopListening();

and it compiles, but can you explain is it an array and by adding [2] it bring the two lines of data?

In the receive code, just enclose the initialized value with {}

int euler[0] = {0};

Also, you cannot have 2 variables with the same name in the same scope.

      int eulerX[0] = {0};
      int eulerY[1] = {0};

the problem is on the transmitter code its

euler[0]
euler[1]
euler[2]

so by changing it to eulerx[0] and eulery[1]

would that break the code?

MakeMyIdeas:
the problem is on the transmitter code its

euler[0]
euler[1]
euler[2]

so by changing it to eulerx[0] and eulery[1]

would that break the code?

How did you declare "euler"?
Post the whole code if you are not sure.

#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#include "MPU6050.h"
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

MPU6050 mpu;

#define led 12
#define LED_PIN 8
#define gLed 9

#define OUTPUT_READABLE_EULER
//#define OUTPUT_READABLE_YAWPITCHROLL


bool blinkState = false;

RF24 radio(7, 8); // CE, CSN
const byte address[6] = {"00001"};

bool dmpReady = false;  // set true if DMP init was successful
uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU
uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)
uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)
uint16_t fifoCount;     // count of all bytes currently in FIFO
uint8_t fifoBuffer[64]; // FIFO storage buffer

// orientation/motion vars
Quaternion q;           // [w, x, y, z]         quaternion container
VectorInt16 aa;         // [x, y, z]            accel sensor measurements
VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements
VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements
VectorFloat gravity;    // [x, y, z]            gravity vector
float euler[3];         // [psi, theta, phi]    Euler angle container
float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector

// packet structure for InvenSense teapot demo
//uint8_t teapotPacket[14] = { '

, 0x02, 0,0, 0,0, 0,0, 0,0, 0x00, 0x00, ‘\r’, ‘\n’ };
volatile bool mpuInterrupt = false;    // indicates whether MPU interrupt pin has gone high
void dmpDataReady() {
    mpuInterrupt = true;
}

void setup() {
  pinMode(12, OUTPUT);
  pinMode(9, OUTPUT);
  radio.begin();
  radio.openWritingPipe(address); // 00001
  radio.setPALevel(RF24_PA_MIN);
  // join I2C bus (I2Cdev library doesn’t do this automatically)
    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
        Wire.begin();
        TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz)
    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
        Fastwire::setup(400, true);
    #endif

// initialize serial communication
    // (115200 chosen because it is required for Teapot Demo output, but it’s
    // really up to you depending on your project)
    Serial.begin(115200);
    while (!Serial); // wait for Leonardo enumeration, others continue immediately

// NOTE: 8MHz or slower host processors, like the Teensy @ 3.3v or Ardunio
    // Pro Mini running at 3.3v, cannot handle this baud rate reliably due to
    // the baud timing being too misaligned with processor ticks. You must use
    // 38400 or slower in these cases, or use some kind of external separate
    // crystal solution for the UART timer.

// initialize device
    Serial.println(F(“Initializing I2C devices…”));
    mpu.initialize();

// verify connection
    Serial.println(F(“Testing device connections…”));
    Serial.println(mpu.testConnection() ? F(“MPU6050 connection successful”) : F(“MPU6050 connection failed”));

// wait for ready
    Serial.println(F("\nSend any character to begin DMP programming and demo: "));
    while (Serial.available() && Serial.read()); // empty buffer
    while (!Serial.available());                // wait for data
    while (Serial.available() && Serial.read()); // empty buffer again

// load and configure the DMP
    Serial.println(F(“Initializing DMP…”));
    devStatus = mpu.dmpInitialize();

// supply your own gyro offsets here, scaled for min sensitivity
    mpu.setXGyroOffset(220);
    mpu.setYGyroOffset(76);
    mpu.setZGyroOffset(-85);
    mpu.setZAccelOffset(1788); // 1688 factory default for my test chip

// make sure it worked (returns 0 if so)
    if (devStatus == 0) {
        // turn on the DMP, now that it’s ready
        Serial.println(F(“Enabling DMP…”));
        mpu.setDMPEnabled(true);

// enable Arduino interrupt detection
        Serial.println(F(“Enabling interrupt detection (Arduino external interrupt 0)…”));
        attachInterrupt(0, dmpDataReady, RISING);
        mpuIntStatus = mpu.getIntStatus();

// set our DMP Ready flag so the main loop() function knows it’s okay to use it
        Serial.println(F(“DMP ready! Waiting for first interrupt…”));
        dmpReady = true;

// get expected DMP packet size for later comparison
        packetSize = mpu.dmpGetFIFOPacketSize();
    } else {
        // ERROR!
        // 1 = initial memory load failed
        // 2 = DMP configuration updates failed
        // (if it’s going to break, usually the code will be 1)
        Serial.print(F(“DMP Initialization failed (code “));
        Serial.print(devStatus);
        Serial.println(F(”)”));
    }

// configure LED for output
    pinMode(LED_PIN, OUTPUT);
    digitalWrite(led, HIGH);//set led on
      delay(1000);
    digitalWrite(led, LOW);//set led off
      delay(1000);
    digitalWrite(led, HIGH);//set led on indication of power on.
}
void loop() {
  delay(5);
  radio.stopListening();
  delay(5);
  radio.startListening();
  while (!radio.available());

digitalWrite(gLed, HIGH);
 
  // if programming failed, don’t try to do anything
    if (!dmpReady) return;

// wait for MPU interrupt or extra packet(s) available
    while (!mpuInterrupt && fifoCount < packetSize) {
        // other program behavior stuff here
        // .
        // .
        // .
        // if you are really paranoid you can frequently test in between other
        // stuff to see if mpuInterrupt is true, and if so, “break;” from the
        // while() loop to immediately process the MPU data
        // .
        // .
        // .
    }

// reset interrupt flag and get INT_STATUS byte
    mpuInterrupt = false;
    mpuIntStatus = mpu.getIntStatus();

// get current FIFO count
    fifoCount = mpu.getFIFOCount();

// check for overflow (this should never happen unless our code is too inefficient)
    if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
        // reset so we can continue cleanly
        mpu.resetFIFO();
        Serial.println(F(“FIFO overflow!”));

// otherwise, check for DMP data ready interrupt (this should happen frequently)
    } else if (mpuIntStatus & 0x02) {
        // wait for correct available data length, should be a VERY short wait
        while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();

// read a packet from FIFO
        mpu.getFIFOBytes(fifoBuffer, packetSize);
       
        // track FIFO count here in case there is > 1 packet available
        // (this lets us immediately read more without waiting for an interrupt)
        fifoCount -= packetSize;

#ifdef OUTPUT_READABLE_EULER
            // display Euler angles in degrees
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetEuler(euler, &q);
            Serial.print(“euler\t”);
            Serial.print(euler[0] * 180/M_PI);
            Serial.print("\t");
            Serial.print(euler[1] * 180/M_PI);
            Serial.print("\t");
            Serial.println(euler[2] * 180/M_PI);
       
                //send to reciever start here
            radio.write(&euler[0], sizeof(euler[0]));
            radio.write(&euler[1], sizeof(euler[1]));
        #endif

//        #ifdef OUTPUT_READABLE_YAWPITCHROLL
//            // display Euler angles in degrees
//            mpu.dmpGetQuaternion(&q, fifoBuffer);
//            mpu.dmpGetGravity(&gravity, &q);
//            mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
//            Serial.print(“ypr\t”);
//            Serial.print(ypr[0] * 180/M_PI);
//            Serial.print("\t");
//            Serial.print(ypr[1] * 180/M_PI);
//            Serial.print("\t");
//            Serial.println(ypr[2] * 180/M_PI);
//        #endif

// blink LED to indicate activity
        blinkState = !blinkState;
        digitalWrite(LED_PIN, blinkState);
  }
}

Transmit code is fine, don't change anything.

Since "euler" is an array of float, you need to change in Receive code:

      float euler[2] = {0,0};
     
      radio.read(&euler[0], sizeof(euler[0]));
      radio.read(&euler[1], sizeof(euler[1]));

Thank you I will change now I will get my head around all this.

when defining the variable, the value inside the brackets specified it's size.

int euler [0]