From db4b933981bebd8944c964036dc36d8ee8f91a3a Mon Sep 17 00:00:00 2001 From: Roman Hajnala Date: Fri, 7 Mar 2025 19:47:04 +0100 Subject: [PATCH] libky upratovanie --- README.md | 16 ++++++++++++++++ platformio.ini | 6 +++++- src/main.cpp | 15 +++++++++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ca1fbde --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# kalsketimer + +## tu som ukradol kod na citanie RFID kariet +[https://randomnerdtutorials.com/esp32-mfrc522-rfid-reader-arduino/](https://randomnerdtutorials.com/esp32-mfrc522-rfid-reader-arduino/) + + +| MFRC522 RFID Reader | ESP32 | Description | +|---------------------|-------|-------------| +| SDA | GPIO 5 | SPI signal input, I2C data line, or UART data input | +| SCK | GPIO 18 | SPI clock | +| MOSI | GPIO 23 | SPI data input | +| MISO | GPIO 19 | SPI master-in-slave-out, I2C serial clock, or UART serial output | +| IRQ | Don't connect | Interrupt pin; signals the microcontroller when an RFID tag is nearby | +| GND | GND | Ground connection | +| RST | GPIO 21 | LOW signal to put the module in power-down mode; send a HIGH signal to reset the module | +| 3.3V | 3.3V | Power supply (2.5-3.3V) | \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index 8dd1b2d..74f7dc7 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,4 +12,8 @@ platform = espressif32 board = esp32dev framework = arduino -monitor_speed = 115200 \ No newline at end of file +monitor_speed = 115200 + +lib_deps = + arduino-libraries/NTPClient + miguelbalboa/MFRC522 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 24a35eb..43f84cf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,6 +11,7 @@ constexpr bool DEBUG = true; + // pins constexpr int redLedPin = 2; constexpr int greenLedPin = 4; @@ -21,6 +22,10 @@ constexpr int buzzerPin = 13; auto ssid = "ElaZereVsetko2g"; auto password = "CoJeElaToJeEla"; +// API +const String apiUrl = "http://192.168.50.87:8111/api/timer/write"; +const String timerId = "branka1"; + // NTP client WiFiUDP ntpUDP; // Europe/Prague timezone and update every 60 seconds @@ -110,8 +115,14 @@ void loop() { debugPrint("send: " + uidString); // Create the URL - String url = "http://192.168.50.87:8111/api/timer/write/12345/" + uidString + "/" + String(timeWithMicroseconds) + "/"; - debugPrint("to: " + url); + char url[256]; // Make sure this is large enough for your URL + snprintf(url, sizeof(url), "%s/%s/%s/%s/", + apiUrl.c_str(), + timerId.c_str(), + uidString.c_str(), + timeWithMicroseconds); + + debugPrint(url); // Send the HTTP GET request HTTPClient http; http.begin(url);