diff --git a/README.md b/README.md index b0d7743..a36ef07 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,9 @@ Finally, the long announced Tonuino-PCB for Wemos' Lolin32 is [there](https://gi * 08.12.2020: Reworked MQTT-timeout-Management * 09.12.2020: mDNS-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 (thanks @mariolukas for contribution!) + (untested) PCB added for Wemos Lolin D32 + gerberfiles for headphone-PCB -More to come... +* 18.12.2020: Added SD-MMC 1 Bit mode: This mode needs one PIN less and has almost double speed than SPI mode (thanks @tueddy for contribution!) +* 18.12.2020: Added support for the PN5180 reader. The PN5180 has better RFID range/sensitivity and can read ISO-15693 / iCode SLIX2 tags aka Tonies (thanks @tueddy for contribution!) +
More to come... ## Known bugs * Some webstreams don't run. Guess it's a combination of saturated connection-pool and lack of heap-memory. Works probably better if ESP32-WROVER is used, as this chip has PSRAM. @@ -47,7 +49,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. @@ -86,9 +89,8 @@ Depending on the develboard you're using and the needs you have, there are diffe A lot of wiring is necessary to get ESP32-Tonuino working. After my first experiments on a breadboard I soldered all the stuff onto a board in order to avoid wild-west-cabling. Especially for the interconnect between uC and uSD-card-reader make sure to use short wires (like 10cm or so)! As of my experience with a breadbord, male/male-connectors are better than female/female-connectors. Important: you can easily connect another I2S-DACs by just connecting them in parallel to the I2S-pins (DIN, BCLK, LRC). This is true for example if you plan to integrate a [line/headphone-pcb](https://www.adafruit.com/product/3678). In general, this runs fine. But unfortunately especially this board lacks of a headphone jack, that takes note if a plug is inserted or not. Best way is to use a [headphone jack](https://www.conrad.de/de/p/cliff-fcr1295-klinken-steckverbinder-3-5-mm-buchse-einbau-horizontal-polzahl-3-stereo-schwarz-1-st-705830.html) that has a pin that is pulled to GND, if there's no plug and vice versa. Using for example a MOSFET-circuit, this GND-signal can be inverted in a way, that MAX98357.SD is pulled down to GND if there's a plug. Doing that will turn off the speaker immediately if there's a plug and vice versa. Have a look at the PCB-folder in order to view the detailed solution. Here's an example for such a [headphone-pcb](https://github.com/biologist79/Tonuino-ESP32-I2S/tree/master/PCBs/Headphone%20with%20PCM5102a%20and%20TDA1308) that makes use of GND.
Have a look at my PCB in the subfolder Hardware-Platforms/Wemos Lolin32. Probably this makes things easier for you. - ## Wiring (2 SPI-instances) -Uses two SPI-instances. The first one for the RFID-reader and the second for SD-card-reader. This is also the setup, I personally use.
+Uses two SPI-instances. The first one for the RFID-reader and the second for SD-card-reader. This is also the [setup, I personally use](https://github.com/biologist79/Tonuino-ESP32-I2S/tree/master/PCBs/Wemos%20Lolin32).
| ESP32 (GPIO) | Hardware | Pin | Comment | | ------------- | --------------------- | ------ | ------------------------------------------------------------ | | 5 V | SD-reader | VCC | Connect to p-channel MOSFET for power-saving when uC is off | @@ -131,6 +133,18 @@ Uses two SPI-instances. The first one for the RFID-reader and the second for SD- Optionally, GPIO 17 can be used to drive a Mosfet-circuit in order to switch off peripherals (SD, Neopixel, RFID and MAX98357a) if ESP32 is in deepsleep. lease 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. If you need further informations on transistor-circuits visit this [website](https://dl6gl.de/schalten-mit-transistoren.html).
In general I recommend using a [uSD-card-reader](https://www.ebay.de/itm/Micro-SPI-Kartenleser-Card-Reader-2GB-SD-8GB-SDHC-Card-3-3V-ESP8266-Arduino-NEU/333796577968) that can be run solely with 3.3V (doesn't have a 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 :-). And by the way: when LiPo-battery is connected, there's no 5V. That's why I designed my [Lolin32-PCB](https://github.com/biologist79/Tonuino-ESP32-I2S/tree/master/PCBs/Wemos%20Lolin32) with 3.3V only. +## 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. Have to admit I had some problems to get this running. Seems to be connected properly, but nothing happens when an RFID-tag is applied. Maybe anybody else wants to point out :-) @@ -170,9 +184,25 @@ 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 SD-card-reader already integrated (Lolin D32 Pro, several TTGO-boards), 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/boot 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. Please note: the code-basis is outdated. Will need to re-integrate it into my master-branch... + ## WiFi WiFi is mandatory for webgui, FTP and MQTT. However, WiFi can be temporarily or permanently disabled. There are two ways to do that: * Use a special modification-card that can be configured via webgui diff --git a/platformio.ini b/platformio.ini index b8911b9..deace44 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,26 +8,65 @@ ; 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 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/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 b89d46f..5c33633 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 @@ -576,8 +589,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); @@ -587,7 +603,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); @@ -604,9 +620,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); } @@ -1546,7 +1568,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; @@ -1669,13 +1695,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 @@ -1721,6 +1755,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); @@ -1783,7 +1818,122 @@ 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], lastCardId[cardIdSize]; + char *cardIdString; + uint8_t lastUID[10]; + + 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; + } + 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); @@ -3388,7 +3546,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); @@ -3428,8 +3590,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; } @@ -3554,13 +3719,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(); @@ -3568,7 +3737,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 @@ -3583,6 +3756,34 @@ void setup() { } + // welcome message + loggerNL(""); + loggerNL("_____ _____ _____ _____ _____ "); + Serial.println("|_ _|___ ___| | | | | | | "); + Serial.println(" | | | . | | | |- -| | | | | | "); + Serial.println(" |_| |___|_|_|_____|_____|_|___|_____| "); + Serial.println(" ESP-32 version"); + Serial.println(""); + + // 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 + Serial.print("SD card type: "); + 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); @@ -3865,10 +4066,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)