How to make HTTPS Get and Post?

Hello

Is it possible with Ndogo to make HTTPS request?
I have try GPRSBee library and make HTTP GET request, it is OK.
Now I want to make HTTPS GET and POST request to a server. How to proceed?

Thanks for your help.
Best regards
Christian

The GPRSbee library does not have support for https.

It is not clear to me if the SIM900 or SIM800 even has support for it. The SIM900 AT command manual does not describe anything with respect to https. But there is a old (2012) manual floating around with the title “SIM900 HTTPS AT Commands Set V1.00”, however I have no idea if that means it is supported or not, and if so, how.

Not sure if the firmware in the GPRSbee supports it but this document:

SIM800 Series_SSL_Application Note_V1.01

from the SIMCOM website describes the use of HTTPS (you need to create account to download it.)

Weird. I’ve downloaded that “SSL” document. But the title says: “SIM800 Series_Serial Port_Application Note”.

Found it. I had to manually modify the last part of the URL to
SIM800 Series_SSL_Application Note_V1.01.pdf

I have tried the direct AT commands to enable HTTPS mode on the SIM800H. I was able to successfully set the mode and retrieve https://google.com.

However, it is difficult to verify what exactly is going on. I am not very familiar with SSL/TLS, but establishing a connection seems to be quite an involved process. I’m not sure if that process could be handled entirely on the SIM800H itself.

Anyway here is my example work:

I have downloaded the document SSL and tried GabrielNotman code.

To query my server with HTTPS, I must give some key header for this I use the
command AT + HTTPPARAM with USERDATA parameter to give the keys and values.
I cannot find the correct syntax for a “key / value”. I always have an ERROR
in response.

I do not manage to provide several “key / value”.
I want to translate this python syntax in an AT command:

headers = { ‘Key1’: 'key1Value "
‘Key2’: 'key2Value "
‘Content-Type’: ‘application / json’
}

For this, I say these syntaxes still with ERROR response:

ATCommand ("AT + HTTPPARA = " USERDATA \ ", " Key1: key1Value “\ n”);

ATCommand("AT + HTTPPARA = " USERDATA \ ", " Key2 \ ":"key2Value \ “\ n”);

ATCommand("AT + HTTPPARA = " USERDATA \ “”“Content-Type”: “application / json '” ");

ATCommand("AT + HTTPPARA = " USERDATA \ ", " Content-Type: application / json \ “”);

ATCommand("AT + HTTPPARA = " USERDATA \ ", " Content-Type ": " application / json \ “”);

ATCommand(“AT+HTTPPARA=“USERDATA”,“Key1”:“key1Value”;“Key2”:“key2Value”;“Content-Type”:“application/json””);

ATCommand("AT + HTTPPARA = " USERDATA \ ", " Key1 \ “:” key1Value \ "\ n " Key2 \ ": "key2Value "\ n " Content-Type \ ": " request / JSON \ “”);

I sent an email to the SIMCom support and I hope an answer

I post again the same message because there are error with “copy/paste code”
I have downloaded the document SSL and tried GabrielNotman code.

To query my server with HTTPS, I must give some key header for this I use the
command AT + HTTPPARAM with USERDATA parameter to give the keys and values.
I cannot find the correct syntax for a “key / value”. I always have an ERROR
in response.

I do not manage to provide several “key / value”.
I want to translate this python syntax in an AT command:

headers = { ‘Key1’: ‘key1Value’,
‘Key2’: ‘key2Value’,
‘Content-Type’:‘application/json’
}

For this, I say these syntaxes still with ERROR response:

ATCommand(“AT+HTTPPARA=“USERDATA”,“Key1: key1Value”\n”);

ATCommand(“AT+HTTPPARA=“USERDATA”,“Key2”: “key2Value”\n”);

ATCommand(“AT+HTTPPARA=“USERDATA”,”‘Content-Type’: ‘application/json’"");

ATCommand(“AT+HTTPPARA=“USERDATA”,“Content-Type: application/json””);

ATCommand(“AT+HTTPPARA=“USERDATA”,“Content-Type\”: \”application/json””);

ATCommand(“AT+HTTPPARA=“USERDATA”,“Key1”:“key1Value”;“Key2”:“key2Value”;“Content-Type”:“application/json””);

ATCommand(“AT+HTTPPARA=“USERDATA”,“Key1”: “key1Value”\n"Key2”: “key2Value”\n"Content-Type": “application/json”");

I sent an email to the SIMCom support and I hope an answer

The syntax for the “content-type” field is :
ATCommand(“AT+HTTPPARA=“CONTENT”,“application/json””);

I am not able to find a proper syntax for the command AT+HTTPPARA=“USERDATA”. All my tests return ERROR…

My questions :

  1. Does the USERDATA parameter is actually implemented in the firmware of my SIM800H Ndogo card?

An AT+CGMR command returns : Revision:1308B06SIM800H32
2) Is it the last SIM800H firmware ? I do not find information on SIMCom web site.

  1. If the firmware is not good, is it possible to update the firmware on my SIM800H Ndogo, if so how to proceed?

Hi Christian,

I have in the past tried to add additional headers for HTTP actions on the Sim900/800H. I could not find a way to achieve this using the built in HTTP stack. My conclusion was that only a limited set of headers are supported. I not sure I tried the USERDATA option as it doesn’t appear in earlier revisions of the AT Commands manual.

If I remember correctly, certain commands require a previous sequence. A call to AT+HTTPINIT might be needed first. If you were able to set the content-type header, then you are probably at the correct point in the sequence.

My previous solution to this issue was to just open a TCP socket and format the HTTP request manually.

Hi GabrielNotman,

I have a SIMCom support response concerning my initial request: How to write two “key/value” in an USERDATA command.
SIMCom have made some test and found error if “;” is use in the command.

Dear Christian:
Nice to know you! Happy New Year!
Can you let me know where you buy the SIM800H samples?
For the problem, we have tested it and find that there is indeed a problem in case of the content of userdata has “;” inside.
So, we plan to add a “” ahead of the “;”, is it OK for you?
BTW, I am not sure there must be this “;” in the USERDATA for your HTTP server, from our point of view, it should be \r\n instead.
Meanwhile, for the Content-type, you can use AT+HTTPPARA to set this parameter directly,
no need to set it via USERDATA. Use “CONTENT” to fix “Content-Type”.

I have to send a new email to SIMCom: How to write an USERDATA command will only ONE “key/value”.
I have no response concerning this, but SIMCom ask me if I want to test a new firmware with the";" correction.

Hello Christian:
I am not familiar with the code from the link, but as I said in last Email, we plan to add a “” ahead of the “;”, is it OK for you?
In previous FW, the “;” will be treated as a separateed symbol between two AT commands, so the USERDATA can’t be delivered correctly to the HTTP server.
Would you like to test with our new FW?
If it is OK, I will ask our R&D to prepare it, please let me know, thanks!

I can test it but my question: How to update the SIM800H firmware on the NDogo card? Is it possible?

I believe the firmware is updated using the USB pins for the Sim800 module.
These are connected to the main break out headers and are labelled D+, D- and VBUS.
The Ndogo schema can be found here: http://ndogo.sodaq.net/schema-rev-2/

I am not familiar with the update process and I haven’t attempted it myself.
As with any firmware update care must be taken to ensure that the process is completed correctly.

Hi GabrielNotman

SIMCom have send me a new firmware “Revision:1308B09SIM800H32” with a GUI tools to upgrade the SIM800H and the associated documentation.
To ugrade the SIM800H, it is necessary to manage the SIM800H power pins like this:

  1. Put PRWKEY pin to LOW
  2. Click on “Start button” on the SIMCom GUI application, then put VBAT pin to HIGH and the frmware downloading starts. Waiting until the end.

I have seen the NDogo schema and made the following synotic:

To manage the SIM800H power pins, I have made the following program:

void setup()
{
//Start Serial ports
Serial.begin(115200);
Serial1.begin(115200);

//Intialise the GPRSbee
gprsbee.initNdogoSIM800(Serial1, SIM800PWRKEY, SIM800VBAT, SIM800STATUS);

//Setup debugging
gprsbee.setDiag(Serial);
delay(10000);
Serial.println(“Hello”);

Serial.println(“PWRKEY LOW”);
digitalWrite(SIM800PWRKEY, LOW);

Serial.println(“Close Arduino monitor console’”);
Serial.println(“You have 30s to click on ‘Start Download’ button on SIMCom GUI application”);
delay(30000);

// Serial.println(“SIM800VBAT HIGH”);
digitalWrite(SIM800VBAT, HIGH);
}

void loop()
{
}

I prepare the SIMCom GUI application.
I launch the above Arduino program and wait the message.
I close the Arduino monitor console and click on the “Start Download” button on SIMCom application.
But the downloding never start.

I have a doubt over my procedure to manage supply pins . Is something missing?

Thanks for your help.
Best regards
Christian

I believe there are two sets of USB pins:

Labelled: D+, D- which connect the USB header to the FTDI chip.
Labelled: S8_D+, S8_D- which connect from the header pins (JP2) to the Sim800H module.

It appears that you are trying to program it over the USB lines connected to the FTDI.

OK I made a mistake on my schematic. Here is the right schema.

I have a question: can I connect the VMBus pin (5V) from the USB connector to the SIM800H pin? Is there a risk of double supply?

I have asked this question to SIMCom; here is the answer:

Hi Christian:
I am not sure the schematic design of the board from SODAQ, but my suggestion would be:

  1. Cut off the power/batery on SODAQ board, connect SIM800H to your PC through USB connector
  1. PWRKEY of SIM800H connected to GND directly
  1. Open SIM800H flash update tool on your PC, click download
  1. Apply separate Power to the VBAT of SIM800H, then the update process will start automatically, wait until the updating finished.

To follow the SIMCom recommendation, the problem is that the VBAT pin and the PWRKEY SIM800H are not accessible on JP1 and JP2 connectors.

VBAT exist on JP1 connector but it is not direct to SIM800H chip. PWRKEY and VBAT on SIM800H are controled by transistor by the ATMEL1284. D23 and D18 pins are not directly accessible.

What you suggest me?
Can I proceed as indicated in my schema ? No double supply risk?
I prefer to ask the question to avoid crashing my board or SIM800H.

There are some details on page 33 of the datasheet:

It seems there is also the option to do it over the UART as well.

EUREKA

I have updated my SIM800H on my NDogo card with the last SIMCom firmware (Revision:1308B09SIM800H32) and now I can use USERDATA parameter to send my authentication keys for HTTPS GET and POST request.
The initial SIM800H firmware (Revision:1308B06SIM800H32) do not have the USERDATA parameter implemented.

To update SIM800H, I use the above schema with GND, D+, D- and VBUS connected.
I fix the power with the following sketch:

include GPRSbee.h

void setup()
{
//Start Serial ports
Serial.begin(115200);
Serial1.begin(115200);

//Intialise the GPRSbee
gprsbee.initNdogoSIM800(Serial1, SIM800PWRKEY, SIM800VBAT, SIM800STATUS);

//Setup debugging
gprsbee.setDiag(Serial);
delay(5000);

Serial.println(“PWRKEY HIGH”);
digitalWrite(SIM800PWRKEY, HIGH);
// Wait a little
delay(2);
Serial.println(“SIM800VBAT HIGH”);
digitalWrite(SIM800VBAT, HIGH);
Serial.println(“PWRKEY LOW”);
delay(2500);
digitalWrite(SIM800PWRKEY, LOW);
}

void loop()
{
}

Then I launch the SIMCom update firmware utility. I had a lot of trouble to update the firmware, I have mad more and more tries.
At this end, I have the last SIM800H firmware.

To make HTTPS GET and POST request, I use the command AT+HTTPPARA=“USERDATA” to fix my two authentication keys.
Here the sketch that I have used to test.

include Wire.h
include GPRSbee.h

define APN “my provider Apn”

define NORMAL_PREFIX “http://”
define SECURE_PREFIX “https://”
define URL_GET “my server Url for Get”
define URL_POST “my server Url for Post”

define TEMPO2 2000

define TEMPO5 5000
define TEMPO8 8000
define TEMPO10 10000
define TEMPO20 20000
define TEMPO30 20000

void setup()

{
//Start Serial ports
Serial.begin(57600);
Serial1.begin(57600);

//Intialise the GPRSbee
#ifdef ARDUINO_AVR_SODAQ_NDOGO
gprsbee.initNdogoSIM800(Serial1, SIM800PWRKEY, SIM800VBAT, SIM800STATUS);
#endif
#ifdef ARDUINO_AVR_SODAQ_MBILI
gprsbee.init(Serial1, BEECTS, BEEDTR);
gprsbee.setPowerSwitchedOnOff(true);
#endif

//Setup debugging
gprsbee.setDiag(Serial);

//Run HTTPS GET test
HTTPSGetTest(); // OK

//Run HTTPS POST test
HTTPSPostTest(); // OK
}

void loop()
{
}

void ATCommand(String _command, int _waitDelay = TEMPO5)
{
float delaySecs = (float)_waitDelay / 1000.0f;
Serial.println(“Sending AT Command, waiting " + String(delaySecs) + " seconds for a response”);
gprsbee.sendCommandWaitForOK(_command.c_str(), _waitDelay);
delay(_waitDelay);
}

// My authentication Keys for HTTPS request
define ValueKey1 “ValueKey1”
define ValueKey2 “ValueKey2”

void HTTPSGetTest()
{
gprsbee.on();
delay(TEMPO8);

//Initialise the GPRS connection
ATCommand("ATE0");

// ATCommand("AT+CGMR");  // Firmware version

ATCommand("AT+SAPBR=3,1,\"Contype\",\"GPRS\"");
ATCommand("AT+SAPBR=3,1,\"APN\",\"" + String(APN) + "\"");
ATCommand("AT+SAPBR=1,1"); 
ATCommand("AT+SAPBR=2,1"); 

//Try HTTPS GET
ATCommand("AT+HTTPINIT");
ATCommand("AT+HTTPPARA=\"CID\",1"); 
ATCommand("AT+HTTPPARA=\"URL\",\"" + String(SECURE_PREFIX) + String(URL_GET) +"\""); 
ATCommand("AT+HTTPPARA=\"REDIR\",1");

// -- 
ATCommand("AT+HTTPPARA=\"USERDATA\",\"NameKey1: " + String(ValueKey1) + "\\r\\nNameKey2: " + String(ValueKey2) +"\"");
ATCommand("AT+HTTPPARA=\"CONTENT\",\"application/json\"");  

//ATCommand("AT+HTTPPARA?");  // To see all the parameters

// ---
ATCommand("AT+HTTPSSL=1");
ATCommand("AT+HTTPSSL?");
ATCommand("AT+HTTPACTION=0", TEMPO20);  // GET
ATCommand("AT+HTTPREAD", TEMPO20);

//Terminate HTTP & GPRS and then switch off
ATCommand("AT+HTTPTERM"); 
ATCommand("AT+SAPBR=0,1"); 
gprsbee.off();

}

void HTTPSPostTest()
{
gprsbee.on();
delay(TEMPO8);

//Initialise the GPRS connection
ATCommand("ATE0");

// ATCommand("AT+CGMR");  // Get Firmware version

ATCommand("AT+SAPBR=3,1,\"Contype\",\"GPRS\"");
ATCommand("AT+SAPBR=3,1,\"APN\",\"" + String(APN) + "\"");
ATCommand("AT+SAPBR=1,1"); 
ATCommand("AT+SAPBR=2,1"); 

//Try HTTPS POST
ATCommand("AT+HTTPINIT");
ATCommand("AT+HTTPPARA=\"CID\",1"); 
ATCommand("AT+HTTPPARA=\"URL\",\"" + String(SECURE_PREFIX) + String(URL_POST) +"\""); 
ATCommand("AT+HTTPPARA=\"REDIR\",1");

// -- 
ATCommand("AT+HTTPPARA=\"USERDATA\",\"NameKey1: " + String(ValueKey1) + "\\r\\nNameKey2: " + String(ValueKey2) +"\"");
ATCommand("AT+HTTPPARA=\"CONTENT\",\"application/json\"");  

//ATCommand("AT+HTTPPARA?");  // To see all the parameters

// ---
ATCommand("AT+HTTPSSL=1");
//ATCommand("AT+HTTPSSL?");
// Prepare the POST : We have a JSON structure of 18 characters to send and we fix the timing to 12s
// This line and the next command lines must be realized before the timeout indicated in the command, here 12s.
ATCommand("AT+HTTPDATA=18,12000", TEMPO5);  
// Send structure JSON in the body when DOWNLOAD is received
ATCommand("[{ \"value\": 987 }]", TEMPO2);  // JSON structure of 18 characters to send to the server
// The 2 above lines must be realized before 12s to avoid error message like "JSON structure empty"
// See information here : http://stackoverflow.com/questions/33346425/sim800-at-command-post-data-to-server
ATCommand("AT+HTTPACTION=1", TEMPO10);   // POST
ATCommand("AT+HTTPREAD", TEMPO10);

//Terminate HTTP & GPRS and then switch off
ATCommand("AT+HTTPTERM"); 
ATCommand("AT+SAPBR=0,1"); 
gprsbee.off();

}

Now, all is OK for me.

Hi,

Can you provide the email on which we have to contact simcom, to get the latest firmware? We are facing the same problem and after reading your thread we concluded that the module we are using (SIM800) have the firmware 1308B02SIM800M64 which did not implemented the “USERDATA parameter to send my authentication keys” Please help.

Hi,

Initially I have contacted SIMCOM from their web site : http://simcomm2m.com/En/service/ask.aspx . Then an enginner contact me.

Today, I have make a search on Google.
You have some information to update the SIM800 with the updater tool here : http://www.raviyp.com/embedded/214-learn-how-to-update-the-firmware-of-your-sim800-modules
And you can upload the firmware 1308B09SIM800H32 from : http://dostmuhammad.com/blog/sim800-series-firmware-update-appnotes/ . There are also more other firmwares perhap more recent.
I have not try these links.