The GenericHTTP library simplifies sending HTTP requests using the ESP8266-01 module (e.g., ESP-01) with an Arduino board. It provides a convenient way to establish Wi-Fi connection, send various types of HTTP requests, and handle responses.
- Connect to Wi-Fi network using provided SSID and password.
- Send HTTP GET and POST requests to specified endpoints.
- Handle HTTP responses, including parsing and extracting data.
- Download the latest release of the library.
- In the Arduino IDE, go to Sketch > Include Library > Add .ZIP Library... and select the downloaded ZIP file.
- Restart the Arduino IDE.
- Import the
GenericHTTP.h
library at the beginning of your Arduino sketch:
#include <GenericHTTP.h>
- Create an instance of the GenericHTTP class:
GenericHTTP http;
- Connect to Wi-Fi using connectToWiFi function:
http.connectToWiFi("your_wifi_ssid", "your_wifi_password");
- Send an HTTP GET request:
bool success = http.sendHTTPRequest("GET", "example.com", "80", "/path/to/endpoint", nullptr, nullptr);
if (success) {
// Handle successful response
} else {
// Handle failed request
}
The library comes with several example sketches to help you get started:
- Basic Usage: Demonstrates the basic usage of the library to connect to Wi-Fi and send an HTTP GET request.
- Advanced Usage: Shows more advanced scenarios, such as handling responses and using custom headers.
Feel free to explore these examples to understand how to integrate the GenericHTTP library into your own projects.