Hello everyone, I am trying to make a connection to the thingspeak server, but I don’t know why it could not get the data to the server correctly.
I use two functions, one to configure the modem and another to send, basically when I call the send function, I give it a temperature value in float format, the problem I think is in this part:
sprintf (http_cmd, "GET https://api.thingspeak.com/update?api_key=%s&field1=%f",Update_Key,value1);
modem.printf (http_cmd);
modem.putc (26); // special "CTRL-Z" character
The code that manipulates the module is:
void ModemInit()
{
wait(4);
uart_debug.printf("Configuring MODEM Telit UL865-NAD");
modem.printf("AT\r\n");
wait(2);
modem.printf("AT+CGDCONT=1,\"IP\",\"web.tmovil.cl\"\r\n");
wait(3);
modem.printf("AT#SGACT=1,1\r\n");
wait(3);
modem.printf("AT&K0\r\n");
wait(3);
//modem.printf("AT#SD=1,0,80,\"api.thingspeak.com\",0,0,1\r\n");
//wait(3);
}
void server_send(float value1)
{
wait(3);
char* Update_Key = "HOA9X7ZGZ0HLJG9N";
char http_cmd[300];
uart_debug.printf("Sending Data to Server ....\r\n");
uart_debug.printf("AT#SD=1,0,80,\"api.thingspeak.com\",0,0,1\r\n");
modem.printf("AT#SD=1,0,80,\"api.thingspeak.com\",0,0,1\r\n"); //Open remote connection trough socket.
wait(3);
uart_debug.printf("AT#SSEND=1\r\n");
modem.printf("AT#SSEND=1\r\n"); //SEnd Data
wait(0.7);
sprintf(http_cmd,"GET https://api.thingspeak.com/update?api_key=%s&field1=%f",Update_Key,value1);
modem.printf(http_cmd);
modem.putc(26); // special "CTRL-Z" character
wait(0.5);
uart_debug.printf("AT#SH=1\r\n");
modem.printf("AT#SH=1\r\n"); //End Connection
wait(0.5);
}
Board : STM32F103 aka Bluepill
Module : Telit UL865-NAD
Regards
Francisco