3

Can somebody help me?

I have problems sending data from a SIM800C to a website.

The first problem is, I uploaded the following code to Arduino (I use the Serial Monitor in Arduino IDE to send AT commands to the SIM800 and read the response).

#include <SoftwareSerial.h>

#define TX 10
#define RX 11
#define t 2000

SoftwareSerial mySerial(RX, TX);
int k=0, aS=0, amS=0;

void setup() {
  Serial.begin(9600);
  while(!Serial); // Wait for Serial ready
  Serial.println("Intalizing...");
  mySerial.begin(9600);
  delay(5000);
  mySerial.println("AT"); // Send the first AT command to auto set baud rate
  delay(1000);
  Serial.println("You can type AT command and send to SIM800 by using Serial Monitor");
}

void loop() {
  k=0;
  aS=Serial.available();  // aS: The number of bytes available to read from the buff of Serial
  amS=mySerial.available(); // amS: The number of bytes available to read from the buff of mySerial
  while(aS>0) {
    mySerial.write(Serial.read());
    k=1; aS--;
  }
  if (k==1) {
    mySerial.println();
  }
  while (amS>0) {
    Serial.write(mySerial.read());
    k=2; amS--;
  }
  delay(1000);
}

Next, I send the AT commands below one by one and viewed responses. All the AT commands and responses can be seen on the Serial Monitor.

AT+SAPBR=3,1,"Contype","GPRS"
AT+SAPBR=3,1,"APN","m3-world"
AT+SAPBR=3,1,"USER","mms"
AT+SAPBR=3,1,"PWD","mms"
AT+CSTT="m3-world","mms","mms"
AT+SAPBR=1,1
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","http://weatherstation.byethost3.com/"
AT+HTTPDATA=9,10000
value=YOU
AT+HTTPACTION=1

The last response below shows that the data (value=YOU) have been sent successfully.

OK
++HTTPACTION:1,200,839

I have created a website to read data with the GET method. My problem is nothing changes on the website. That means the website has not read the data sent from the SIM800 yet.

dda
  • 6,030
  • 2
  • 25
  • 34
Huy Nguyen
  • 31
  • 1
  • 5

1 Answers1

0

Your example is sending a POST request. If you would like to send a GET request with a name/value pair, it should be structured a little differently. Changing your example from above:

AT+SAPBR=3,1,"CONTYPE","GPRS"
AT+SAPBR=3,1,"APN","m3-world"
AT+SAPBR=3,1,"USER","mms"
AT+SAPBR=3,1,"PWD","mms"
AT+SAPBR=1,1
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","http://weatherstation.byethost3.com/?value=YOU"
AT+HTTPACTION=0

Note the name/value pair is in the URL now and AT+HTTPACTION=1 is changed to AT+HTTPACTION=0 to indicate GET instead of POST

skot9000
  • 11
  • 3
  • Thanks for your answer. I got this problem. My problem is my server blocked all IP access, so I change to another server. Every thing are all right. – Huy Nguyen Feb 22 '18 at 00:54
  • 1
    This is the proper sequence for HTTP GET on a SIM800 in case anyone else finds themselves here. Just make sure your modem is registered with the gsm network first. – skot9000 Mar 13 '18 at 20:40