It's much easier for people to help you if you include short program directly in your Post - like this
#include <BearSSLHelpers.h>
#include <CertStoreBearSSL.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiAP.h>
#include <ESP8266WiFiGeneric.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266WiFiScan.h>
#include <ESP8266WiFiSTA.h>
#include <ESP8266WiFiType.h>
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <WiFiClientSecureAxTLS.h>
#include <WiFiClientSecureBearSSL.h>
#include <WiFiServer.h>
#include <WiFiServerSecure.h>
#include <WiFiServerSecureAxTLS.h>
#include <WiFiServerSecureBearSSL.h>
#include <WiFiUdp.h>
#include <Keypad.h>
#include <ESPAsyncWebServer.h>
AsyncWebServer server(80);
const char* PARAM_INPUT_1 = "input1";
// HTML web page to handle 3 input fields (input1, input2, input3)
const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html><head>
<title>ESP Input Form</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head><body>
<form action="/get">
input1: <input type="text" name="input1">
<input type="submit" value="Submit">
</form>
</body></html>)rawliteral";
void notFound(AsyncWebServerRequest *request) {
request->send(404, "text/plain", "Not found");
}
const char *ssid = "WiFiLoja";
const char *pass = "PauloGoulao";
WiFiClient client;
const byte n_rows = 4;
const byte n_cols = 4;
char* password = "1590"; // variavel com a password 4 numeros
char keys[n_rows][n_cols] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte colPins[n_rows] = {D3, D2, D1, D0};
byte rowPins[n_cols] = {D7, D6, D5, D4};
int RedpinLock = 3;
int GreenpinUnlock = 9;
int relayInput = 15; // pino de entrada para o relé
int position = 0;
volatile byte relayState = LOW;
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, n_rows, n_cols);
void setup(){
Serial.begin(115200);
Serial.println("Ligando a ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi Ligado");
Serial.println(WiFi.localIP()); //mostra IP
delay(1000);
pinMode(RedpinLock, OUTPUT);
pinMode(GreenpinUnlock, OUTPUT);
pinMode(relayInput, OUTPUT); // inicializa o relay
digitalWrite(relayInput, HIGH);
// Send web page with input fields to client
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/html", index_html);
});
// Send a GET request to <ESP_IP>/get?input1=<inputMessage>
server.on("/get", HTTP_GET, [] (AsyncWebServerRequest *request) {
String inputMessage;
String inputParam;
// GET input1 value on <ESP_IP>/get?input1=<inputMessage>
if (request->hasParam(PARAM_INPUT_1)) {
inputMessage = request->getParam(PARAM_INPUT_1)->value();
inputParam = PARAM_INPUT_1;
}
else {
inputMessage = "No message sent";
inputParam = "none";
}
Serial.println(inputMessage);
request->send(200, "text/html", "HTTP GET request sent to your ESP on input field ("
+ inputParam + ") with value: " + inputMessage +
"
<a href=\"/\">Return to Home Page</a>");
});
server.onNotFound(notFound);
server.begin();
}
void loop(){
Serial.println("Introduza");
char key = keypad.getKey();
Serial.println(key);
if (key == password[position])
{
position ++;
}
if (position == 4)
{
LockedPosition(false);
position =0;
LockedPosition(true);
}
delay(100);
}
void LockedPosition(int locked){
if (locked)
{
digitalWrite(RedpinLock, HIGH);
digitalWrite(GreenpinUnlock, LOW);
digitalWrite(relayInput, HIGH);
Serial.println("fechado");
}
else
{
digitalWrite(RedpinLock, LOW);
digitalWrite(GreenpinUnlock, HIGH);
digitalWrite(relayInput, LOW);
Serial.println("aberto");
delay(2000);
}
}
I'm not sufficiently familiar with web programming on the ESP8266 to be able to offer any advice beyond the general comment I have already made - sorry.
...R