Skip to content

An ESP32 library to facilitate the execution of HTTP requests ๐ŸŒ

License

Notifications You must be signed in to change notification settings

petruspierre/EasyHTTP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

EasyHTTP

An ESP32 library to facilitate the execution of HTTP requests ๐ŸŒ

Summary

Getting started

Installation

First you need to install this library. So follow the steps:

Manual installation

  • Download this repository in .ZIP format by clicking here
  • Copy the directory inside and paste in your libraries folder (usually located in /Documents/Arduino/libraries)
  • Open your Library Manager Tools > Include Libraries > Manage Libraries...
  • Search for ArduinoJSON and install it

Using library manager

  • Not available yet

Setting it up

After install it, you have to include EasyHTTP in your project

#include <EasyHTTP.h>

[...]

Setup network constants to work with

[...]

char* ssid = "Your SSID here"; // SSID is your WiFi name
char* password = "Your password";

String baseURL = "http://yourapiurl.com"; // API that you will consume with EasyHTTP

[...]

Now you have to instance a EasyHTTP object

[...]

EasyHTTP http(ssid, password);

[...]

Now, in your void setup lets connect to WiFi and set base URL

[...]
void setup() {

  Serial.begin(115200); // It will be useful in void loop
  http.connectWiFi();
  http.setBaseURL(baseURL);

}
[...]

In your void loop lets make a GET request

[...]
void loop() {

  String response = http.get("/test"); // It will make a request like GET http://yourapiurl.com/test
  Serial.println(response);

  delay(3000);

}

Full code

#include <EasyHTTP.h>

char* ssid = "Your SSID";
char* password = "Your Password";

String baseURL = "http://yourapiurl.com";

EasyHTTP http(ssid, password);

void setup() {
  
  Serial.begin(115200);
  http.connectWiFi();
  http.setBaseURL(baseURL);

}

void loop() {
  String response = http.get("/test");
  Serial.println(response);

  delay(3000);
}

Examples

About

An ESP32 library to facilitate the execution of HTTP requests ๐ŸŒ

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages