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 ?

  • IC Timer 555 yang Multifungsi

    IC timer 555 adalah sirkuit terpadu (chip) yang digunakan dalam berbagai pembangkit timer, pulsa dan aplikasi osilator. Komponen ini digunakan secara luas, berkat kemudahan dalam penggunaan, harga rendah dan stabilitas yang baik

  • Kontrol Perangkat Rumah Dari Internet

    Internet Of Things sudah menjadi istilah yang semakin dikenal orang. Mau tahu bagaimana konsep, cara pembuatan dan pemanfaatannya ?

  • Bermain DOT Matrix - LOVEHURT

    Project Sederhana dengan Dot Matrix dan Attiny2313. Bisa menjadi hadiah buat teman atau pacarmu yang ulang tahun dengan tulisan dan animasi yang dapat dibuat sendiri.

  • JAM DIGITAL 6 DIGIT TANPA MICRO FULL CMOS

    Jika anda pencinta IC TTL datau CMOS maka project jam digital ini akan menunjukkan bahwa tidak ada salahnya balik kembali ke dasar elektronika digital , sebab semuanya BISA dibuat dengan teknologi jadul

  • Node Red - Kontrol Industri 4.0

    Teknologi kontrol sudah melampaui ekspektasi semua orang dan dengan kemajuan dunia elektronika, kini semakin leluasa berkreasi melalui Node Red

Sabtu, 03 Juli 2021

[ ESP 8266 ] Wireless Key Via Wifi - Part 3 - Combine Wifi + Sd Card

We have come to the end of my project to design a motorbike wireless key,  based on wifi + sd card, where we will combine the previous discussion, first part is esp8266 as an asynchronous webserver and the second discussion regarding the SD Card. So this 2 parts needs to be understood first so that it is not too confusing for our readers.





Broadly speaking, the objectives to be achieved from this practice series are:


  • Using ESP8266 as an access point and webserver to be accessed by smartphones and then controlling the relay connected to the electric motor lock system
  • The SD card is used as a storage medium for wifi parameters and the answer key / challenge code that the user will solve via a smartphone



The circuit that I designed as follows:




But this time I will focus only on the important part and have never been discussed in the previous 2 series of articles, namely the wifi setting from sd card and questions for passwords, where users can write their own wifi name on the SD card via PC/Laptop and make this device can be changed as desired. 


Here I use a settings file called lock.txt which contains the data:


wifi,mybike,iamverycool
1,motorbike,suzuki
2,year of purchase,2012
3,city,london
4,your cat name,pussy
5,hobby,fishing


The top line of wifi, mybike, iamverycool is the setting for the wifi name and password (at least 8 characters). While the next is a sequence of 5 questions that can be solved to turn on the motor contact relay.


The script for reading the contents of the file per line is then parsed as follows:


dataFile = SD.open("lock.txt");

  if (dataFile) {

    while (dataFile.available()) {

    buffer = dataFile.readStringUntil('\r\n');
   //parsing text for wifi and password
    if(getStringPartByNr(buffer,',',0) == "wifi")
    {
    Serial.println(buffer);
    ssid =  getStringPartByNr(buffer,',',1);
    password = getStringPartByNr(buffer,',',2);
      
    }
    //open the question and answer as the number of sequence
    else if(getStringPartByNr(buffer,',',0) == String(sequ))
    {
    Serial.print("question : ");
    key = getStringPartByNr(buffer,',',1);
    Serial.print(key);
    Serial.print(" - answer : ");
    chal =getStringPartByNr(buffer,',',2); 
    Serial.println(chal);
    }
   }
   
    dataFile.close();


Meanwhile, to make changes to the questions so that they are not always the same as those asked, it is necessary to carry out a process of adding sequences that are stored in the seq.txt file. It is similar to a random process / choosing questions at randomly order.


SD.remove("seq.txt");  //erase the file then make a new one
  File myFile = SD.open("seq.txt", FILE_WRITE);
  if (myFile) // it opened OK
    {
    Serial.println("Writing to seq.txt");
    sequ++; //add sequence
    if(sequ > maxsequ) sequ= 1; //back to start
    //write to SD card for new sequence
    myFile.print(String(sequ));
    myFile.close(); 
    Serial.print("current sequence :");
    Serial.println(String(sequ));
    }
  else 
    Serial.println("Error opening seq.txt");

To compare whether the answer is correct or not, a comparison is made in the input form that is responded to by the form submit asynchronously.



rver.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("Answer : ");
    Serial.println(inputMessage); 

    //if compared and correct
    if(inputMessage == chal)
    {

    
    request->send(200, "text/html", SendCorrect());
    
    
    }

    else{
     olkey = key ; 
     request->send(200, "text/html", SendWrong(olkey,inputMessage));
      }

    writeToFile();  // add sequence to sd card
   

                                     
  }); 


The results are quite satisfactory and the questions can be changed as desired.









Because it's still in the form of a web and the format is a regular GET, then for development it can be wrapped into an Android APK which is quite simple, you only need to change the HTML web to an Android application. Also, if you want to be cool, you can include a second relay to start it via the button on the smartphone screen.




Share:

[ ESP 8266 ] Wireless Key Via Wifi - Part 2 - SD Card Access Read File Line by Line

On this part, maybe, is the part that is most often discussed and easily " googled " in various blogs and articles, because the SD Card libraries and ready-to-use SD card reader module for SPI-based Arduino are very cheap in the online market. So I will discuss a little bit further,  parsing files and text per line  on the SD Card.





Because the shield or module is ready to use, you will be spoiled with direct connections to the MCU or Wemos D1 node module, just look for the appropriate SPI PIN (MOSI, MISO, SCK) and CS then use the libraries available directly on the Arduino sketch, namely SD.h and SPI .h.


And the easiest is the script to test whether the connection is correct or not, as simple as the following:


#include <SPI.h>
#include <SD.h>

const int chipSelect = D8; // use D0 for Wemos D1 Mini
File root; 


void setup() {
 Serial.begin(9600);
  Serial.print("\r\nWaiting for SD card to initialise...");
  if (!SD.begin(chipSelect)) { // CS is D8 in this example
    Serial.println("SD Card Initialising failed!");
    return;
  }
  Serial.println("SD Card Initialisation completed");

 File dataFile = SD.open("key.csv");
 

  if (dataFile) {

    while (dataFile.available()) {

       Serial.write(dataFile.read());
    }

    dataFile.close();

  }

  // if the file isn't open, pop up an error:

  else {

    Serial.println("error opening seq.txt");

  }
  

}

void loop() {
  

}




The output result as follows:






The file which i use in this example is in CSV format, that I made using excel as the following format:




So, as per line, there are 3 parts of data separated by "commas" and ending with ascii 'CR LF' or if in the coding or  C language is known as  the character '\r\n'.  And i found on the google search, a very powerful script that is useful when you want to find rows with a certain index and then parse it:


String getStringPartByNr(String data, char separator, int index)
{
    // spliting a string and return the part nr index
    // split by separator
    
    int stringData = 0;        //variable to count data part nr 
    String dataPart = "";      //variable to hole the return text
    
    for(int i = 0; i<data.length()-1; i++) {    //Walk through the text one letter at a time
      
      if(data[i]==separator) {
        //Count the number of times separator character appears in the text
        stringData++;
        
      }else if(stringData==index) {
        //get the text when separator is the rignt one
        dataPart.concat(data[i]);
        
      }else if(stringData>index) {
        //return text and stop if the next separator appears - to save CPU-time
        return dataPart;
        break;
        
      }

    }
    //return text if this is the last part
    return dataPart;
}


Next, I combine it to get the data on the specified row with the index  "no", I use the arduino sketch console to wait for keyboard input from the desired row of data inside an SD card.


#include <SPI.h>
#include <SD.h>

const int chipSelect = D8; // use D0 for Wemos D1 Mini
File root; 

String buffer;
String rx_str = ""; //variabel string for stringinput
char rx_byte = 0;

String getStringPartByNr(String data, char separator, int index)
{
    // spliting a string and return the part nr index
    // split by separator
    
    int stringData = 0;        //variable to count data part nr 
    String dataPart = "";      //variable to hole the return text
    
    for(int i = 0; i<data.length()-1; i++) {    //Walk through the text one letter at a time
      
      if(data[i]==separator) {
        //Count the number of times separator character appears in the text
        stringData++;
        
      }else if(stringData==index) {
        //get the text when separator is the rignt one
        dataPart.concat(data[i]);
        
      }else if(stringData>index) {
        //return text and stop if the next separator appears - to save CPU-time
        return dataPart;
        break;
        
      }

    }
    //return text if this is the last part
    return dataPart;
}


void bacaSD( String index) // read line from an index
{
 
  File dataFile = SD.open("key.csv");
 
  if (dataFile) {

    while (dataFile.available()) {

    buffer = dataFile.readStringUntil('\r\n');
    
    //parsing 
    if(getStringPartByNr(buffer,',',0) == index)
    {
    Serial.print("no : "); 
    Serial.print(index); 
    Serial.print(" - key : ");
    Serial.print(getStringPartByNr(buffer,',',1));
    Serial.print(" - challenge : ");
    Serial.println(getStringPartByNr(buffer,',',2));
     
    }
    
    }
    dataFile.close();

  }

  // if the file isn't open, pop up an error:

  else {

    Serial.println("error opening KEY.CSV");

  }


}

void setup() {
 Serial.begin(9600);
  Serial.print("\r\nWaiting for SD card to initialise...");
  if (!SD.begin(chipSelect)) { // CS is D8 in this example
    Serial.println("SD Card Initialising failed!");
    return;
  }
  Serial.println("SD Card Initialisation completed");
  Serial.println("Masukkan index baris: ");
 
  

}

void loop() {
 
if (Serial.available() > 0) {    // is a character available?
    rx_byte = Serial.read();       // get the character
    
    if (rx_byte != '\n') {
      // a character of the string was received
      rx_str += rx_byte;
    }
    else {
      // end of string
      Serial.print("Data baris ke: ");
      Serial.println(rx_str);
      bacaSD(rx_str);
      
      rx_str = "";                // clear the string for reuse
      Serial.println("");
      Serial.println("Please Input Line Index: ");
    }
  } // end
}


The results can be seen in the following animation, and if you try it, you can use the "newline" mode on the Arduino Sketch console monitor.





Share:

[ 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:

Jumat, 02 Juli 2021

Marconi first wireless signal transmission in London on 27 July 1896

Italian inventor and electrical engineer Guglielmo Marconi was born on 25 April, 1874, in Bologna and became a pioneer in the field of long-distance radio transmission and a key developer of radio telegraphy.





Marconi initially began experimenting with radio waves when he was 20 years old, with the hope of creating a form of wireless telegraphy.


By 1895 he had succeeded in transmitting a signal just over a mile ‒ but the Italian Ministry of Posts & Telegraphs was not interested in funding further research.


It later transpired that the letter he sent explaining his wireless telegraph machine had been dismissed as madness – the head of the ministry apparently scrawled "to the Longara" on the document, referring to an asylum in Rome.

Undaunted by lack of interest in his native Italy, Marconi travelled to London and, via family connections, was introduced to William Preece, engineer-in-chief to the General Post Office – a forerunner of today's BT. Preece and the Post Office supported Marconi in his early career in the UK.


On 27 July 1896, Marconi successfully demonstrated his wireless telegraphy system by sending a signal between two Post Office buildings.





The transmitter was placed on the roof of the Central Telegraph Office – at the junction of Newgate Street and St Martin’s Le Grand, where the BT Centre now stands – and a receiver on the roof of GPO South building on Carter Lane. A plaque on BT Centre commemorates this first public transmission of wireless signals.


Though the distance covered by the signal between the two London buildings was only 300 metres, the demonstration persuaded the GPO to fund further tests by Marconi on Salisbury Plain.

But despite recognising the system’s potential, the GPO failed to sign a formal agreement with Marconi – leaving him free to establish a private company (The Wireless Telegraph & Signal Company Ltd) in London in 1897.


The company enjoyed rapid success – first successfully transmitting across the English Channel in 1899, then across the Atlantic in 1901. Marconi’s company became well-known as a provider of wireless equipment and operators for shipping – most famously to the Titanic, whose wireless transmissions as the ship sank in April 1912 helped save many lives.





Herbert Samuel, postmaster general at the time, said of the Titanic disaster: “Those who have been saved, have been saved through one man, Mr Marconi... and his marvellous invention.” Marconi and his family had been invited to sail on the ship’s doomed maiden voyage but had been unable to make the journey.


Marconi shared the 1909 Nobel prize in physics with Karl Ferdinand Braun “in recognition of their contributions to the development of wireless telegraphy’’.


Braun's major contributions included introducing closed tuned circuits in the generating part of the transmitter, and its separation from the radiating part (the antenna) by means of inductive coupling – and, later, the use of crystals for receiving purposes.  Braun also developed the first cathode ray tube in 1897 – a key element in the creation of television.

Share:

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 (21) artikel (11) attiny (3) attiny2313 (19) blog (1) bluetooth (1) cmos (2) crypto (2) dasar (45) digital (1) display (3) esp8266 (25) euro2020 (13) gcc (1) iklan (1) infrared (2) Input Output (3) iot (44) jam (7) 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 (70) micropython (6) mikrokontroller (12) mikrotik (5) mqtt (1) ninmedia (3) ntp (1) paket belajar (19) palang pintu otomatis (1) parabola (78) pcb (2) power (1) praktek (2) project (33) proyek (1) python (3) 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) telegram (2) telepon (9) televisi (145) 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