carrascoacd / ArduinoSIM800L

Arduino HTTP & FTP client for SIM800L/SIM800 boards to perform GET and POST requests to a JSON API as well as FTP uploads.
159 stars 58 forks source link
arduino ftp ftp-client http-client json-api library sim800 sim800l sim900

Donate

Arduino SIM800L library

A smart HTTP & FTP library based on Seeeduino that implements the AT HTTP commands to perform GET and POST requests to a JSON API as well as FTP uploads.

Support

Instalation

Download the ZIP library and then import it: Sketch -> Include Library -> Add .ZIP Library ...

Quick start!

How to do a GET request! :+1:

unsigned int RX_PIN = 7;
unsigned int TX_PIN = 8;
unsigned int RST_PIN = 12;

const char BEARER[] PROGMEM = "gprs-service.com";

HTTP http(9600, RX_PIN, TX_PIN, RST_PIN);
http.connect(BEARER);

char response[256];
Result result = http.get("your.api.com", response);

Serial.println(response);

http.disconnect();

How to do a POST request! :+1:

unsigned int RX_PIN = 7;
unsigned int TX_PIN = 8;
unsigned int RST_PIN = 12;
const char BEARER[] PROGMEM = "gprs-service.com";

HTTP http(9600, RX_PIN, TX_PIN, RST_PIN);
http.connect(BEARER);

char response[256];
Result result = http.post("your.api.com", "{\"date\":\"12345678\"}", response);

Serial.println(response);

http.disconnect();

How to do a FTP upload! :+1:

unsigned int RX_PIN = 7;
unsigned int TX_PIN = 8;
unsigned int RST_PIN = 12;
const char BEARER[] PROGMEM = "gprs-service.com";
const char FTP_SERVER[] PROGMEM = "ftp.server";
const char FTP_USER[] PROGMEM = "user";
const char FTP_PASS[] PROGMEM = "pass";

FTP ftp(9600, RX_PIN, TX_PIN, RST_PIN);
ftp.putBegin(BEARER, "example.txt", FTP_SERVER, FTP_USER, FTP_PASS);
ftp.putWrite("hello!", sizeof("hello!"));
ftp.putEnd();

I suggest the ArduinoJSON library for parsing the JSON response, then you can play with the values easily.

HTTP. How it works?

In order to perform a request, the library follows these steps:

Configure Bearer:
HTTP GET:
HTTP POST:

Future improvements

Development