NodeMCU-and-RFID-RC522-IoT-Projects
/* # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # RFID MFRC522 / RC522 Library : https://github.com/miguelbalboa/rfid # # # # Installation : # # NodeMCU ESP8266/ESP12E RFID MFRC522 / RC522 # # D2 <----------> SDA/SS # # D5 <----------> SCK # # D7 <----------> MOSI # # D6 <----------> MISO # # GND <----------> GND # # D1 <----------> RST # # 3V/3V3 <----------> 3.3V # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Subscribe To The IoT Projects YouTube Channel : https://www.youtube.com/channel/UC49xSqiQ6gBrxUMQ9zvzO6A :) :) :) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # */ //----------------------------------------Include the NodeMCU ESP8266 Library---------------------------------------------------------------------------------------------------------------// //----------------------------------------see here: https://teiotprojects.com/connect-rfid-to-php-mysql-database-with-nodemcu-esp8266/ to add NodeMCU ESP8266 library and board #include #include //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// //----------------------------------------Include the SPI and MFRC522 libraries-------------------------------------------------------------------------------------------------------------// //----------------------------------------Download the MFRC522 / RC522 library here: https://github.com/miguelbalboa/rfid #include #include //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// #define SS_PIN D2 //--> SDA / SS is connected to pinout D2 #define RST_PIN D1 //--> RST is connected to pinout D1 MFRC522 mfrc522(SS_PIN, RST_PIN); //--> Create MFRC522 instance. #define ON_Board_LED 2 //--> Defining an On Board LED, used for indicators when the process of connecting to a wifi router //----------------------------------------SSID and Password of your WiFi router-------------------------------------------------------------------------------------------------------------// const char* ssid = "Alsan Air WiFi 4"; const char* password = "11122235122@kap1"; //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// ESP8266WebServer server(80); //--> Server on port 80 int readsuccess; byte readcard[4]; char str[32] = ""; String StrUID; //-----------------------------------------------------------------------------------------------SETUP--------------------------------------------------------------------------------------// void setup() { Serial.begin(115200); //--> Initialize serial communications with the PC SPI.begin(); //--> Init SPI bus mfrc522.PCD_Init(); //--> Init MFRC522 card delay(500); WiFi.begin(ssid, password); //--> Connect to your WiFi router Serial.println(""); pinMode(ON_Board_LED, OUTPUT); digitalWrite(ON_Board_LED, HIGH); //--> Turn off Led On Board //----------------------------------------Wait for connection Serial.print("Connecting"); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); //----------------------------------------Make the On Board Flashing LED on the process of connecting to the wifi router. digitalWrite(ON_Board_LED, LOW); delay(250); digitalWrite(ON_Board_LED, HIGH); delay(250); } digitalWrite(ON_Board_LED, HIGH); //--> Turn off the On Board LED when it is connected to the wifi router. //----------------------------------------If successfully connected to the wifi router, the IP Address that will be visited is displayed in the serial monitor Serial.println(""); Serial.print("Successfully connected to : "); Serial.println(ssid); Serial.print("IP address: "); Serial.println(WiFi.localIP()); Serial.println("Please tag a card or keychain to see the UID !"); Serial.println(""); } //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// //-----------------------------------------------------------------------------------------------LOOP---------------------------------------------------------------------------------------// void loop() { // put your main code here, to run repeatedly readsuccess = getid(); if (readsuccess) { digitalWrite(ON_Board_LED, LOW); HTTPClient http; //Declare object of class HTTPClient String UIDresultSend, postData; UIDresultSend = StrUID; //Post Data postData = "UIDresult=" + UIDresultSend; http.begin("http://192.168.1.8/NodeMCU-and-RFID-RC522-IoT-Projects/getUID.php"); //Specify request destination http.addHeader("Content-Type", "application/x-www-form-urlencoded"); //Specify content-type header int httpCode = http.POST(postData); //Send the request String payload = http.getString(); //Get the response payload Serial.println(UIDresultSend); Serial.println(httpCode); //Print HTTP return code Serial.println(payload); //Print request response payload http.end(); //Close connection delay(1000); digitalWrite(ON_Board_LED, HIGH); } } //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// //----------------------------------------Procedure for reading and obtaining a UID from a card or keychain---------------------------------------------------------------------------------// int getid() { if (!mfrc522.PICC_IsNewCardPresent()) { return 0; } if (!mfrc522.PICC_ReadCardSerial()) { return 0; } Serial.print("THE UID OF THE SCANNED CARD IS : "); for (int i = 0; i < 4; i++) { readcard[i] = mfrc522.uid.uidByte[i]; //storing the UID of the tag in readcard array_to_string(readcard, 4, str); StrUID = str; } mfrc522.PICC_HaltA(); return 1; } //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// //----------------------------------------Procedure to change the result of reading an array UID into a string------------------------------------------------------------------------------// void array_to_string(byte array[], unsigned int len, char buffer[]) { for (unsigned int i = 0; i < len; i++) { byte nib1 = (array[i] >> 4) & 0x0F; byte nib2 = (array[i] >> 0) & 0x0F; buffer[i * 2 + 0] = nib1 < 0xA ? '0' + nib1 : 'A' + nib1 - 0xA; buffer[i * 2 + 1] = nib2 < 0xA ? '0' + nib2 : 'A' + nib2 - 0xA; } buffer[len * 2] = '\0'; } //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------//
//https://drive.google.com/drive/folders/1Vv_TdMcvsO9qDFYBcRi0qO-iZFjjJDk-?usp=sharing
Komentari Tulisan Ini
Tulisan Lainnya
Belajar Berwirausaha Bersama LPK BINTANG TERANG
Saatnya Maju Bersama.. Membangun Skill, Peluang, dan Masa Depan. Di era digital saat ini, kemampuan berwirausaha bukan hanya pilihan – tetapi menjadi keterampilan penting yang ma
Kunjungan Mentor GreenHouse
Kehadiran mentor di greenhouse hari ini memberi pandangan dan ilmu baru serta menginspirasikan untuk terus memperbaiki proses budidayaan tanaman pakcoy di greenhouse. Bimbingan mentor
Kedatangan Asestor Dari BBPVP Bandung
Ciamis 15 November 2025, Jalan Panumbangan No.444 Dusun Sukamanah (LPK Bintang Terang), Kedatangan Asesor dari BBPVP Bandung untuk memverifikasi alat yang akan digunakan untuk melaksa
Bertemu Sang Melon Premium: Kisah dari Greenhouse
“Kunjungan edukatif ke Greenhouse Melon hari ini membuka wawasan kami tentang proses budidaya modern yang sehat dan berkelanjutan. Banyak ilmu baru, banyak inspirasi baru.&rdquo
PELATIHAN IoT (INTERNET OF THINGS)
Pelatihan IoT (Internet of Things) Terlengkap – LPK Bintang Terang Di era digital seperti sekarang, teknologi berkembang sangat cepat. Hampir semua bidang kehidupan mulai memanfa
“Efisiensi Pertanian Modern: Monitoring Tanaman dalam Greenhouse”
Di era pertanian modern, teknologi menjadi kunci untuk menciptakan sistem tanam yang efisien, produktif, dan ramah lingkungan. Dengan bantuan berbagai sensor canggih seperti
“Belajar Peduli Lingkungan Melalui Kegiatan Merakit Tong Sampah Otomatisi”
Panumbangan, 5 November 2025 — Siswa LPK Bintang Terang kembali menorehkan prestasi membanggakan. Kali ini, mereka berhasil merakit tong sampah pintar (smart trash bin) ya
Kabid PNF Disdik Ciamis Beri Motivasi di LPK Bintang Terang
Ciamis, 01 November 2025 — Kepala Bidang Pendidikan Nonformal (PNF) Dinas Pendidikan Kabupaten Ciamis, Bapak Eka Yudha Katresna, S.Sos., M.M., berkunjung ke LPK/LKP Bintang Terang
SMART FARMING (IoT Berbasis ESP32)
/******************************************************* Program : SMART FARMING (IoT Berbasis ESP32) Chip : ESP32 Website : https://bintangterang
CAMAT PANUMBANGAN KUNJUNGI LPK BINTANG TERANG
Camat Panumbangan Kunjungi LPK Bintang Terang, Beri Motivasi untuk Peserta Pelatihan Smart Farming Panumbangan, 31 Oktober 2025 — LPK Bintang Terang mendapat kunjungan istimewa







