How to introduce a variable in the get request? "[Variable RFID]


Connect TCP and send GET request.

  1. This example is used to test DFRobot_SIM808 GPS/GPRS/GSM Shield's connect TCP and send GET request.
  2. Open the SIM808_TCPConnection example or copy these code to your project
  3. Download and dial the function switch to Arduino
  4. Open serial helper
  5. Waiting for a few minutes, until serial has sent "Connect success"
  6. Serial will send "Hello world!"

create on 2016/09/23, version: 1.0
by jason
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>

//#define PIN_TX 10
//#define PIN_RX 11
//SoftwareSerial mySerial(PIN_TX,PIN_RX);
//DFRobot_SIM808 sim808(&mySerial);//Connect RX,TX,PWR,

//make sure that the baud rate of SIM900 is 9600!
//you can use the AT Command(AT+IPR=9600) to set it through SerialDebug

DFRobot_SIM808 sim808(&Serial);

char http_cmd[] = "GET /api/agents/[variable RFID] HTTP/1.0\r\n"
"Host: [mode edit, possible spam removed]\r\n"

char buffer[512];

void setup(){

//******** Initialize sim808 module *************
while(!sim808.init()) {
Serial.print("Sim808 init error\r\n");

//*********** Attempt DHCP *******************
while(!sim808.join(F("cmnet"))) {
Serial.println("Sim808 join network error");

//************ Successful DHCP ****************
Serial.print("IP Address is ");

//*********** Establish a TCP connection ************
if(!sim808.connect(TCP,"[mode edit, possible spam removed]", 80)) {
Serial.println("Connect error");
Serial.println("Connect [mode edit, possible spam removed] success");

//*********** Send a GET request *****************
Serial.println("waiting to fetch...");
sim808.send(http_cmd, sizeof(http_cmd)-1);
while (true) {
int ret = sim808.recv(buffer, sizeof(buffer)-1);
if (ret <= 0){
Serial.println("fetch over...");
buffer[ret] = '\0';
Serial.print("Recv: ");
Serial.print(" bytes: ");

//************* Close TCP or UDP connections **********

//*** Disconnect wireless connection, Close Moving Scene *******

void loop(){


code tags?

If you use the sprintf() function to build the string that you will use with the GET then you can include the value of any variables that you need

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