This program allows to use an ESP32 to control 32 Inputs/Outputs over HTTP using WiFi Connection.
- 16 inputs (Waveshare MCP23017 GPIO)
- 16 outputs (Waveshare MCP23017 GPIO)
- send the state of an input to an HTTP server
- set the state of an output by HTTP calls
- ESP32 NodeMCU
- 2 x Waveshare MCP23017 IO Expansion Board (connected on ESP32 using I2C)
You must weld A0 to change address of the board used for inputs.
This program is edited using PlatformIO.
- Import code in Arduino IDE
- Enable the
Path variable
support for ESPAsyncWebServer
The procedure is detailed in Using Arduino IDE.
Before uploading program to your ESP32, you must configure settings (IP Address, ...).
Each change of state triggers an HTTP request to following URL (depending value of deviceId
)
When deviceId is |
HTTP request is sent to |
---|---|
Empty String ("") | http://{server}:{serverPort}/input/{id}/{state} |
Non-empty String | http://{server}:{serverPort}/input/{deviceId}/{id}/{state} |
Parameter | Description | Values |
---|---|---|
deviceId | Device identifier | Value of deviceId in Configuration.hpp |
id | Input id | See io-mappings |
state | Input state | 0 or 1 |
Given the following configuration :
IPAddress server(192, 168, 0, 1);
int serverPort = 1234;
...
String deviceId = "";
When | HTTP request is sent on |
---|---|
Input 0 changes to 0 | http://192.168.0.1:1234/input/0/0 |
Input 0 changes to 1 | http://192.168.0.1:1234/input/0/1 |
Given the following configuration :
IPAddress server(192, 168, 0, 1);
int serverPort = 1234;
...
String deviceId = "deviceA";
When | HTTP request is sent on |
---|---|
Input 0 changes to 0 | http://192.168.0.1:1234/input/deviceA/0/0 |
Input 0 changes to 1 | http://192.168.0.1:1234/input/deviceA/0/1 |
To set output state, call following URL http://{ip}/output/{id}/{state}/{duration}
Parameter | Description | Values |
---|---|---|
id | Output id | See io-mappings |
state | Output state | off or on |
duration | Duration (ms) Only available for "on" | 1 to 65535 |
Given the following configuration :
IPAddress ip(192, 168, 0, 11);
Usage | URL to call |
---|---|
Enable output 0 | http://192.168.0.11/output/0/on |
Disable output 0 | http://192.168.0.11/output/0/off |
Enable output 0 during 2000 ms | http://192.168.0.11/output/0/on/2000 |
To set all outputs state, call following URL http://{ip}/outputs/{state}
Parameter | Description | Values |
---|---|---|
state | Output state | off or on |
Given the following configuration :
IPAddress ip(192, 168, 0, 11);
Usage | URL to call |
---|---|
Enable all outputs | http://192.168.0.11/outputs/on |
Disable all outputs | http://192.168.0.11/outputs/off |
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
See LICENSE for more information.
- me-no-dev/AsyncTCP Repository
- me-no-dev/ESPAsyncWebServer Repository
- adafruit/Adafruit-MCP23017-Arduino-Library Repository
- Amael BERTEAU
- Project page (Personal Website) (French)
- Facebook Page "Le Lab d'Amael" (French)