Desconozco cual es el error por el cual no se actualizan los datos. Adjunto programa. El mismo fue hecho acorde a las modificaciones de Como enviar multiples datos.
#include <SoftwareSerial.h>
#include <String.h>
SoftwareSerial mySerial(2, 3); //your pins to serial communication
int value1 = 0;
int value2 = 0;
//-------------------------------------------------------------
//---------------------Ubidots Configuration-------------------
//-------------------------------------------------------------
String token = “okI7X32zAdV5yU5jDPt3XYYtBOdzaBEEAEDRqbd5SIO22CvfBU7Ux8ZdZfxc”;// Your Ubidots token
String idvariable1 = “55bbefe176254229fb0eeea2”; // Temperatura // Your variable_ID
String idvariable2 = “55bbefed7625422a13471e07”; //Temp
//String token = “YRWsXoUOptheqaDFNT58o65hyHe4m”; //your token to post a value
//String token = “b7f96e49db98c0d7deb651a527a10ee5b8612cc4”;
//okI7X32zAdV5yU5jDPt3XYYtBOdzaBEEAEDRqbd5SIO22CvfBU7Ux8ZdZfxc
//String idvariable = “55b8f87f7625426abdb1fd2f”; //ID of your variable
void setup()
{
mySerial.begin(19200); //the GPRS baud rate
Serial.begin(19200); //the serial communication baud rate
Serial.println(“Starting”);
delay(2000);
}
void loop()
{
value1 = analogRead(A0); //read pin A0 of the Arduino
value2 = analogRead(A1); //read pin A0 of the Arduino
Serial.print("Enviando a Ubidots Value1=");
Serial.println(value1);
Serial.print("Enviando a Ubidots Value2=");
Serial.println(value2);
save_value(String(value1), String(value1)); //call the save_value function
if (mySerial.available())
Serial.write(mySerial.read());
}
//this function is to send the sensor data to Ubidots, you can see the new value in Ubidots after running this function
void save_value(String value1, String value2)
{
int num;
String le;
String var;
//var="{“value”:"+ value + “}”;
var="[{“variable”:" + idvariable1 + “, “value”:” + value1 + “}, {“variable”:” + idvariable2 + “, “value”:” + value2 + “}]”;
num=var.length();
le=String(num);
for(int i = 0;i<7;i++)
{
mySerial.println(“AT+CGATT?”); //this is better made repeatedly because it is unstable
delay(2000);
ShowSerialData();
}
mySerial.println("AT+CSTT=“internet.ctimovil.com.ar”,“clarogprs”,“clarogprs999”); //APN Claro //replace with your providers’ APN
delay(1000);
ShowSerialData();
mySerial.println(“AT+CIICR”); //bring up wireless connection
delay(3000);
ShowSerialData();
mySerial.println(“AT+CIFSR”); //get local IP adress
delay(2000);
ShowSerialData();
mySerial.println(“AT+CIPSPRT=0”);
delay(3000);
ShowSerialData();
mySerial.println("AT+CIPSTART=“tcp”,“things.ubidots.com”,“80"”); //start up connection
delay(3000);
ShowSerialData();
mySerial.println(“AT+CIPSEND”); //begin sendiing data to the remote server
delay(3000);
ShowSerialData();
mySerial.print(“POST /api/v1.6/collections/values/”);
//mySerial.print(“POST /api/v1.6/variables/”+idvariable);
delay(100);
ShowSerialData();
mySerial.println("/values HTTP/1.1");
delay(100);
ShowSerialData();
mySerial.println(“Content-Type: application/json”);
delay(100);
ShowSerialData();
mySerial.println("Content-Length: "+le);
delay(100);
ShowSerialData();
mySerial.print("X-Auth-Token: ");
delay(100);
ShowSerialData();
mySerial.println(token);
delay(100);
ShowSerialData();
mySerial.println(“Host: things.ubidots.com”);
delay(100);
ShowSerialData();
mySerial.println();
delay(100);
ShowSerialData();
mySerial.println(var);
delay(100);
ShowSerialData();
mySerial.println();
delay(100);
ShowSerialData();
mySerial.println((char)26);
delay(7000);
mySerial.println();
ShowSerialData();
mySerial.println(“AT+CIPCLOSE”); //close communication
delay(1000);
ShowSerialData();
}
void ShowSerialData()
{
while(mySerial.available()!=0)
Serial.write(mySerial.read());
}
Datos que muestra el monitoreo de los mismos
AT+CGATT?
+CGATT: 1
OK
AT+CGATT?
+CGATT: 1
OK
AT+CGATT?
+CGATT: 1
OK
AT+CGATT?
+CGATT: 1
OK
AT+CGATT?
+CGATT: 1
OK
AT+CGATT?
+CGATT: 1
OK
AT+CGATT?
+CGATT: 1
OK
AT+CSTT=“internet.ctimovil.com.ar”,“clarogprs”,"clarogprs999
AT+CIICR
ERROR
AT+CIFSR
10.40.15.31
AT+CIPSPRT=0
OK
AT+CIPSTART=“tcp”,“things.ubidots.com”,“80”
OK
CONNECT OKAT+CIPSEND
POST /api/v1.6/collections/values//values HTTP/1.1
Content-Type: application/json
Content-Length: 104
X-Auth-Token: okI7X32zAdV5yU5jDPt3XYYtBOdzaBEEAEDRqbd5SIO22CvfBU7Ux8ZdZfxc
Host: things.ubidots.com
[{“variable”:55bbefe176254229fb0eeea2, “value”:339}, {“variable”
SEND OK
HTTP/1.1 404 NOT FOUND
Server: nginx/1.6.2
Date
AT+CIPCLOSE
CLOSE OK
Enviando a Ubidots Value1=337
Enviando a Ubidots Value2=327
Nota: En esta sentencia no aparece la segunda variable. Solicito ayuda
[{“variable”:55bbefe176254229fb0eeea2, “value”:339}, {“variable”