Error Serial.println

Hola,
Tengo 3 sensores: uno que mide la rotación, otro que mide el desplazamiento y otro que mide la apertura de unas pinzas y necesito enviar a Unity 3 valores (grados de rotacion, mm de desplazamiento, y grados de apertura) a través del puerto serie pero no soy capaz ya que me sale el siguiente error:

Sensorizacion:42:36: error: invalid operands of types 'const char [17]' and 'const char [2]' to binary 'operator+'
String data = "rotation_degrees" + "," + "deep_measure" + "," + "opening_degrees";
~~~~~~~~~~~~~~~^
exit status 1
invalid operands of types 'const char [17]' and 'const char [2]' to binary 'operator+'

Este es el código que estoy utilizando:

#include <AS5311.h>
#include <AS5040.h>

// OUTPUT PINS
#define enc_step 6
#define enc_dir  7
#define enc_z    8


AS5040 enc(3,2,4,5); //(CLKpin, CSpin, DOpin, PROGpin) 
AS5311 myAS5311(4,3,1,5); //(D0pin, CLKpin, CSpin, INDEXpin) 

int rotation_degrees = 0;
long deep_measure = 0;
float opening_degrees = 0;

const int FLEX_PIN = A1;

const float VCC = 5; 
const float R_DIV = 20000.0;

const float STRAIGHT_RESISTANCE = 9500.0;
const float BEND_RESISTANCE = 70000.0;


void setup ()
{
  //GIRO
  Serial.begin (115200) ;   // NOTE BAUD RATE
  if (!enc.begin (AS5040_STEPDIR | AS5040_8BIT))  // set to 8 bits (7 to 10 is the range)
    Serial.println ("Error setting up AS5040") ;
  //APERTURA
  pinMode(FLEX_PIN, INPUT);
}

void loop ()
{ 
  rotation();
  deep();
  opening();
  
  String data = rotation_degrees + "," + deep_measure + "," + opening_degrees;
  Serial.println(data);
 
  delay (50) ;
}

void rotation(){
  if(enc.valid()){
    rotation_degrees = enc.read()*360/1024;
  }else{
    rotation_degrees = -1;
  } 
 
  }

void deep(){
  deep_measure = myAS5311.encoder_value(); 

  }

void opening(){
    int flexADC = analogRead(FLEX_PIN);
    float flexV = flexADC * VCC / 1023.0;
    float flexR = R_DIV * (VCC / flexV - 1.0);

    opening_degrees = map(flexR, STRAIGHT_RESISTANCE, BEND_RESISTANCE,
                   0, 180.0);

  }

¿Sabéis cómo solucionarlo?

Gracias.

No habla espanol mucho, pero;

no necesito


String data = rotation_degrees + "," + deep_measure + "," + opening_degrees;
  Serial.println(data);

pruebo esto

Serial.print(rotation_degrees);  Serial.print(" , "); Serial.print(deep_measure); Serial.print(" , "); Serial.println(opening_degrees);
  
String data = String(rotation_degrees) + String(",") + String(deep_measure) + String(",") + String(opening_degrees);
String data;
data = rotation_degrees;
data += ',';
data += deep_measure;
etc

Evita muchas creaciones de cuerdas pequeñas.
Si está utilizando Strings, consulte mi tutorial sobre
Taming Arduino Strings

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