From dcba3583ece572ee1ed8078a25f59dc1f8fbda0b Mon Sep 17 00:00:00 2001 From: tueddy Date: Sun, 13 Dec 2020 23:05:26 +0100 Subject: [PATCH 1/3] * Add support for SD MMC 1 Bit mode: This mode doubles the SD card speed (FTP upload speed ~350 kB/s compared to ~180 kB/s in SPI mode). Needs one PIN less but fixed PIN assignments Add support for the PN5180 RFID reader: PN5180 has better RFID range/sensitivity and can read ISO-15693 / iCode SLIX2 aka Tonies --- README.md | 35 +++++++- platformio.ini | 5 +- src/main.cpp | 232 ++++++++++++++++++++++++++++++++++++++++++++----- src/settings.h | 35 ++++++-- 4 files changed, 273 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 40cef13..490a8fc 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ Finally, the long announced Tonuino-PCB for Wemos' Lolin32 is [there](https://gi * 08.12.2020: Reworked MQTT-timeout-Management * 09.12.2020: mDND-feature added. If tonuino's name is "tonuino", you can use `tonuino.local` instead it's of IP-address. * 11.12.2020: Revised GUI-design + (untested) PCB added for Wemos Lolin D32 + gerberfiles for headphone-PCB +* 13.12.2020: Add SD-MMC 1 Bit mode: This mode needs one PIN less and has almost double speed than SPI mode +* 13.12.2020: Add support for the PN5180 reader. The PN5180 has better RFID range/sensitivity and can read ISO-15693 / iCode SLIX2 tags aka Tonies More to come... ## Known bugs @@ -48,7 +50,8 @@ The heart of my project is an ESP32 on a [Wemos Lolin32 development-board](https * [Buttons](https://de.aliexpress.com/item/32896285438.html) * [Speaker](https://www.visaton.de/de/produkte/chassiszubehoer/breitband-systeme/fr-7-4-ohm) * uSD-card: doesn't have to be a super-fast one; uC is limiting the throughput. Tested 32GB without any problems. - +* uSD in SD-MMC (1 Bit) mode: Several devkits with onboard SD slot have support for this mode, e.g.: (https://de.aliexpress.com/item/4001229463219.html) +* optional replace the RFID-reader with a the better one: PN5180 comes with better RFID range, less power consumption and support for ISO-15693 / iCode SLIX2 tags (https://www.bing.com/shop?q=pn5180&FORM=SHOPTB) Most of them can be ordered cheaper directly in China. It's just a give an short impression of the hardware; feel free to order where ever you want to. These are not affiliate-links. ## Getting Started @@ -104,6 +107,18 @@ Optionally, GPIO 17 can be used to drive a NPN-transistor (BC337-40) that pulls This also works for a 3.3V-setup with IRF530NPBF (N-channel MOSFET) and NDP6020P (P-channel MOSFET). Resistor-values: R1: 100k, R2: omitted(!), R4: 100k, R5: 1k. A 3.3V-setup is helpful if you want to battery-power your Tonuino and 5V is not available in battery-mode. For example this is the case when using Wemos Lolin32 with only having LiPo connected. Please refer the schematics for my [Lolin32-PCB](https://github.com/biologist79/Tonuino-ESP32-I2S/blob/master/PCBs/Wemos%20Lolin32/Pictures/Tonuino-Lolin32-Schematics.pdf) for further informations.
Advice: When powering a SD-card-reader solely with 3.3V, make sure to use one WITHOUT a voltage regulator. Or at least one with a pin dedicated for 3.3V (bypassing voltage regulator). This is because if 3.3V go through the voltage regulator a small voltage-drop will be introduced, which may lead to SD-malfunction as the resulting voltage is a bit too low. Vice versa if you want to connect your reader solely to 5V, make sure to have one WITH a voltage regulator :-). +## Wiring (SD card in 1 Bit SD-MMC mode) different to above +| ESP32 (GPIO) | Hardware | Pin | Comment | +| ------------- | --------------------- | ------ | ------------------------------------------------------------ | +| -- | SD-reader | CS | no CS required | +| 15 | SD-reader | MOSI | | +| 2 | SD-reader | MISO | 10K hardware pullup may be required | +| 14 | SD-reader | SCK | | + +SD-MMC mode requires these fixed PIN's. SD-MMC mode is almost twice as fast than SPI mode. +You find a good comparasion of different SD card modes here: (https://www.instructables.com/Select-SD-Interface-for-ESP32/) +Advice: Double check that above PIN's not used in otherway (PREVIOUS_BUTTON is mounted to SD MISO in default settings.h) + ## Wiring (1 SPI-instance) [EXPERIMENTAL, maybe not working!] Basically the same as using 2 SPI-instances but... In this case RFID-reader + SD-reader share SPI's SCK, MISO and MOSI. But make sure to use different CS-pins. @@ -143,6 +158,23 @@ In this case RFID-reader + SD-reader share SPI's SCK, MISO and MOSI. But make su | 33 | Voltage-divider / BAT | | Optional: Voltage-divider to monitor battery-voltage | | 22 | Headphone jack | | Optional: if pulled to ground, headphone-volume is set | + +## Wiring (PN5180 instead of MFRC522) different to above +PN5180 reader needs two more PIN's, RESET and BUSY. Double check PIN conflicts! + +| ESP32 (GPIO) | Hardware | Pin | Comment | +| ------------- | --------------------- | ------ | ------------------------------------------------------------ | +| 17 | PN5180 RFID-reader | 3.3V | Connect directly to GPIO 17 for power-saving when uC is off | +| GND | PN5180 RFID-reader | GND | | +| 21 | PN5180 RFID-reader | CS/SDA | Same as MFRC522. Don't share with SD! | +| 23 | PN5180 RFID-reader | MOSI | Same as MFRC522 | +| 19 | PN5180 RFID-reader | MISO | Same as MFRC522 | +| 18 | PN5180 RFID-reader | SCK | Same as MFRC522 | +| 16 | PN5180 RFID-reader | BUSY | be aware of SD MISO if running in SPI mode | +| 22 | PN5180 RFID-reader | RST | be aware of Headphone jack PIN | + + + ## Wiring (custom) / different pinout When using a develboard with for example SD-card-reader already integrated (Lolin D32 Pro), the pinouts described above my not fit; feel free to change them according your needs. Additionaly some boards may use one or some of the GPIOs I used for their internal purposes and that reason for are maybe not exposed via pin-headers. However, having them exposed doesn't mean they can be used without limits. This is because some GPIOs have to be logical LOW or HIGH at start for example and this is probably not the case when connecting stuff to it. Feel free to adjust the GPIOs proposed by me (but be adviced it could take a while to get it running). If you encounter problems please refer the board's manual first.
[Here](https://github.com/biologist79/Tonuino-ESP32-I2S/tree/master/Hardware-Plaforms/ESP32-A1S-Audiokit) I described a solution for a board with many GPIOs used internally and a very limited number of GPIOs exposed. That's why I had to use different SPI-GPIOs for RFID as well. Please note I used a slightly modified [RFID-lib](https://github.com/biologist79/Tonuino-ESP32-I2S/tree/master/Hardware-Plaforms/ESP32-A1S-Audiokit/lib/MFRC522) there. @@ -161,6 +193,7 @@ Please note: via GUI upper and lower voltage cut-offs for visualisation of batte * Enabling `SHUTDOWN_IF_SD_BOOT_FAILS` is really recommended if you run your Tonuino in battery-mode without having a restart-button exposed to the outside of Tonuino's enclosure. Because otherwise there's no way to restart your Tonuino and the error-state will remain until battery is empty (or you open the enclosure, hehe). * Enabling `PLAY_LAST_RFID_AFTER_REBOOT` will tell Tonuino to remember the last RFID-tag played after next reboot. So rebooting Tonuino will end up in autoplay. * If `MDNS_ENABLE` is enabled, your Tonuino is reachable via hostname.local. So if your Tonuino's hostname is 'tonuino', the address is `tonuino.local`. +* If you want to use the SD card in SD-MMC mode (double upload speed for FTP) use `SD_MMC_1BIT_MODE` and double check these PIN's are not used by other periperal * Compile and upload the sketch. ## Starting Tonuino-ESP32 first time diff --git a/platformio.ini b/platformio.ini index b8911b9..663174f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -18,16 +18,15 @@ monitor_speed = 115200 board_build.partitions = no_ota.csv ;board_build.partitions = min_spiffs.csv -upload_port = /dev/cu.SLAB_USBtoUART -monitor_port = /dev/cu.SLAB_USBtoUART lib_deps = https://github.com/schreibfaul1/ESP32-audioI2S.git https://github.com/madhephaestus/ESP32Encoder.git https://github.com/knolleary/pubsubclient.git - https://github.com/biologist79/ESP32FTPServer + https://github.com/tueddy/ESP32FTPServer.git https://github.com/FastLED/FastLED.git https://github.com/biologist79/rfid.git + https://github.com/tueddy/PN5180-Library.git ESP Async WebServer https://github.com/me-no-dev/AsyncTCP https://github.com/bblanchon/ArduinoJson.git diff --git a/src/main.cpp b/src/main.cpp index 4a618ed..8f423e9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,10 +15,21 @@ #endif #include "Audio.h" #include "SPI.h" -#include "SD.h" #include "FS.h" +#ifdef SD_MMC_1BIT_MODE + #include "SD_MMC.h" +#else + #include "SD.h" +#endif #include "esp_task_wdt.h" -#include +#ifdef RFID_READER_TYPE_MFRC522 + #include +#endif +#ifdef RFID_READER_TYPE_PN5180 + #include + #include + #include +#endif #include #ifdef MQTT_ENABLE #include @@ -249,7 +260,9 @@ static const char restartWebsite[] PROGMEM = "

Der Tonuino wird neu gestartet. // Audio/mp3 +#ifndef SD_MMC_1BIT_MODE SPIClass spiSD(HSPI); +#endif TaskHandle_t mp3Play; TaskHandle_t rfid; #ifdef NEOPIXEL_ENABLE @@ -575,8 +588,11 @@ void parseSDFileList(fs::FS &fs, const char * dirname, const char * parent, uint esp_task_wdt_reset(); if (pathValid(fileNameBuf)) { sendWebsocketData(0, 31); - appendNodeToJSONFile(SD, DIRECTORY_INDEX_FILE, fileNameBuf, parent, "folder" ); - + #ifdef SD_MMC_1BIT_MODE + appendNodeToJSONFile(SD_MMC, DIRECTORY_INDEX_FILE, fileNameBuf, parent, "folder" ); + #else + appendNodeToJSONFile(SD, DIRECTORY_INDEX_FILE, fileNameBuf, parent, "folder" ); + #endif // check for next subfolder if(levels){ parseSDFileList(fs, fileNameBuf, root.name(), levels -1); @@ -586,7 +602,7 @@ void parseSDFileList(fs::FS &fs, const char * dirname, const char * parent, uint } else { if (fileValid(fileNameBuf)) { - appendNodeToJSONFile(SD, DIRECTORY_INDEX_FILE, fileNameBuf, parent, "file" ); + appendNodeToJSONFile(fs, DIRECTORY_INDEX_FILE, fileNameBuf, parent, "file" ); } } vTaskDelay(portTICK_PERIOD_MS*50); @@ -603,9 +619,15 @@ void parseSDFileList(fs::FS &fs, const char * dirname, const char * parent, uint * is done. */ void createJSONFileList() { - createFile(SD, DIRECTORY_INDEX_FILE, "["); - parseSDFileList(SD, "/", NULL, FS_DEPTH); - appendToFile(SD, DIRECTORY_INDEX_FILE, "]"); + #ifdef SD_MMC_1BIT_MODE + createFile(SD_MMC, DIRECTORY_INDEX_FILE, "["); + parseSDFileList(SD_MMC, "/", NULL, FS_DEPTH); + appendToFile(SD_MMC, DIRECTORY_INDEX_FILE, "]"); + #else + createFile(SD, DIRECTORY_INDEX_FILE, "["); + parseSDFileList(SD, "/", NULL, FS_DEPTH); + appendToFile(SD, DIRECTORY_INDEX_FILE, "]"); + #endif isFirstJSONtNode = true; sendWebsocketData(0,30); } @@ -1543,7 +1565,11 @@ void playAudio(void *parameter) { #ifdef NEOPIXEL_ENABLE showRewind = true; #endif - audio.connecttoSD(*(playProperties.playlist + playProperties.currentTrackNumber)); + #ifdef SD_MMC_1BIT_MODE + audio.connecttoFS(SD_MMC, *(playProperties.playlist + playProperties.currentTrackNumber)); + #else + audio.connecttoSD(*(playProperties.playlist + playProperties.currentTrackNumber)); + #endif loggerNl((char *) FPSTR(trackStart), LOGLEVEL_INFO); trackCommand = 0; continue; @@ -1666,13 +1692,21 @@ void playAudio(void *parameter) { playProperties.playlistFinished = false; } else { // Files from SD - if (!SD.exists(*(playProperties.playlist + playProperties.currentTrackNumber))) { // Check first if file/folder exists + #ifdef SD_MMC_1BIT_MODE + if (!SD_MMC.exists(*(playProperties.playlist + playProperties.currentTrackNumber))) { // Check first if file/folder exists + #else + if (!SD.exists(*(playProperties.playlist + playProperties.currentTrackNumber))) { // Check first if file/folder exists + #endif snprintf(logBuf, serialLoglength, "Datei/Ordner '%s' existiert nicht", *(playProperties.playlist + playProperties.currentTrackNumber)); loggerNl(logBuf, LOGLEVEL_ERROR); playProperties.trackFinished = true; continue; } else { - audio.connecttoSD(*(playProperties.playlist + playProperties.currentTrackNumber)); + #ifdef SD_MMC_1BIT_MODE + audio.connecttoFS(SD_MMC, *(playProperties.playlist + playProperties.currentTrackNumber)); + #else + audio.connecttoSD(*(playProperties.playlist + playProperties.currentTrackNumber)); + #endif #ifdef NEOPIXEL_ENABLE showPlaylistProgress = true; #endif @@ -1718,6 +1752,7 @@ void playAudio(void *parameter) { } +#ifdef RFID_READER_TYPE_MFRC522 // Instructs RFID-scanner to scan for new RFID-tags void rfidScanner(void *parameter) { static MFRC522 mfrc522(RFID_CS, RST_PIN); @@ -1780,8 +1815,113 @@ void rfidScanner(void *parameter) { } vTaskDelete(NULL); } +#endif + +#ifdef RFID_READER_TYPE_PN5180 +// Instructs RFID-scanner to scan for new RFID-tags using PN5180 +void rfidScanner(void *parameter) { + static PN5180ISO14443 nfc14443(RFID_CS, RFID_BUSY, RFID_RST); + static PN5180ISO15693 nfc15693(RFID_CS, RFID_BUSY, RFID_RST); + nfc14443.begin(); + nfc14443.reset(); + // show PN5180 reader version + uint8_t firmwareVersion[2]; + nfc14443.readEEprom(FIRMWARE_VERSION, firmwareVersion, sizeof(firmwareVersion)); + Serial.print(F("Firmware version=")); + Serial.print(firmwareVersion[1]); + Serial.print("."); + Serial.println(firmwareVersion[0]); + + // activate RF field + delay(4); + loggerNl((char *) FPSTR(rfidScannerReady), LOGLEVEL_DEBUG); + byte cardId[cardIdSize]; + char *cardIdString; + + for (;;) { + esp_task_wdt_reset(); + vTaskDelay(10); + if ((millis() - lastRfidCheckTimestamp) >= RFID_SCAN_INTERVAL) { + // Reset the loop if no new card is present on the sensor/reader. This saves the entire process when idle. + lastRfidCheckTimestamp = millis(); + // 1. check for an ISO-14443 card + nfc14443.reset(); + nfc14443.setupRF(); + uint8_t uid[10]; + if (nfc14443.isCardPresent() && nfc14443.readCardSerial(uid)) { + cardIdString = (char *) malloc(cardIdSize*3 +1); + if (cardIdString == NULL) { + logger((char *) FPSTR(unableToAllocateMem), LOGLEVEL_ERROR); + #ifdef NEOPIXEL_ENABLE + showLedError = true; + #endif + continue; + } + uint8_t n = 0; + logger((char *) FPSTR(rfidTagDetected), LOGLEVEL_NOTICE); + for (uint8_t i=0; iping(); } else if (type == WS_EVT_DISCONNECT) { //client disconnected - Serial.printf("ws[%s][%u] disconnect: %u\n", server->url(), client->id()); + Serial.printf("ws[%s][%u] disconnect: %u\n", server->url(), uint(client->id())); } else if (type == WS_EVT_ERROR) { //error was received from the other end Serial.printf("ws[%s][%u] error(%u): %s\n", server->url(), client->id(), *((uint16_t*)arg), (char*)data); @@ -3375,7 +3523,11 @@ void webserverStart(void) { }); wServer.on("/files", HTTP_GET, [](AsyncWebServerRequest *request) { + #ifdef SD_MMC_1BIT_MODE + request->send(SD_MMC, DIRECTORY_INDEX_FILE, "application/json"); + #else request->send(SD, DIRECTORY_INDEX_FILE, "application/json"); + #endif }); wServer.onNotFound(notFound); @@ -3414,8 +3566,11 @@ void webserverStart(void) { return NULL; } namespace_ID = FindNsID (nvs, _namespace) ; // Find ID of our namespace in NVS - - File backupFile = SD.open(_destFile, FILE_WRITE); + #ifdef SD_MMC_1BIT_MODE + File backupFile = SD_MMC.open(_destFile, FILE_WRITE); + #else + File backupFile = SD.open(_destFile, FILE_WRITE); + #endif if (!backupFile) { return false; } @@ -3536,13 +3691,17 @@ void setup() { ); #endif - // Init uSD-SPI - pinMode(SPISD_CS, OUTPUT); - digitalWrite(SPISD_CS, HIGH); #ifndef SINGLE_SPI_ENABLE + #ifdef SD_MMC_1BIT_MODE + pinMode(2, INPUT_PULLUP); + #else + // Init uSD-SPI + pinMode(SPISD_CS, OUTPUT); + digitalWrite(SPISD_CS, HIGH); spiSD.begin(SPISD_SCK, SPISD_MISO, SPISD_MOSI, SPISD_CS); spiSD.setFrequency(1000000); + #endif #else //SPI.begin(RFID_SCK, RFID_MISO, RFID_MOSI); SPI.begin(); @@ -3550,7 +3709,11 @@ void setup() { #endif #ifndef SINGLE_SPI_ENABLE + #ifdef SD_MMC_1BIT_MODE + while (!SD_MMC.begin("/sdcard", true)) { + #else while (!SD.begin(SPISD_CS, spiSD)) { + #endif #else while (!SD.begin(SPISD_CS)) { #endif @@ -3565,6 +3728,24 @@ void setup() { } + // show SD card type + #ifdef SD_MMC_1BIT_MODE + Serial.println("SD card mounted in SD_MMC 1 Bit mode"); + uint8_t cardType = SD_MMC.cardType(); + #else + Serial.println("SD card mounted in SPI mode"); + uint8_t cardType = SD.cardType(); + #endif + if(cardType == CARD_MMC){ + Serial.println("MMC"); + } else if(cardType == CARD_SD){ + Serial.println("SDSC"); + } else if(cardType == CARD_SDHC){ + Serial.println("SDHC"); + } else { + Serial.println("UNKNOWN"); + } + #ifdef HEADPHONE_ADJUST_ENABLE pinMode(HP_DETECT, INPUT); headphoneLastDetectionState = digitalRead(HP_DETECT); @@ -3847,10 +4028,17 @@ void setup() { /** * Create empty Index json file when no file exists. */ - if(!fileExists(SD,DIRECTORY_INDEX_FILE)){ - createFile(SD,DIRECTORY_INDEX_FILE,"[]"); - ESP.restart(); - } + #ifdef SD_MMC_1BIT_MODE + if(!fileExists(SD_MMC,DIRECTORY_INDEX_FILE)){ + createFile(SD_MMC,DIRECTORY_INDEX_FILE,"[]"); + ESP.restart(); + } + #else + if(!fileExists(SD,DIRECTORY_INDEX_FILE)){ + createFile(SD,DIRECTORY_INDEX_FILE,"[]"); + ESP.restart(); + } + #endif bootComplete = true; Serial.print(F("Free heap: ")); diff --git a/src/settings.h b/src/settings.h index de1f63c..578acef 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,7 +1,7 @@ #include "Arduino.h" //########################## MODULES ################################# -//#define MDNS_ENABLE // When enabled, you don't have to handle with Tonuino's IP-address. If hostname is set to "tonuino", you can reach it via tonuino.local +#define MDNS_ENABLE // When enabled, you don't have to handle with Tonuino's IP-address. If hostname is set to "tonuino", you can reach it via tonuino.local #define MQTT_ENABLE // Make sure to configure mqtt-server and (optionally) username+pwd #define FTP_ENABLE // Enables FTP-server #define NEOPIXEL_ENABLE // Don't forget configuration of NUM_LEDS if enabled @@ -12,18 +12,33 @@ #define MEASURE_BATTERY_VOLTAGE // Enables battery-measurement via GPIO (ADC) and voltage-divider //#define PLAY_LAST_RFID_AFTER_REBOOT // When restarting Tonuino, the last RFID that was active before, is recalled and played -//#define SINGLE_SPI_ENABLE // If only one SPI-instance should be used instead of two (not yet working!) //#define BLUETOOTH_ENABLE // Doesn't work currently (so don't enable) as there's not enough DRAM available +//################## select SD card mode ############################# +//#define SD_MMC_1BIT_MODE // run SD card in SD-MMC 1Bit mode +//#define SINGLE_SPI_ENABLE // If only one SPI-instance should be used instead of two (not yet working!) + +//################## select RFID reader ############################## +#define RFID_READER_TYPE_MFRC522 // use MFRC522 +//#define RFID_READER_TYPE_PN5180 //################## GPIO-configuration ############################## -// uSD-card-reader (via SPI) -#define SPISD_CS 15 // GPIO for chip select (SD) -#ifndef SINGLE_SPI_ENABLE - #define SPISD_MOSI 13 // GPIO for master out slave in (SD) => not necessary for single-SPI - #define SPISD_MISO 16 // GPIO for master in slave ou (SD) => not necessary for single-SPI - #define SPISD_SCK 14 // GPIO for clock-signal (SD) => not necessary for single-SPI +#ifdef SD_MMC_1BIT_MODE + // uSD-card-reader (via SD-MMC 1Bit) + // + // SD_MMC uses fixed pins + // MOSI 15 + // SCKK 14 + // MISO 2 // hardware pullup may required +#else + // uSD-card-reader (via SPI) + #define SPISD_CS 15 // GPIO for chip select (SD) + #ifndef SINGLE_SPI_ENABLE + #define SPISD_MOSI 13 // GPIO for master out slave in (SD) => not necessary for single-SPI + #define SPISD_MISO 16 // GPIO for master in slave ou (SD) => not necessary for single-SPI + #define SPISD_SCK 14 // GPIO for clock-signal (SD) => not necessary for single-SPI + #endif #endif // RFID (via SPI) @@ -33,6 +48,10 @@ #define RFID_MISO 19 // GPIO for master in slave out (RFID) #define RFID_SCK 18 // GPIO for clock-signal (RFID) +#ifdef RFID_READER_TYPE_PN5180 + #define RFID_BUSY 16 // PN5180 BUSY PIN + #define RFID_RST 22 // PN5180 RESET PIN +#endif // I2S (DAC) #define I2S_DOUT 25 // Digital out (I2S) #define I2S_BCLK 27 // BCLK (I2S) From d6eee244f47ca4eb8b06fc5cae896229a138ebfe Mon Sep 17 00:00:00 2001 From: Torsten Stauder Date: Mon, 14 Dec 2020 00:43:07 +0100 Subject: [PATCH 2/3] Added boards to platformio.ini + WiFi-Fix --- platformio.ini | 46 +++++++++++++++++++++++++++++++++++++++++++--- src/main.cpp | 10 +++++----- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/platformio.ini b/platformio.ini index 663174f..deace44 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,16 +8,56 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html -;[env:nodemcu-32s] [env:lolin32] platform = espressif32 -;board = nodemcu-32s board = lolin32 framework = arduino monitor_speed = 115200 board_build.partitions = no_ota.csv -;board_build.partitions = min_spiffs.csv +upload_port = /dev/cu.SLAB_USBtoUART +monitor_port = /dev/cu.SLAB_USBtoUART +[env:lolin_d32] +platform = espressif32 +board = lolin_d32 +framework = arduino +monitor_speed = 115200 +board_build.partitions = no_ota.csv +upload_port = /dev/cu.SLAB_USBtoUART +monitor_port = /dev/cu.SLAB_USBtoUART + +[env:lolin_d32_pro] +platform = espressif32 +board = lolin_d32_pro +framework = arduino +monitor_speed = 115200 +board_build.partitions = no_ota.csv +upload_port = /dev/cu.SLAB_USBtoUART +monitor_port = /dev/cu.SLAB_USBtoUART + +[env:nodemcu-32s] +platform = espressif32 +board = nodemcu-32s +framework = arduino +monitor_speed = 115200 +board_build.partitions = no_ota.csv +upload_port = /dev/cu.SLAB_USBtoUART +monitor_port = /dev/cu.SLAB_USBtoUART + +[env:az-delivery-devkit-v4] +platform = espressif32 +board = az-delivery-devkit-v4 +framework = arduino +monitor_speed = 115200 +board_build.partitions = no_ota.csv +upload_port = /dev/cu.SLAB_USBtoUART +monitor_port = /dev/cu.SLAB_USBtoUART + + +;;; Change upload/monitor-port of your board regarding your operating-system! +;MAC: /dev/cu.SLAB_USBtoUART +;WINDOWS: COM3 +;LINUX: /dev/ttyUSB0 (if it's the first USB-device attached, otherwise increase number) lib_deps = https://github.com/schreibfaul1/ESP32-audioI2S.git diff --git a/src/main.cpp b/src/main.cpp index 8f423e9..962f4e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1881,9 +1881,9 @@ void rfidScanner(void *parameter) { nfc15693.reset(); nfc15693.setupRF(); // check for ICODE-SLIX2 password protected tag - // put your privacy password here, e.g.: + // put your privacy password here, e.g.: // https://de.ifixit.com/Antworten/Ansehen/513422/nfc+Chips+f%C3%BCr+tonies+kaufen - uint8_t password[] = {0x01, 0x02, 0x03, 0x04}; + uint8_t password[] = {0x01, 0x02, 0x03, 0x04}; ISO15693ErrorCode myrc = nfc15693.disablePrivacyMode(password); if (ISO15693_EC_OK == myrc) { Serial.println("disable PrivacyMode successful"); @@ -1916,7 +1916,7 @@ void rfidScanner(void *parameter) { } xQueueSend(rfidCardQueue, &cardIdString, 0); } - } + } } vTaskDelete(NULL); } @@ -3108,7 +3108,7 @@ wl_status_t wifiManager(void) { // Get (optional) hostname-configration from NVS String hostname = prefsSettings.getString("Hostname", "-1"); if (hostname.compareTo("-1")) { - WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); + //WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); WiFi.setHostname(hostname.c_str()); snprintf(logBuf, serialLoglength, "%s: %s", (char *) FPSTR(restoredHostnameFromNvs), hostname.c_str()); loggerNl(logBuf, LOGLEVEL_INFO); @@ -3713,7 +3713,7 @@ void setup() { while (!SD_MMC.begin("/sdcard", true)) { #else while (!SD.begin(SPISD_CS, spiSD)) { - #endif + #endif #else while (!SD.begin(SPISD_CS)) { #endif From e7f318528301492a13cb974820b8bf4e3752ccef Mon Sep 17 00:00:00 2001 From: tueddy Date: Tue, 15 Dec 2020 23:01:28 +0100 Subject: [PATCH 3/3] PN5180 has no function isNewCardPresent: do not recognize the same card again and again. compare with last cardId Show different card ISO-14443 / ISO15693 in debug output Add a welcome message: Tonuino ESP-32 --- src/logmessages.h | 1 + src/logmessages_EN.h | 1 + src/main.cpp | 34 +++++++++++++++++++++++++++------- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/logmessages.h b/src/logmessages.h index 8e08bea..d7078a4 100644 --- a/src/logmessages.h +++ b/src/logmessages.h @@ -47,6 +47,7 @@ static const char endOfPlaylistReached[] PROGMEM = "Ende der Playlist erreicht." static const char trackStartatPos[] PROGMEM = "Titel wird abgespielt ab Position"; static const char rfidScannerReady[] PROGMEM = "RFID-Tags koennen jetzt gescannt werden..."; static const char rfidTagDetected[] PROGMEM = "RFID-Karte erkannt: "; +static const char rfid15693TagDetected[] PROGMEM = "RFID-Karte (ISO-15693) erkannt: "; static const char rfidTagReceived[] PROGMEM = "RFID-Karte empfangen"; static const char rfidTagUnknownInNvs[] PROGMEM = "RFID-Karte ist im NVS nicht hinterlegt."; static const char goToSleepDueToIdle[] PROGMEM = "Gehe in Deep Sleep wegen Inaktivität..."; diff --git a/src/logmessages_EN.h b/src/logmessages_EN.h index 497793e..a63cf2f 100644 --- a/src/logmessages_EN.h +++ b/src/logmessages_EN.h @@ -47,6 +47,7 @@ static const char endOfPlaylistReached[] PROGMEM = "Reached end of playlist."; static const char trackStartatPos[] PROGMEM = "Starting track at position"; static const char rfidScannerReady[] PROGMEM = "RFID-tags can now be applied..."; static const char rfidTagDetected[] PROGMEM = "RFID-tag detected: "; +static const char rfid15693TagDetected[] PROGMEM = "RFID-Karte (ISO-15693) erkannt: "; static const char rfidTagReceived[] PROGMEM = "RFID-tag received"; static const char rfidTagUnknownInNvs[] PROGMEM = "RFID-tag is unkown to NVS."; static const char goToSleepDueToIdle[] PROGMEM = "Going to deepsleep due to inactivity-timer..."; diff --git a/src/main.cpp b/src/main.cpp index 8f423e9..7b71c83 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1837,8 +1837,9 @@ void rfidScanner(void *parameter) { // activate RF field delay(4); loggerNl((char *) FPSTR(rfidScannerReady), LOGLEVEL_DEBUG); - byte cardId[cardIdSize]; + byte cardId[cardIdSize], lastCardId[cardIdSize]; char *cardIdString; + uint8_t lastUID[10]; for (;;) { esp_task_wdt_reset(); @@ -1859,11 +1860,15 @@ void rfidScanner(void *parameter) { #endif continue; } + for (uint8_t i=0; i