Browse Source

Bugfix: renamed includes; added description

master
Torsten Stauder 5 years ago
parent
commit
d19a3eb4e3
  1. 11
      README.md
  2. BIN
      pictures/Pullup-removal.jpg
  3. 32
      src/main.cpp
  4. 8
      src/settings-lolin32.h
  5. 4
      src/settings-lolin_d32.h
  6. 9
      src/settings-lolin_d32_pro.h

11
README.md

@ -12,7 +12,7 @@ Finally, the long announced Tonuino-PCB for Wemos' Lolin32 is [there](https://gi
* 17.11.2020: Introduced a distinct volume for headphone for optional headphone-PCB.
* 20.11.2020: Added directive `MEASURE_BATTERY_VOLTAGE`: monitoring battery's voltage is now supported.
* 25.11.2020: WiFi can now be enabled/disabled instantly by pressing two buttons.
* 28.11.2020: Battery's voltage can now be visualized by Neopixel by short-press of rotary encoder's burtton.
* 28.11.2020: Battery's voltage can now be visualized by Neopixel by short-press of rotary encoder's button.
* 28.11.2020: Added directive `PLAY_LAST_RFID_AFTER_REBOOT`: Tonuino will recall the last RFID played after reboot.
* 05.12.2020: Added filebrowser to webgui (thanks @mariolukas for contribution!)
* 05.12.2020: Moved all user-relevant settings to src/settings.h
@ -25,6 +25,7 @@ Finally, the long announced Tonuino-PCB for Wemos' Lolin32 is [there](https://gi
* 20.12.2020: Due to memory-issues with webstreams, FTP needs to be activated by pressing pause+next-button now
<br />More to come...
* 23.12.2020: User-config is now split into general part (settings.h) and develboard-specific part (e.g. settings-lolin32.h)
* 28.12.2020: Added display (via i2c)
## 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. Advice: Don't enable modules (e.g. MQTT) if you don't need them as this could save memory.
@ -42,7 +43,7 @@ The core of my implementation is based on the popular [ESP32 by Espressif](https
The basic idea of Tonuino is to provide a way, to use the Arduino-platform for a music-control-concept that supports locally stored music-files without DRM-restrictions. This basically means that RFID-tags are used to direct a music-player. Even for kids this concept is simple: place an RFID-object (card, character) on top of a box and the music starts to play. Place another RFID-object on it and anything else is played. Simple as that.
## 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.). But probably it's besser to use it's successor: [Wemos Lolin D32](https://de.aliexpress.com/item/32808551116.html).
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.). But probably it's better to use it's successor (which has battery-measurement already included): [Wemos Lolin D32](https://de.aliexpress.com/item/32808551116.html). Or, if you're planning to hear webstreams regularly, [Wemos Lolin D32 pro](https://de.aliexpress.com/item/32883116057.html) might be a good decision. It comes with uSD-slot onboard and because of its ESP32-WROVER-B has PSRAM included. PSRAM is used as webstream-cache and might be used more intensively in future.
* [MAX98357A (like Adafruit's)](https://de.aliexpress.com/item/32999952454.html)
* [uSD-card-reader; 3.3V only; supports SPI + SD-MMC](https://www.ebay.de/itm/Micro-SPI-Kartenleser-Card-Reader-2GB-SD-8GB-SDHC-Card-3-3V-ESP8266-Arduino-NEU/333796577968)
* [RFID-reader](https://www.amazon.de/AZDelivery-Reader-Arduino-Raspberry-gratis/dp/B074S8MRQ7)
@ -95,8 +96,8 @@ Please note: via GUI upper and lower voltage cut-offs for visualisation of batte
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.
* It is almost twice as fast in FTP-transfer<br />
So why using SPI if SD-MMC seems to be better? The primary problem of SD-MMC is: you cannot choose different GPIOs. That doesn't sound bad but this can (depending on the uSD-card-reader-module) be a problem because maybe GPIO2 is pulled HIGH to 3.3V by a resistor. For example this is the case when using the reader-module named above in hardware-setup. It's a problem because if GPIO2 is pulled high, ESP32 doesn't enter flash-mode. As soon as flash-mode is entered, it's no longer a problem. However, this behaviour can be an issue if ESP32 is deeply "burried" in Tonuino's enclosure and you want to update its firmware. But fortunately there's a way to bypass this problem: remove the [pullup-resistor shown in the picture](https://raw.githubusercontent.com/biologist79/Tonuino-ESP32-I2S/master/pictures/Pullup-removal.jpg). It can be removed safely because if MMC-mode is set, pullup is done in software using `pinMode(2, INPUT_PULLUP);`.
## 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.
@ -165,7 +166,7 @@ In general I recommend using a [uSD-card-reader](https://www.ebay.de/itm/Micro-S
| ------------- | --------------------- | ------ | ------------------------------------------------------------ |
| -- | SD-reader | CS | no CS required |
| 15 | SD-reader | MOSI | |
| 2 | SD-reader | MISO | 10K hardware pullup may be required |
| 2 | SD-reader | MISO | make sure there's no hardware-pullup |
| 14 | SD-reader | SCK | |
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/).

BIN
pictures/Pullup-removal.jpg

After

Width: 794  |  Height: 1280  |  Size: 352 KiB

32
src/main.cpp

@ -8,9 +8,9 @@
#elif (HAL == 2)
#include "settings-espa1s.h" // Contains all user-relevant settings for ESP32-A1S Audiokit
#elif (HAL == 3)
#include "settings-lolin_D32.h" // Contains all user-relevant settings for Wemos Lolin D32
#include "settings-lolin_d32.h" // Contains all user-relevant settings for Wemos Lolin D32
#elif (HAL == 4)
#include "settings-lolin_D32_pro.h" // Contains all user-relevant settings for Wemos Lolin D32 pro
#include "settings-lolin_d32_pro.h" // Contains all user-relevant settings for Wemos Lolin D32 pro
#endif
#include <ESP32Encoder.h>
@ -38,8 +38,8 @@
#include <MFRC522.h>
#endif
#ifdef RFID_READER_TYPE_MFRC522_I2C
#include "Wire.h"
#include <MFRC522_I2C.h>
#include "Wire.h"
#include <MFRC522_I2C.h>
#endif
#ifdef RFID_READER_TYPE_PN5180
#include <PN5180.h>
@ -269,10 +269,10 @@ AsyncEventSource events("/events");
// Audio/mp3
#ifndef SD_MMC_1BIT_MODE
SPIClass spiSD(HSPI);
fs::FS FSystem = (fs::FS)SD;
SPIClass spiSD(HSPI);
fs::FS FSystem = (fs::FS)SD;
#else
fs::FS FSystem = (fs::FS)SD_MMC;
fs::FS FSystem = (fs::FS)SD_MMC;
#endif
TaskHandle_t mp3Play;
@ -283,7 +283,7 @@ TaskHandle_t rfid;
#endif
#if (HAL == 2)
#include "AC101.h"
#include "AC101.h"
static TwoWire i2cBusOne = TwoWire(0);
static AC101 ac(i2cBusOne);
#endif
@ -3868,20 +3868,6 @@ void setup() {
a2dp_sink.start("Tonuino");
#endif
#ifdef DISPLAY_I2C
// OLED Display - https://github.com/olikraus/u8g2/wiki/u8g2setupcpp#sh1106-128x64_noname-1
U8G2_SH1106_128X64_NONAME_1_2ND_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
u8g2.begin();
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_ncenB08_tr);
u8g2.drawStr(0,8,"Tonuino gestartet");
u8g2.drawStr(0,16,"Papas Projekt");
u8g2.drawStr(0,24,"Dritte Statuszeile passt");
u8g2.drawStr(0,16,"und noch eine vierte Zeile");
} while ( u8g2.nextPage() );
#endif
// Create queues
volumeQueue = xQueueCreate(1, sizeof(int));
if (volumeQueue == NULL) {
@ -4148,7 +4134,7 @@ void setup() {
// Create empty index json-file when no file exists.
if (!fileExists(FSystem,DIRECTORY_INDEX_FILE)) {
createFile(FSystem,DIRECTORY_INDEX_FILE,"[]");
ESP.restart();
esp_deep_sleep_start();
}
bootComplete = true;

8
src/settings-lolin32.h

@ -8,7 +8,7 @@
Caveats: None
Status:
tested with 2x SPI: RC522 & SD (by biologist79)
tested with 1x SPI: PN5180, SD (MMC) (by tueddy)
tested with 1x SPI: PN5180, SD (MMC) (by tueddy and biologist79) => don't enable SINGLE_SPI_ENABLE
*/
//################## GPIO-configuration ##############################
@ -17,8 +17,8 @@
//
// SD_MMC uses fixed pins
// MOSI 15
// SCKK 14
// MISO 2 // hardware pullup may required
// SCK 14
// MISO 2
#else
// uSD-card-reader (via SPI)
#define SPISD_CS 15 // GPIO for chip select (SD)
@ -53,7 +53,7 @@
// Control-buttons
#define PAUSEPLAY_BUTTON 5 // GPIO to detect pause/play
#define NEXT_BUTTON 4 // GPIO to detect next
#define PREVIOUS_BUTTON 2 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2)
#define PREVIOUS_BUTTON 2 // GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode)
// (optional) Power-control
#define POWER 17 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep

4
src/settings-lolin_d32.h

@ -17,8 +17,8 @@
//
// SD_MMC uses fixed pins
// MOSI 15
// SCKK 14
// MISO 2 // hardware pullup may required
// SCK 14
// MISO 2
#else
// uSD-card-reader (via SPI)
#define SPISD_CS 15 // GPIO for chip select (SD)

9
src/settings-lolin_d32_pro.h

@ -6,19 +6,14 @@
PCB: None so far
Infos: https://www.wemos.cc/en/latest/d32/d32_pro.html
Schematics: https://www.wemos.cc/en/latest/_static/files/sch_d32_pro_v2.0.0.pdf
Caveats: GPIO35 (battery monitoring) + SD can't be changed, it's built in
Caveats: GPIO35 (battery monitoring) + SD can't be changed, it's built in (and because of the SD-pinout used, it is not compatible with MMC-mode)
Status:
tested with 2xSPI: RC522 & SD (by biologist79)
*/
//################## GPIO-configuration ##############################
#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
// NOT SUPPORTED BY D32 pro as 15 / 14 / 2 doesn't match D32 pro's SD-pinout
#else
// uSD-card-reader (via SPI) => Cannot be changed, it's built in!
#define SPISD_CS 4 // GPIO for chip select (SD)

Loading…
Cancel
Save