Semua Akan Digital Pada Akhirnya... Dari Audio, Video, TV, Kontrol, Keuangan, Kesehatan dan Sebagainya. Blog Ini Ditujukan Buat Kamu Yang Ingin Belajar Dasar Digital Dan Yang selalu Bertanya, Kenapa Bisa Begini Dan Harus Begitu ?

Sabtu, 03 Juli 2021

[ ESP 8266 ] Wireless Key Via Wifi - Part 1 - Asynchronous Web Server

Sophisticated security is a necessity in the digital era, supported by the increasingly affordable digital ready to use microcontroller modules. In this project series, i will design a digital key system based on the ESP8266 - which is the most favorite IOT module of the 8-bit AVR microcontroller with the advantage of a buit in  wifi module.




This project is a combination of various libraries of esp8266 hardware that you can use directly or combined with various development kit modules that you can buy online, such as node mcu, wemos, esp32 and so on. In this project includes the following discussion:


- EspAsyncWebserver (from Me-No-Dev)



This is a popular and very powerful library for creating Asynchronous HTTP and WebSocket Servers on an Arduino  or ESP8266. With this library, it is easier for servers that work mainly outside the main loop so that they are reliable in serving access from several users at once time.


For ESP8266 requires ESPAsyncTCP to use this library, you may need to have the latest git version of ESP8266 Arduino Core


This example is  a simple form, where my wemos d1 works  as SoftAP.



#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <WiFiClient.h> 


AsyncWebServer server(80);

const char* PARAM_INPUT = "input";
const char *ssid = "trial";
const char* password = "niceproject";

String SendHTML()
{

String ptr = " <!DOCTYPE HTML><html><head> ";
  ptr +="<title>CONTOH INPUTAN</title> ";
  ptr +="<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"> ";
  ptr +=" </head><body> ";
  ptr +=" Enter Text Here .. ";
  ptr +=" <br> ";
  ptr +="<form action=\"/get\"> ";
  ptr +=" Challenge: <input type=\"text\" name=\"input\"> ";
  ptr +="  <input type=\"submit\" value=\"Submit\"> ";
  ptr +="</form><br><br>";
  ptr +="</body> ";
  ptr +="</html> ";
  return ptr;
}

void notFound(AsyncWebServerRequest *request) {
  request->send(404, "text/plain", "Not found");
}

void setup(){
 
 Serial.begin(9600);
 WiFi.softAP(ssid, password );//AP
 
 IPAddress apip = WiFi.softAPIP(); //alamat IP
    Serial.print("Please connect to wifi and open in browser : \n");  //ip address
    Serial.println(apip);
 
  // Send web page with text input
    server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(200, "text/html", SendHTML() ); 
  });

  // Send a GET request to <ESP_IP>/get?input=<inputMessage>
  server.on("/get", HTTP_GET, [] (AsyncWebServerRequest *request) {
    String inputMessage;
    String inputParam;
    
    // GET input1 value on <ESP_IP>/get?input=<inputMessage>
    if (request->hasParam(PARAM_INPUT) ) {
      inputMessage = request->getParam(PARAM_INPUT)->value();
      inputParam = PARAM_INPUT;

    }
   
    else {
      inputMessage = "No challenge ";
      inputParam = "none";
    }

    Serial.print("param : ");
    Serial.println(inputParam );
    Serial.print("pesan : ");
    Serial.println(inputMessage); 
    
     request->send(200, "text/html", "Send with Param (" 
                                     + inputParam + ") and message : " + inputMessage +
                                     "<br><a href=\"/\">Return to Home Page</a>");
                                     
  });
  server.onNotFound(notFound);
  server.begin();
}

void loop() {
  // empty

}


The result is when I connect my smartphone to the wifi which is emitted by Wemos / ESP8266 and enter the address http://192.168.4.1 as follows:










- Read SD card


To be continued in the next article : https://www.aisi555.com/2021/07/esp-8266-wireless-key-via-wifi-part-2.html

Share:

0 komentar:

Posting Komentar

Kontak Penulis



12179018.png (60×60)
+628155737755

HP: 081331339072
Mail : ahocool@gmail.com

Site View

Categories

555 (8) 7 segmen (3) adc (4) amplifier (2) analog (15) android (12) antares (3) arduino (18) artikel (11) attiny (2) attiny2313 (18) blog (1) bluetooth (1) cmos (2) crypto (2) dasar (42) digital (1) display (3) esp8266 (9) euro2020 (13) gcc (1) iklan (1) infrared (2) Input Output (3) iot (26) jam (6) jualan (12) kereta api (1) keyboard (1) keypad (3) kios pulsa (2) kit (6) komponen (16) komputer (3) komunikasi (1) kontrol (7) lain-lain (8) lcd (2) led (14) led matrix (6) line tracer (1) lm35 (1) memory (1) metal detector (4) microcontroller (56) mikrokontroller (10) mikrotik (5) ninmedia (3) ntp (1) paket belajar (19) palang pintu otomatis (1) parabola (77) pcb (2) power (1) praktek (2) project (33) proyek (1) python (2) radio (15) raspberry pi (4) remote (1) revisi (1) rfid (1) robot (1) rpm (2) rs232 (1) script break down (3) sdcard (3) sensor (1) sharing (3) signage (1) sinyal (1) sms (6) software (18) solar (1) solusi (1) tachometer (2) technology (1) teknologi (2) telepon (9) televisi (144) television (28) transistor (2) troubleshoot (3) tulisan (83) tutorial (80) tvri (2) vu meter (2) vumeter (2) wav player (3) wayang (1) wifi (3)

Arsip Blog

Diskusi


kaskus
Forum Hobby Elektronika