diff --git a/README.md b/README.md index 04f4d4f..de69682 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ The heart of my project is an ESP32 on a [Wemos Lolin32 development-board](https * 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. * Edit `src/settings.h` according your needs. Especially don't forget to set `HAL` depending on your develboard. -* Edit board-specific (`HAL`) config-file (e.g. `settings-lolin32.h` for Lolin32 or `settings-lolin_d32.h` for Lolin D32). If you're running a board that is not listed there: start with `settings-lolin32.h`. Specific means: it was successfully tested or is at least supposed to be working. Said this I want to outline in many cases `settings-lolin32.h` can be used with other boards as well (with no or just a few tweaks). +* Edit board-specific (`HAL`) config-file (e.g. `settings-lolin32.h` for Lolin32 or `settings-lolin_d32.h` for Lolin D32). If you're running a board that is not listed there: start with `settings-custom.h` and change it according your needs. * 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. Depending on your develboard it might me necessary to push a button in order to allow ESP32 to enter flashmode (not necessary für Lolin32, D32 und D32 pro). * Now have a look at the serial-output at the bottom of Visual Studio Code's windows. At the first run there might appear a few error-messages (related to missing entries in NVS). Don't worry, this is just normal. However, make sure SD is running as this is mandatory! * If everything ran fine, at the first run, ESPuino should open an access-point with the name "ESPuino". Join 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 ESPuino. Hint: I tried to connect this access-point via Android mobile. Basically that's no problem, but as my mobile detected there'd be no internet-connection, it keept LTE-connection open and prevented me from connecting to `192.168.4.1`. So if in doubts use a computer. diff --git a/src/main.cpp b/src/main.cpp index 94d72ff..9258070 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,6 +11,8 @@ #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 +#elif (HAL == 5) + #include "settings-custom.h" // Contains all user-relevant settings custom-board #endif #include diff --git a/src/settings-custom.h b/src/settings-custom.h new file mode 100644 index 0000000..220c6c2 --- /dev/null +++ b/src/settings-custom.h @@ -0,0 +1,79 @@ +#include "Arduino.h" + +//######################### INFOS #################################### +/* This is not a develboard-specific config-file. It's intended for your own use. + It's been originally derived from lolin32, but just change it according your needs! +*/ + +//################## GPIO-configuration ############################## +// Please note: GPIOs 34, 35, 36, 39 are input-only and don't have pullup-resistors. +// So if connecting a button to these, make sure to add a 10k-pullup-resistor for each button. +// Further infos: https://randomnerdtutorials.com/esp32-pinout-reference-gpios/ +#ifdef SD_MMC_1BIT_MODE + // uSD-card-reader (via SD-MMC 1Bit) + // + // SD_MMC uses fixed pins + // MOSI 15 + // SCK 14 + // MISO 2 +#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) +#define RST_PIN 99 // Not necessary but has to be set anyway; so let's use a dummy-number +#define RFID_CS 21 // GPIO for chip select (RFID) +#define RFID_MOSI 23 // GPIO for master out slave in (RFID) +#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 + #define RFID_IRQ 39 // PN5180 IRQ PIN (only needed for low power card detection) + #define BUTTON_PIN_BITMASK 0x8000000000// 2^RFID_IRQ in hex +#endif +// I2S (DAC) +#define I2S_DOUT 25 // Digital out (I2S) +#define I2S_BCLK 27 // BCLK (I2S) +#define I2S_LRC 26 // LRC (I2S) + +// Rotary encoder +#define DREHENCODER_CLK 34 // If you want to reverse encoder's direction, just switch GPIOs of CLK with DT (in software or hardware) +#define DREHENCODER_DT 35 // Info: Lolin D32 / Lolin D32 pro 35 are using 35 for battery-voltage-monitoring! +#define DREHENCODER_BUTTON 32 // Button is used to switch ESPuino on and off + +// 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; 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 + +// (optional) Neopixel +#define LED_PIN 12 // GPIO for Neopixel-signaling + +// (optinal) Headphone-detection +#ifdef HEADPHONE_ADJUST_ENABLE + #define HP_DETECT 22 // GPIO that detects, if there's a plug in the headphone jack or not +#endif + +// (optional) Monitoring of battery-voltage via ADC +#ifdef MEASURE_BATTERY_VOLTAGE + #define VOLTAGE_READ_PIN 33 // GPIO used to monitor battery-voltage. Change to 35 if you're using Lolin D32 or Lolin D32 pro as it's hard-wired there! + float referenceVoltage = 3.35; // Voltage between 3.3V and GND-pin at the develboard in battery-mode (disconnect USB!) + float offsetVoltage = 0.1; // If voltage measured by ESP isn't 100% accurate, you can add an correction-value here +#endif + +// (optional) For measuring battery-voltage a voltage-divider is necessary. Their values need to be configured here. +#ifdef MEASURE_BATTERY_VOLTAGE + uint8_t rdiv1 = 129; // Rdiv1 of voltage-divider (kOhms) (measure exact value with multimeter!) + uint16_t rdiv2 = 129; // Rdiv2 of voltage-divider (kOhms) (measure exact value with multimeter!) => used to measure voltage via ADC! +#endif \ No newline at end of file diff --git a/src/settings.h b/src/settings.h index 2cf7cc8..18e6003 100644 --- a/src/settings.h +++ b/src/settings.h @@ -10,9 +10,10 @@ 2: ESP32-A1S Audiokit => settings-espa1s.h 3: Wemos Lolin D32 => settings-lolin_D32.h 4: Wemos Lolin D32 pro => settings-lolin_D32_pro.h + 5: custom => settings-custom.h more to come... */ - #define HAL 1 // HAL 1 = LoLin32, 2 = ESP32-A1S-AudioKit, 3 = Lolin D32, 4 = Lolin D32 pro + #define HAL 1 // HAL 1 = LoLin32, 2 = ESP32-A1S-AudioKit, 3 = Lolin D32, 4 = Lolin D32 pro; 5 = custom //########################## MODULES #################################