This PCB was kindly provided by a user (@mariolukas) of my Tonuino-fork and I didn't test it myself.
## ESP32 I2S Breakout Carrier PCB
## ESP32 I2S Breakout Carrier PCB
This is a simple PCB which makes wiring the whole stuff much easier. It contains connections for all components which are described in the projects wiring table.
I used an ESP32 form AZ-Delivery but every Pin-Compatible ESP32 Board will do the job.
This is a simple PCB which makes wiring the whole stuff much easier. It contains connections for all components which are described in the projects wiring table. An ESP32 from AZ-Delivery was used but every pin-Compatible ESP32-board will do the job.


The image shows my first boards which came with a litte wiring bug. The bug is fixed in the current version.
I ordered my board at aisler.net, there is already and upload available.
The image shows my first boards which came with a litte wiring bug. The bug is fixed in the current version. I ordered my board at aisler.net, there is already and upload available.
The PCB does not provide an option for charing or power management (including step down/up). It provides a pinout for 5V Input.
## Todos
This PCB does not provide an option for charing or power-management (including step down/up). It provides a pinout for 5V-input.
## Antenna Improvements
It is recommended to solder an external antenna to the ESP32 for preventing connection issues. Cheap ESP32 boards come with an antenna which is laying on the PCB. The newer ones provide an ESP32 board where the antenna part protrudes over the edge.
## Antenna-improvements
It is recommended to solder an external antenna to the ESP32 for preventing connection issues. Cheap ESP32 boards come with an antenna which is laying on the PCB. The newer ones provide an ESP32-board where the antenna-part protrudes over the edge.
You can find some useful tips for soldering an antenna to the old ones here:
You can find some useful tips for soldering an antenna to the old ones here:
This is a pcb, that was kindly provided by a user of my Tonuino-fork. It makes use of a DAC named 'PCM5102A' with a TDA1308 as amp. PCM5102A supports I2S, so it can connected in parallel to MAX98357a to the I2S-pins BCLK, LRC and DIN. Of course, it needs 3.3V and GND, too. Please note that SMD-technique is used. <br/>
This is a pcb, that was kindly provided by a user of my Tonuino-fork. It makes use of a DAC named 'PCM5102A' with a TDA1308 as amp. PCM5102A supports I2S, so it can connected in parallel to MAX98357a to the I2S-pins BCLK, LRC and DIN. Of course, it needs 3.3V and GND, too. Please note that SMD-technique is used. <br/>
The 6th pin of connector J1 is used to indicate whether there's a plug or not. That means if there is a plug, this pin is pulled to GND and therefore can be used to connect to MAX98357.SD. Doing so will mute MAX's amp and vice versa. Off course you need a special [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) to use this feature. Additionaly this 6th pin can be connected to the ESP32 in order to make use of the feature `HEADPHONE_ADJUST_ENABLE`. Doing so can optionally limit the headphone's maximum volume (configureable via GUI). <br/>
The 6th pin of connector J1 is used to indicate whether there's a plug or not. That means if there is a plug, this pin is pulled to GND and therefore can be used to connect to MAX98357.SD. Doing so will mute MAX's amp and vice versa. Of course you need a special [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) to use this feature. Additionaly this 6th pin can be connected to the ESP32 in order to make use of the feature `HEADPHONE_ADJUST_ENABLE`. Doing so can optionally limit the headphone's maximum volume (configureable via GUI). <br/>
## Disclaimer
## Disclaimer
PCB-circuit is provided 'as is' without warranty. As previously stated it was kindly provided by a user and I only can give limited support to it. However: it runs fine without any problems in my Tonuinos.
PCB-circuit is provided 'as is' without warranty. As previously stated it was kindly provided by a user and I only can give limited support to it. However: it runs fine without any problems in my Tonuinos.
* Better don't solder Lolin D32 directly to the PCB. I recommend to make use of female connectors instead (link below).
* Better don't solder Lolin D32 directly to the PCB. I recommend to make use of female connectors instead (link below).
* When ordering a LiPo-battery, make sure to use [one](https://www.eremit.de/p/eremit-3-7v-2500mah-lipo-104050-jst-ph-2-0mm) with deep discharge protection! This is really really really important!!!
* When ordering a LiPo-battery, make sure to use [one](https://www.eremit.de/p/eremit-3-7v-2500mah-lipo-104050-jst-ph-2-0mm) with deep discharge protection! This is really really really important!!!
* Doesn't (currently) support SD-MMC and RFID-reader PN5180
## Hardware-setup
## Hardware-setup
The heart of my project is an ESP32 on a [Wemos Lolin D32 development-board](https://de.aliexpress.com/item/32808551116.html). Make sure to install the drivers for the USB/Serial-chip (CP2102 e.g.).
The heart of my project is an ESP32 on a [Wemos Lolin D32 development-board](https://de.aliexpress.com/item/32808551116.html). Make sure to install the drivers for the USB/Serial-chip (CP2102 e.g.).
@ -23,6 +23,7 @@ After I've been asked many times to provide a PCB, I finally did so :-) It makes
* In contrast to Lolin D32, Lolin32 doesn't feature an integrated voltage-divider. That's why on the lower left there's a JST-PH2.0-connector to connect the LiPo-battery. Make sure to connect (+) to the left und GND to the right. From there you need to solder two short wires (5cm or so) onto the pcb with a JST-PH2.0-connector attached on the other side. This one needs to be plugged into Lolin32 (see pictures-folder). Please note: Lolin's JST-PH2.0-connector needs (+) left side and GND right side. Don't be confused if black/red-colouring of the JST-wires used seems "weird" because is reversed (black => (+); red => GND).
* In contrast to Lolin D32, Lolin32 doesn't feature an integrated voltage-divider. That's why on the lower left there's a JST-PH2.0-connector to connect the LiPo-battery. Make sure to connect (+) to the left und GND to the right. From there you need to solder two short wires (5cm or so) onto the pcb with a JST-PH2.0-connector attached on the other side. This one needs to be plugged into Lolin32 (see pictures-folder). Please note: Lolin's JST-PH2.0-connector needs (+) left side and GND right side. Don't be confused if black/red-colouring of the JST-wires used seems "weird" because is reversed (black => (+); red => GND).
* Better don't solder Lolin32 directly to the PCB. I recommend to make use of female connectors instead (link below).
* Better don't solder Lolin32 directly to the PCB. I recommend to make use of female connectors instead (link below).
* When ordering a LiPo-battery, make sure to use [one](https://www.eremit.de/p/eremit-3-7v-2500mah-lipo-104050-jst-ph-2-0mm) with deep discharge protection! This is really really really important!!!
* When ordering a LiPo-battery, make sure to use [one](https://www.eremit.de/p/eremit-3-7v-2500mah-lipo-104050-jst-ph-2-0mm) with deep discharge protection! This is really really really important!!!
* Doesn't (currently) support SD-MMC and RFID-reader PN5180
## Hardware-setup
## Hardware-setup
The heart of my project is an ESP32 on a [Wemos Lolin32 development-board](https://www.ebay.de/itm/4MB-Flash-WEMOS-Lolin32-V1-0-0-WIFI-Bluetooth-Card-Based-ESP-32-ESP-WROOM-32/162716855489). Make sure to install the drivers for the USB/Serial-chip (CP2102 e.g.).
The heart of my project is an ESP32 on a [Wemos Lolin32 development-board](https://www.ebay.de/itm/4MB-Flash-WEMOS-Lolin32-V1-0-0-WIFI-Bluetooth-Card-Based-ESP-32-ESP-WROOM-32/162716855489). Make sure to install the drivers for the USB/Serial-chip (CP2102 e.g.).
@ -20,12 +20,13 @@ Finally, the long announced Tonuino-PCB for Wemos' Lolin32 is [there](https://gi
* 08.12.2020: Reworked MQTT-timeout-Management
* 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.
* 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
* 11.12.2020: Revised GUI-design (thanks @mariolukas for contribution!) + (untested) PCB added for Wemos Lolin D32 + gerberfiles for headphone-PCB
* 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!)
* 18.12.2020: Added SD-MMC 1 Bit-mode (`SD_MMC_1BIT_MODE`). This mode needs one GPIO less and provides almost doubled speed (compared to SPI) for FTP-transfers (thanks @tueddy for contribution!)
* 18.12.2020: Added support for RFID-reader PN5180 (`RFID_READER_TYPE_PN5180`). PN5180 has better RFID-range/sensitivity and can read ISO-15693 / iCode SLIX2-tags aka 'Tonies' (thanks @tueddy for contribution!)
<br/>More to come...
<br/>More to come...
## Known bugs
## 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.
* 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. Advice: Don't enable modules (e.g. MQTT) if you don't need them as this could save memory.
* English translation for webgui is currently outdated. This will be fixed soon when i18n-support will be integrated.
## Disclaimer
## Disclaimer
This is a **fork** of the popular [Tonuino-project](https://github.com/xfjx/TonUINO) which means, that it only shares the basic concept of controlling a music-player by RFID-tags and buttons. **Said this I want to rule out, that the code-basis is completely different and developed by myself**. So there might be features, that are supported by my fork whereas others are missing or implemented differently. For sure both share that it's non-profit, DIY and developed on [Arduino](https://www.arduino.cc/).
This is a **fork** of the popular [Tonuino-project](https://github.com/xfjx/TonUINO) which means, that it only shares the basic concept of controlling a music-player by RFID-tags and buttons. **Said this I want to rule out, that the code-basis is completely different and developed by myself**. So there might be features, that are supported by my fork whereas others are missing or implemented differently. For sure both share that it's non-profit, DIY and developed on [Arduino](https://www.arduino.cc/).
@ -41,7 +42,7 @@ The basic idea of Tonuino is to provide a way, to use the Arduino-platform for a
## Hardware-setup
## Hardware-setup
The heart of my project is an ESP32 on a [Wemos Lolin32 development-board](https://www.ebay.de/itm/4MB-Flash-WEMOS-Lolin32-V1-0-0-WIFI-Bluetooth-Card-Based-ESP-32-ESP-WROOM-32/162716855489). If ordered in China (Aliexpress, eBay e.g.) it's pretty cheap (around 4€) but even in Europe it's only around 8€. Make sure to install the drivers for the USB/Serial-chip (CP2102 e.g.).
The heart of my project is an ESP32 on a [Wemos Lolin32 development-board](https://www.ebay.de/itm/4MB-Flash-WEMOS-Lolin32-V1-0-0-WIFI-Bluetooth-Card-Based-ESP-32-ESP-WROOM-32/162716855489). If ordered in China (Aliexpress, eBay e.g.) it's pretty cheap (around 4€) but even in Europe it's only around 8€. Make sure to install the drivers for the USB/Serial-chip (CP2102 e.g.).
@ -55,19 +56,20 @@ Most of them can be ordered cheaper directly in China. It's just a give an short
## Getting Started
## Getting Started
* Arduino-IDE can be used but you need to satisfy dependencies for all the libraries listed in `platformio.ini`yourself.
* Instead I recommend to install Microsoft's [Visual Studio Code](https://code.visualstudio.com/). This is a popular and powerful IDE that gives you the ability to install tons of plugins.
* Arduino-IDE can be used but you need to satisfy dependencies for all the libraries listed in `platformio.ini`manually.
* Instead I recommend to install Microsoft's [Visual Studio Code](https://code.visualstudio.com/). This is a popular and powerful IDE that gives you the ability to install tons of (well-supported) plugins.
* Install [Platformio Plugin](https://platformio.org/install/ide?install=vscode) into [Visual Studio Code](https://code.visualstudio.com/) and make sure to have a look at the [documentation](https://docs.platformio.org/en/latest/integration/ide/pioide.html).
* Install [Platformio Plugin](https://platformio.org/install/ide?install=vscode) into [Visual Studio Code](https://code.visualstudio.com/) and make sure to have a look at the [documentation](https://docs.platformio.org/en/latest/integration/ide/pioide.html).
* Install [Git](https://git-scm.com/downloads) and make a copy ("clone") my repository to your local computer using `git clone https://github.com/biologist79/Tonuino-ESP32-I2S.git`. Using git you can keep your local repository easily up to date without doing copy'n'paste.
* Install [Git](https://git-scm.com/downloads) and make a copy ("clone") my repository to your local computer using `git clone https://github.com/biologist79/Tonuino-ESP32-I2S.git`. Using git you can keep your local repository easily up to date without doing copy'n'paste.
* (Optional) Install [Gitlens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens) as plugin (to have advanced Git-support).
* Now, that the git-repository is saved locally, import this folder into Platformio as a project.
* Now, that the git-repository is saved locally, import this folder into Platformio as a project.
* There's a file called `platformio.ini`, that contains the configuration of the develboard (e.g. env:lolin32). Platformio supports hundrets of boards out of the box. So probably, you need to change that configuration. Guess Lolin32 is described in platformio.ini but you need Lolin D32, then lookup Platformio's [documentation](https://docs.platformio.org/en/latest/boards/espressif32/lolin_d32.html) to know what to change.
* There's a file called `platformio.ini`, that contains the configuration for different develboards (e.g. env:lolin32). Platformio supports hundrets of boards out of the box. So probably you need to change/extend that configuration. Guess Lolin32 is described in platformio.ini but you need Lolin D32, then lookup Platformio's [documentation](https://docs.platformio.org/en/latest/boards/espressif32/lolin_d32.html) to know what to change.
* Depending on your operating system (Windows, Mac OS, Linux), you probably need to change `upload_port`and `monitor_port` as well.
* Depending on your operating system (Windows, Mac OS, Linux), you probably need to change `upload_port`and `monitor_port` as well.
* Edit `src/settings.h` according your needs. Especially GPIO-configuration is really important.
* Edit `src/settings.h` according your needs. Especially GPIO-configuration is really important.
* Connect your develboard via USB, click the alien-head to the left and run `Upload and Monitor`. All libraries necessary should be fetched in background now followed by code-compilation. After that, your ESP32 is flashed with the firmware.
* Connect your develboard via USB, click the alien-head to the left and run `Upload and Monitor`. All libraries necessary should be fetched in background now followed by code-compilation. After that, your ESP32 is flashed with the firmware.
* Now have a look at the serial-output at the bottom of Visual Studio Code's windows.
* Now have a look at the serial-output at the bottom of Visual Studio Code's windows.
* If everything ran fine, at the first run, Tonuino should open an access-point with the name "Tonuino". Connect to this WiFi with your computer (or mobile) and enter `192.168.4.1` to your webbrowser. Enter WiFi-credentials and the hostname. After saving the configuraton, restart Tonuino.
* If everything ran fine, at the first run, Tonuino should open an access-point with the name "Tonuino". Connect to this WiFi with your computer (or mobile) and enter `192.168.4.1` to your webbrowser. Enter WiFi-credentials and the hostname. After saving the configuraton, restart Tonuino.
* Now Tonuino tries to join your WiFi. If that was successful, an IP is shown in the serial-console of Visual Studio Code. You can call Tonuino's GUI via this IP. If mDNS-feature is active in `src/settings.h`, you can use the hostname configured extended by .local. So if you configured `tonuino` as hostname, you can use `tonuino.local` for webgui and FTP.
* Now Tonuino tries to join your WiFi. If that was successful, an IP is shown in the serial-console of Visual Studio Code. You can call Tonuino's GUI via this IP. If mDNS-feature is active in `src/settings.h`, you can use the hostname configured extended by .local. So if you configured `tonuino` as hostname, you can use `tonuino.local` for webgui and FTP.
* Via FTP you can upload data (don't expect it to be super fast). It's round about 185 kb/s if SD is in SPI-mode and 300 kB/s if SD is in MMC-mode (this feature will be released soon)
* Via FTP you can upload data (don't expect it to be super fast). It's round about 185 kb/s if SD is in SPI-mode and 300 kB/s if SD is in MMC-mode.
* Via webbrowser you can configure various settings and pair RFID-tags with actions.
* Via webbrowser you can configure various settings and pair RFID-tags with actions.
## Prerequisites / tipps
## Prerequisites / tipps
@ -84,28 +86,48 @@ Please note: via GUI upper and lower voltage cut-offs for visualisation of batte
* 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.
* 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 `MDNS_ENABLE` is enabled, your Tonuino is reachable via hostname.local. So if your Tonuino's hostname is 'tonuino', the address is `tonuino.local`.
## SD-card: SPI or SD-MMC (1 bit)-mode?
Having SD working is mandatory. So there are two modes available to access SD-cards: SPI and SD-MMC (1 bit).<br/>
Advantages SD-MMC (1 bit) over SPI:
* Needs only three GPIOs (instead of four)
* It is almost twice as fast in FTP-transfer
So why using SPI if SD-MMC is better? The primary problem of SD-MMC is: you cannot choose different GPIOs. That doesn't sound bad but this can (depends on the ESP-develboard) be a problem because GPIO2 is pulled HIGH in SD-MMC-mode. And if that's the case, you'll probably not able to flash the firmware as the ESP32 doesn't enter flash-mode. Tested it with Lolin32 and had to remove SD's wire to GPIO2 until flash-mode was entered. As soon as flash-mode was entered, it's safe to re-connect it. So be advised: SD-MMC is nice and fast, but if you want to update the firmware and ESP32 is deeply burried in Tonuino's enclosure, this can be problem.
## RFID: RC522 or PN5180?
RC522 is so to say the Tonuino-standard. It's cheap and works, but RFID-tag has to be placed near the reader. PN5180 instead has better RFID range/sensitivity and can read ISO-15693 / iCode SLIX2-tags aka 'Tonies'. Disadvantages: is a bit more expensive and needs more GPIOs (6 instead of 4). Refer PN5180's wire-section below for further informations.
## 3.3 or 5V?
* MAX98357a: provides more power at 5 V but also runs at 3.3 V
* Neopixel: specification says it needs 5 V but also runs at 3.3 V
* RC522: needs 3.3 V (don't power with 5 V!)
* SD: needs 3.3 V but if voltage-regulator is onboard, it can be connected to 5 V as well
* Rotary encoder: 3.3 V (don't power with 5 V! Encoder doens't care if connected to 3.3 or 5 V, but GPIOs of ESP32 do!)
So why choosing 3.3 V over 5 V?
* It's not necessary to mix up 3.3 and 5 V. Natively ESP32 operates at 3.3 V.
* If you plan to use battery-mode with a LiPo, there's no 5 V available (unless USB is connected).
That's why my design's focus is 3.3 V. If you want to use 5 V - do so. The Mosfet-circuit for saving power in deepsleep (see [Lolin32-schematics](https://github.com/biologist79/Tonuino-ESP32-I2S/blob/master/PCBs/Wemos%20Lolin32/Pictures/Tonuino%20V2-Schematics.pdf) as reference) works as well for 5 V.
## Wiring (general)
## Wiring (general)
Depending on the develboard you're using and the needs you have, there are different options available.
Depending on the develboard you're using and the needs you have, there are different options available.
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.<br/>
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.<br/>
Have a look at my PCB in the subfolder Hardware-Platforms/Wemos Lolin32. Probably this makes things easier for you.
Have a look at my PCB in the subfolder Hardware-Platforms/Wemos Lolin32. Probably this makes things easier for you.
## Wiring (2 SPI-instances)
## Wiring (2 SPI-instances: RC522 + SD)
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).<br/>
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).<br/>
| 5 V | SD-reader | VCC | Connect to p-channel MOSFET for power-saving when uC is off |
| 3.3 (5) V | SD-reader | VCC | Connect to p-channel MOSFET for power-saving when uC is off |
| GND | SD-reader | GND | |
| GND | SD-reader | GND | |
| 15 | SD-reader | CS | |
| 15 | SD-reader | CS | |
| 13 | SD-reader | MOSI | |
| 13 | SD-reader | MOSI | |
| 16 | SD-reader | MISO | |
| 16 | SD-reader | MISO | |
| 14 | SD-reader | SCK | |
| 14 | SD-reader | SCK | |
| 17 | RFID-reader | 3.3V | Connect directly to GPIO 17 for power-saving when uC is off |
| 3.3 V | RFID-reader | 3.3V | Connect directly to GPIO 17 for power-saving when uC is off |
| GND | RFID-reader | GND | |
| GND | RFID-reader | GND | |
| 21 | RFID-reader | CS/SDA | |
| 21 | RFID-reader | CS/SDA | |
| 23 | RFID-reader | MOSI | |
| 23 | RFID-reader | MOSI | |
| 19 | RFID-reader | MISO | |
| 19 | RFID-reader | MISO | |
| 18 | RFID-reader | SCK | |
| 18 | RFID-reader | SCK | |
| 5 V | MAX98357 | VIN | Connect to p-channel MOSFET for power-saving when uC is off |
| 5 / 3.3 V | MAX98357 | VIN | Connect to p-channel MOSFET for power-saving when uC is off |
| GND | MAX98357 | GND | |
| GND | MAX98357 | GND | |
| 25 | MAX98357 | DIN | |
| 25 | MAX98357 | DIN | |
| 27 | MAX98357 | BCLK | |
| 27 | MAX98357 | BCLK | |
@ -122,7 +144,7 @@ Uses two SPI-instances. The first one for the RFID-reader and the second for SD-
| GND | Button (previous) | | |
| GND | Button (previous) | | |
| 5 | Button (pause/play) | | |
| 5 | Button (pause/play) | | |
| GND | Button (pause/play) | | |
| GND | Button (pause/play) | | |
| 5 V | Neopixel | 5 V | Connect to p-channel MOSFET for power-saving when uC is off |
| 3.3 V | Neopixel | 5 V | Connect to p-channel MOSFET for power-saving when uC is off |
| GND | Neopixel | GND | |
| GND | Neopixel | GND | |
| 12 | Neopixel | DI | |
| 12 | Neopixel | DI | |
| 17 | N-channel Mosfet | Gate | |
| 17 | N-channel Mosfet | Gate | |
@ -133,7 +155,7 @@ 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). <br/>
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). <br/>
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.
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 (SDcard in 1 Bit SD-MMC mode) different to above
## Wiring (SD-card in 1 Bit SD-MMC mode) different to above
@ -141,26 +163,25 @@ In general I recommend using a [uSD-card-reader](https://www.ebay.de/itm/Micro-S
| 2 | SD-reader | MISO | 10K hardware pullup may be required |
| 2 | SD-reader | MISO | 10K hardware pullup may be required |
| 14 | SD-reader | SCK | |
| 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)
Make sure to enable `SD_MMC_1BIT_MODE` if you want to use this feature. SD-MMC-mode requires these fixed PINs listed above. You can find a good comparison of different SD-card-modes here: (https://www.instructables.com/Select-SD-Interface-for-ESP32/).
Advice: Double check that above PINs are not used elsewhere (e.g. GPIO2 is used as PREVIOUS_BUTTON as per default in settings.h).
## Wiring (1 SPI-instance) [EXPERIMENTAL, maybe not working!]
Basically the same as using 2 SPI-instances but...
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 :-)
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 :-)
| 5 V | MAX98357 | VIN | Connect to p-channel MOSFET for power-saving when uC is off |
| 5 / 3.3 V | MAX98357 | VIN | Connect to p-channel MOSFET for power-saving when uC is off |
| GND | MAX98357 | GND | |
| GND | MAX98357 | GND | |
| 25 | MAX98357 | DIN | |
| 25 | MAX98357 | DIN | |
| 27 | MAX98357 | BCLK | |
| 27 | MAX98357 | BCLK | |
@ -177,7 +198,7 @@ In this case RFID-reader + SD-reader share SPI's SCK, MISO and MOSI. But make su
| GND | Button (previous) | | |
| GND | Button (previous) | | |
| 5 | Button (pause/play) | | |
| 5 | Button (pause/play) | | |
| GND | Button (pause/play) | | |
| GND | Button (pause/play) | | |
| 5 V | Neopixel | 5 V | Connect to p-channel MOSFET for power-saving when uC is off |
| 5 / 3.3 V | Neopixel | 5 V | Connect to p-channel MOSFET for power-saving when uC is off |
| GND | Neopixel | GND | |
| GND | Neopixel | GND | |
| 12 | Neopixel | DI | |
| 12 | Neopixel | DI | |
| 17 | N-channel Mosfet | Gate | |
| 17 | N-channel Mosfet | Gate | |
@ -186,11 +207,12 @@ In this case RFID-reader + SD-reader share SPI's SCK, MISO and MOSI. But make su
## Wiring (PN5180 instead of MFRC522) different to above
## Wiring (PN5180 instead of MFRC522) different to above
PN5180 reader needs two more PIN's, RESET and BUSY. Double check PIN conflicts!
PN5180 reader needs two more PIN's, RESET and BUSY. Double check PIN conflicts!`RFID_READER_TYPE_PN5180` needs to be enabled to use this feature. Make sure to disable `RFID_READER_TYPE_MFRC522`!
staticconstcharsdMountedMmc1BitMode[]PROGMEM="Versuche SD-Karte wird im SD_MMC-Modus (1 Bit) zu mounten...";
staticconstcharsdMountedSpiMode[]PROGMEM="Versuche SD-Karte wird im SPI-Modus zu mounten...";
staticconstcharbackupRecoveryWebsite[]PROGMEM="<p>Das Backup-File wird eingespielt...<br />Zur letzten Seite <a href=\"javascript:history.back()\">zurückkehren</a>.</p>";
staticconstcharrestartWebsite[]PROGMEM="<p>Der Tonuino wird neu gestartet...<br />Zur letzten Seite <a href=\"javascript:history.back()\">zurückkehren</a>.</p>";
staticconstcharfailedToOpenDirectory[]PROGMEM="Failed to open directory";
staticconstcharfailedToOpenDirectory[]PROGMEM="Failed to open directory";
staticconstcharnotADirectory[]PROGMEM="Not a directory";
staticconstcharnotADirectory[]PROGMEM="Not a directory";
staticconstcharsdMountedMmc1Bit[]PROGMEM="SD-card in SD_MMC 1 Bit-mode configured...";
staticconstcharsdMountedSpi[]PROGMEM="SD card mounted in SPI-mode configured...";
staticconstcharbackupRecoveryWebsite[]PROGMEM="<p>Backup-file is being applied...<br />Back to <a href=\"javascript:history.back()\">last page</a>.</p>";
staticconstcharrestartWebsite[]PROGMEM="<p>Tonuino is being restarted...<br />Back to <a href=\"javascript:history.back()\">last page</a>.</p>";
boolpauseNeopixel=false;// Used to pause Neopixel-signalisation (while NVS-writes as this leads to exceptions; don't know why)
#endif
#endif
// MQTT
// MQTT
#ifdef MQTT_ENABLE
#ifdef MQTT_ENABLE
@ -255,9 +252,6 @@ AsyncWebServer wServer(80);
AsyncWebSocketws("/ws");
AsyncWebSocketws("/ws");
AsyncEventSourceevents("/events");
AsyncEventSourceevents("/events");
staticconstcharbackupRecoveryWebsite[]PROGMEM="<p>Das Backup-File wird eingespielt...<br />Zur letzten Seite <a href=\"javascript:history.back()\">zurückkehren</a>.</p>";
staticconstcharrestartWebsite[]PROGMEM="<p>Der Tonuino wird neu gestartet...<br />Zur letzten Seite <a href=\"javascript:history.back()\">zurückkehren</a>.</p>";
// Audio/mp3
// Audio/mp3
#ifndef SD_MMC_1BIT_MODE
#ifndef SD_MMC_1BIT_MODE
@ -311,7 +305,6 @@ QueueHandle_t trackQueue;
QueueHandle_ttrackControlQueue;
QueueHandle_ttrackControlQueue;
QueueHandle_trfidCardQueue;
QueueHandle_trfidCardQueue;
boolpauseNeopixel=false;// Used to pause Neopixel-signalisation (while NVS-writes as this leads to exceptions; don't know why)
snprintf(logBuf,serialLoglength,"Schreibe '%s' in NVS für RFID-Card-ID %s mit playmode %d und letzter Track %u\n",prefBuf,_rfidCardId,_playMode,_trackLastPlayed);
snprintf(logBuf,serialLoglength,"Schreibe '%s' in NVS für RFID-Card-ID %s mit playmode %d und letzter Track %u\n",prefBuf,_rfidCardId,_playMode,_trackLastPlayed);
if(pauseNeopixel){// Workaround to prevent exceptions while NVS-writes take place
if(pauseNeopixel){// Workaround to prevent exceptions while NVS-writes take place
vTaskDelay(portTICK_RATE_MS*10);
vTaskDelay(portTICK_RATE_MS*10);
continue;
continue;
}
}
#endif
/*#ifdef FTP_ENABLE
/*#ifdef FTP_ENABLE
if(ftpSrv.isConnected()){// Workaround: after moving Neopixel's task to 2nd cpu-core, FTP-transfer-rate decreased. By disabling Neopixel-animation, this can be rescued a bit
if(ftpSrv.isConnected()){// Workaround: after moving Neopixel's task to 2nd cpu-core, FTP-transfer-rate decreased. By disabling Neopixel-animation, this can be rescued a bit
vTaskDelay(portTICK_RATE_MS*100);
vTaskDelay(portTICK_RATE_MS*100);
@ -3565,7 +3541,9 @@ void webserverStart(void) {
// Dumps all RFID-entries from NVS into a file on SD-card
// Dumps all RFID-entries from NVS into a file on SD-card
booldumpNvsToSd(char*_namespace,char*_destFile){
booldumpNvsToSd(char*_namespace,char*_destFile){
pauseNeopixel=true;
#ifdef NEOPIXEL_ENABLE
pauseNeopixel=true;// Workaround to prevent exceptions due to Neopixel-signalisation while NVS-write
#endif
esp_partition_iterator_tpi;// Iterator for find
esp_partition_iterator_tpi;// Iterator for find
constesp_partition_t*nvs;// Pointer to partition struct
constesp_partition_t*nvs;// Pointer to partition struct