Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 8 months ago.
sending data using gsm800 over http
hi, i am trying to send data with gsm800 module over http to a website called ubidots. it is a free server for iot platform. The data is not being sent cause of some coding error which i am not able to rectify, still all at commands give OK reply .
code:
- include "mbed.h"
Serial Serial6(PC_10,PC_11); Serial pc(USBTX,USBRX);
char token[] = "QLh2wKPuem2U39JXwMDTlXkkmgkGT3"; your token to post value char idvariable[] = "58a301db76254267f49cb565"; ID of your variable
void message_reply() { if (Serial6.readable()) { pc.putc(Serial6.getc()); } if(pc.readable()) { Serial6.putc(pc.getc()); }
}
void init_setup() {
Serial6.puts("AT\r"); message_reply();
Serial6.puts("AT+CGATT=1\r"); message_reply(); Serial6.puts("AT+SAPBR=3,1,\"Contype\",\"GPRS\"\r"); message_reply(); Serial6.puts("AT+SAPBR=3,1,\"APN\",\"www\"\r");
message_reply(); Serial6.puts("AT+SAPBR =1,1\r");
message_reply();
for (int i=0;i<15;i++) { Serial6.puts("AT+SAPBR=2,1\r"); }
message_reply();
Serial6.puts("AT+HTTPINIT\r"); message_reply(); Serial6.puts("AT+HTTPPARA=\"CID\",1\r"); message_reply(); Serial6.puts("AT+HTTPPARA=\"URL\",\"https://things.ubidots.com/api/v1.6/variables\"\r"); message_reply();
Serial6.puts(idvariable); message_reply();
Serial6.puts("X-Auth-Token:"); message_reply();
Serial6.puts(token); message_reply();
Serial6.puts("&page_size=1\r"); message_reply();
Serial6.puts("AT+HTTPPARA=\"CONTENT\",\"application/json\"\r"); message_reply();
Serial6.puts("")
Serial6.puts("AT+HTTPDATA=192,10000\r"); message_reply();
Serial6.puts("AT+HTTPACTION=1\r"); message_reply();
Serial6.puts("AT+HTTPREAD\r"); message_reply();
Serial6.puts("AT+HTTPTERM\r"); message_reply(); }
int main () { pc.baud(9600); Serial6.baud(9600);
init_setup();
while (1) { message_reply(); }
}