Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/********* Pleasedontcode.com ********** Pleasedontcode thanks you for automatic code generation! Enjoy your code! - Terms and Conditions: You have a non-exclusive, revocable, worldwide, royalty-free license for personal and commercial use. Attribution is optional; modifications are allowed, but you're responsible for code maintenance. We're not liable for any loss or damage. For full terms, please visit pleasedontcode.com/termsandconditions. - Project: "RFID SMS" - Source Code compiled for: ESP32 DevKit V1 - Source Code created on: 2024-06-13 11:33:50 ********* Pleasedontcode.com **********/ /****** SYSTEM REQUIREMENTS *****/ /****** SYSTEM REQUIREMENT 1 *****/ /* Enhance the RFID system to assign a unique random */ /* identifier to each new RFID tag detected using the */ /* MFRC522 module. Every new identifier will be send */ /* via gsm to number +41 123456 */ /****** END SYSTEM REQUIREMENTS *****/ /****** DEFINITION OF LIBRARIES *****/ #include
#include
//https://github.com/plerup/espsoftwareserial #include
//https://github.com/miguelbalboa/rfid #include
//https://github.com/vittorioexp/Sim800L-Arduino-Library-revised /****** FUNCTION PROTOTYPES *****/ void setup(void); void loop(void); void updateOutputs(void); void generateAndSendUniqueID(); /***** DEFINITION OF DIGITAL INPUT PINS *****/ const uint8_t gsm_SIM800L_RING_PIN_D17 = 17; /***** DEFINITION OF DIGITAL OUTPUT PINS *****/ const uint8_t gsm_SIM800L_RST_PIN_D16 = 16; const uint8_t gsm_SIM800L_DTR_PIN_D22 = 22; /***** DEFINITION OF Software Serial *****/ const uint8_t gsm_SIM800L_Serial_PIN_SERIAL_TX_D14 = 14; const uint8_t gsm_SIM800L_Serial_PIN_SERIAL_RX_D21 = 21; SoftwareSerial gsm_SIM800L_Serial(gsm_SIM800L_Serial_PIN_SERIAL_RX_D21, gsm_SIM800L_Serial_PIN_SERIAL_TX_D14); // RX, TX /***** DEFINITION OF SPI PINS *****/ const uint8_t rfid_MFRC522_SPI_PIN_MOSI_D23 = 23; const uint8_t rfid_MFRC522_SPI_PIN_MISO_D19 = 19; const uint8_t rfid_MFRC522_SPI_PIN_SCLK_D18 = 18; const uint8_t rfid_MFRC522_SPI_PIN_CS_D5 = 5; /***** DEFINITION OF OUTPUT RAW VARIABLES *****/ /***** used to store raw data *****/ bool gsm_SIM800L_RST_PIN_D16_rawData = 0; bool gsm_SIM800L_DTR_PIN_D22_rawData = 0; /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/ /***** used to store data after characteristic curve transformation *****/ float gsm_SIM800L_RST_PIN_D16_phyData = 0.0; float gsm_SIM800L_DTR_PIN_D22_phyData = 0.0; /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/ MFRC522 rfid(rfid_MFRC522_SPI_PIN_CS_D5, rfid_MFRC522_SPI_PIN_SCLK_D18); // Instance of the class Sim800L GSM(gsm_SIM800L_Serial, gsm_SIM800L_RST_PIN_D16, gsm_SIM800L_DTR_PIN_D22, gsm_SIM800L_RING_PIN_D17); // Instance of the class // Array to store new NUID byte nuidPICC[4]; void setup(void) { // put your setup code here, to run once: pinMode(gsm_SIM800L_RING_PIN_D17, INPUT_PULLUP); pinMode(gsm_SIM800L_RST_PIN_D16, OUTPUT); pinMode(gsm_SIM800L_DTR_PIN_D22, OUTPUT); pinMode(rfid_MFRC522_SPI_PIN_CS_D5, OUTPUT); // start the SPI library: SPI.begin(rfid_MFRC522_SPI_PIN_SCLK_D18, rfid_MFRC522_SPI_PIN_MISO_D19, rfid_MFRC522_SPI_PIN_MOSI_D23, rfid_MFRC522_SPI_PIN_CS_D5); gsm_SIM800L_Serial.begin(9600); rfid.PCD_Init(); // Init MFRC522 // Initialize GSM module GSM.begin(4800); } void loop(void) { // put your main code here, to run repeatedly: updateOutputs(); // Refresh output data // Check for new RFID card if (rfid.PICC_IsNewCardPresent() && rfid.PICC_ReadCardSerial()) { // If a new card is detected, generate and send a unique ID generateAndSendUniqueID(); rfid.PICC_HaltA(); // Halt PICC rfid.PCD_StopCrypto1(); // Stop encryption on PCD } } void updateOutputs() { digitalWrite(gsm_SIM800L_RST_PIN_D16, gsm_SIM800L_RST_PIN_D16_rawData); digitalWrite(gsm_SIM800L_DTR_PIN_D22, gsm_SIM800L_DTR_PIN_D22_rawData); } void generateAndSendUniqueID() { // Generate a unique random identifier String uniqueID = ""; for (int i = 0; i < 8; i++) { uniqueID += String(random(0, 9)); // Generate a random digit } // Convert the uniqueID to a mutable char array char uniqueIDChar[uniqueID.length() + 1]; uniqueID.toCharArray(uniqueIDChar, uniqueID.length() + 1); // Send the unique identifier via GSM char number[] = "+41123456"; bool error = GSM.sendSms(number, uniqueIDChar); if (!error) { Serial.println("SMS sent successfully: " + uniqueID); } else { Serial.println("Failed to send SMS"); } } /* END CODE */
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)