[SOLVED] Envío de varios datos a una sola variable con Linkit one

Hola!

Necesito enviar varios datos a una sola variable y graficarlos en una misma petición, pero no recibo ningún dato, por favor podrían ayudarme? Este es el código que tengo:

void setup()
{
LTask.begin();
Serial.begin(115200); // setup Serial port
pinMode(13, OUTPUT);
Serial.println(“Attach to GPRS network”); // Attach to GPRS network - need to add timeout
while (!LGPRS.attachGPRS(“internet.comcel.com.co”,"","")) {
delay(500);
}
Serial.println(“GPRS attached!”);
delay(500);
ads1115.begin();

}

void loop(){

uploadAccelerations();
}

void uploadAccelerations(){

LGPRSClient c;
String vol=readadc();

String payload = “{“value”:”+ vol + “}”;
String le = String(payload.length());
Serial.println(payload);

  if(!c.connected()){
    while (!c.connect(URL, 8080)){
      delay(100);
    }
    Serial.println("Client reconnected!");
  } 


  // Build HTTP POST request
  c.print(F("POST /api/v1.6/variables/"));
  c.print(VARID1);
  c.println(F("/values HTTP/1.1"));
  c.println(F("User-Agent: LinKit One/1.0"));
  c.print(F("X-Auth-Token: "));
  c.println(TOKEN);
  c.println(F("Connection: close"));
  c.println(F("Content-Type: application/json"));
  c.print(F("Content-Length: "));
  c.println(le);
  c.print(F("Host: "));
  c.println(URL);
  c.println(); 
  c.println(payload);
  c.println(); 

  int v;
  while(c.available()){  
    v = c.read();
    if(v < 0){
      Serial.println("No response.");
      break;
    }
    //Serial.print((char)v);
  }
  delay(1000);

}

String readadc(){
String dataString = “”;
for(int i=0;i<50;i++){
int16_t adc0 = ads1115.readADC_SingleEnded(0);
input = (adc0 * 0.1875)/1000;
dataString += String(input);
dataString += String("\n");
}
return dataString;
}

Here’s an MQTT example that’s working for me! it sends three variables. You need to install the PubSubClient library first (https://github.com/knolleary/pubsubclient).

#include <LGPRS.h>      //include the base GPRS library
#include <LGPRSClient.h>  //include the ability to Post and Get information using HTTP
#include <PubSubClient.h>

// These are the variables you will want to change based on your IOT data streaming account / provider

#define TOPIC "/v1.6/devices/linkit-one"

char payload[180];  // Reserve a char to store the Ubidots data. Account for 60 bytes per variable. 
char le[4];
char mqttBroker[] = "things.ubidots.com";
String response;
LGPRSClient GPRSclient;
PubSubClient client(GPRSclient);


void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("linkit-one","TOKENUBIDOTS","")) {
      Serial.println("connected");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

void setup()
{
  Serial.begin(115200);             // setup Serial port
  pinMode(13, OUTPUT);
  Serial.println("Attach to GPRS network");   // Attach to GPRS network - need to add timeout
  while (!LGPRS.attachGPRS("apn.konekt.io","","")) {
    delay(500);
  }
  Serial.println("GPRS attached!");
  client.setServer(mqttBroker, 1883);
  delay(10000);

}

void loop(){
  int temp = analogRead(A0);
  int ph = analogRead(A1);
  int orp = analogRead(A2);

  sprintf(payload,"%s", "{\"temperature\":");
  sprintf(payload,"%s%d", payload, temp);
  sprintf(payload,"%s%s", payload, ",\"ph\":");
  sprintf(payload,"%s%d", payload, ph);
  sprintf(payload,"%s%s", payload, ",\"orp\":");
  sprintf(payload,"%s%d", payload, orp);
  sprintf(payload,"%s%s", payload, "}");
  Serial.println(payload);
  
  if (!client.connected()) {
    reconnect();
  }
  client.publish(TOPIC, payload);
  client.loop();
  
  delay(1000);
}