Replace external SPIRAM lib w/internal optimized (#250)
* Replace external SPIRAM lib w/internal optimized Instead of requiring everyone to download and install another Arduino library to use this lib, include an optimized, self-contained one from the 8266 VM PR: https://github.com/esp8266/Arduino/pull/6994 Does change the API as it now requires a HW chip select, so that parameter is removed from the SpiRAM buffer object. * Redo the FIFO to try and be faster * Fix the SPI interface, buffering. SPI FIFO needs special care so do all work in a RAM copy and the copy it over manually w/32b writes. Ensure the SPI command is done before touching the FIFO. Fix buffering organization. Make the buffer report status as a #### bar. * Fix infinite wait on EOF * Add SW chip select support * Update URL to one that's live today * Clean up metadata printout * Clean up readme refs to obsolete lib * Slow down the DIO->SIO reset sequence * Update readme to remove old SPIRam library ref Also add the resistor to the 1T circuit to avoid transistor overheating.
This commit is contained in:
1 parent
be0ee8283f
commit
0fd2d0413b
5 files changed
+372
-132
No files matched your search
@@ -30,29 +30,16 @@ A neat MQTT-driven ESP8266 light-and-sound device (alarm? toy? who can say!) was
|
||||
A very interesting "linear clock" with a stepper motor, NTP time keeping, and configurable recorded chimes with schematics, 3D printer plans, and source code, is now available http://home.kpn.nl/bderogee1980/projects/linear_clock/linear_clock.html
|
||||
|
||||
## Prerequisites
|
||||
First, make sure you are running the 2.4 or GIT head version of the Arduino libraries for ESP8266, or the latest ESP32 SDK from Espressif.
|
||||
First, make sure you are running the 2.6.3/later or GIT head version of the Arduino libraries for ESP8266, or the latest ESP32 SDK from Espressif.
|
||||
|
||||
You can use GIT to pull right from GitHub: see [this README](https://github.com/esp8266/Arduino/blob/master/README.md#using-git-version) for detailed instructions.
|
||||
|
||||
## ESP-32 SPIFFS Errors
|
||||
The latest official release of the ESP32-Arduino seems to have broken SPIFFS, but a patch has just been committed to git head. If you want to run SPIFFS, please follow the directions below, courtesy of @rfestag:
|
||||
```sh
|
||||
cd ~/Arduino/hardware/espressif/esp32 # Or wherever you have it installed
|
||||
git pull # Update to the latest
|
||||
cd tools
|
||||
python get.py # On my system, I have python3 installed by default, so I had to run python2.7 get.py
|
||||
# Re-upload files using the new mkspiffs that is installed
|
||||
# Then reload your sketch
|
||||
```
|
||||
Be sure to use the [ESP32 SPIFFS](https://github.com/me-no-dev/arduino-esp32fs-plugin) upload plugin before running your sketch to upload the data files once the fixed IDE is set up.
|
||||
|
||||
## Installation
|
||||
Install the library and the SPI driver library in your ~/Arduino/libraries
|
||||
Install the library in your ~/Arduino/libraries
|
||||
```sh
|
||||
mkdir -p ~/Arduino/libraries
|
||||
cd ~/Arduino/libraries
|
||||
git clone https://github.com/earlephilhower/ESP8266Audio
|
||||
git clone https://github.com/Gianbacchio/ESP8266_Spiram
|
||||
```
|
||||
|
||||
When in the IDE please select the following options on the ESP8266:
|
||||
@@ -185,7 +172,7 @@ There are many other variants out there, and they should all work reasonably wel
|
||||
## Software I2S Delta-Sigma DAC (i.e. playing music with a single transistor and speaker)
|
||||
For the best fidelity, and stereo to boot, spend the money on a real I2S DAC. Adafruit makes a great mono one with amplifier, and you can find stereo unamplified ones on eBay or elsewhere quite cheaply. However, thanks to the software delta-sigma DAC with 32x oversampling (up to 128x if the audio rate is low enough) you can still have pretty good sound!
|
||||
|
||||
Use the AudioOutputI2S*No*DAC object instead of the AudioOutputI2S in your code, and the following schematic to drive a 2-3W speaker using a single $0.05 NPN 2N3904 transistor:
|
||||
Use the `AudioOutputI2S*No*DAC` object instead of the `AudioOutputI2S` in your code, and the following schematic to drive a 2-3W speaker using a single $0.05 NPN 2N3904 transistor and ~1K resistor:
|
||||
|
||||
```
|
||||
2N3904 (NPN)
|
||||
@@ -197,7 +184,7 @@ Use the AudioOutputI2S*No*DAC object instead of the AudioOutputI2S in your code,
|
||||
| | | A|
|
||||
ESP8266-GND ------------------+ | +------+ K|
|
||||
| | | E|
|
||||
ESP8266-I2SOUT (Rx) -------------+ | \ R|
|
||||
ESP8266-I2SOUT (Rx) -----/\/\/\--+ | \ R|
|
||||
| +-|
|
||||
USB 5V -----------------------------+
|
||||
|
||||
@@ -207,15 +194,15 @@ If you don't have a 5V source available on your ESP model, you can use the 5V fr
|
||||
|
||||
Connections are as a follows:
|
||||
```
|
||||
ESP8266-RX(I2S tx) -- 2N3904 Base
|
||||
ESP8266-RX(I2S tx) -- Resistor (~1K ohm, not critical) -- 2N3904 Base
|
||||
ESP8266-GND -- 2N3904 Emitter
|
||||
USB-5V -- Speaker + Terminal
|
||||
2N3904-Collector -- Speaker - Terminal
|
||||
```
|
||||
|
||||
Basically the transistor acts as a switch and requires only a drive of 1/beta (~1/1000 for the transistor specified) times the speaker current. As shown you've got a max current of (5-0.7)/8=540mA and a power of 0.54^2 * 8 = ~2.3W into the speaker.
|
||||
*NOTE*: A prior version of this schematic had a direct connection from the ESP8266 to the base of the transistor. While this does provide the maximum amplitude, it also can draw more current from the 8266 than is safe, and can also cause the transistor to overheat.
|
||||
|
||||
When using the software delta-sigma DAC, even though our playback circuit is not using the LRCLK or BCLK pins, the ESP8266 internal hardware *will* be driving them. So these pins cannot be used as outputs in your application. However, you can use the LRCLK and BCLK pins as *inputs*. Simply start playback, then use the standard pinMode(xxx, INPUT/INPUT_PULLUP) Arduino commands and you can, for example, use those two pins to read a button or sensor.
|
||||
As of the latest ESP8266Audio release, with the software delta-sigma DAC the LRCLK and BCLK pins *can* be used by an application. Simply use normal `pinMode` and `dicitalWrite` or `digitalRead` as desired.
|
||||
|
||||
### High pitched buzzing with the 1-T circuit
|
||||
The 1-T amp can _NOT_ drive any sort of amplified speaker. If there is a power or USB input to the speaker, or it has lights or Bluetooth or a battery, it can _NOT_ be used with this circuit.
|
||||
@@ -251,8 +238,9 @@ Ground ---------------------+
|
||||
For ESP8266 with red LED (~1.9Vf drop) you need minimum 150Ohm resistor (12mA max per pin), and output pin is fixed (GPIO3/RX0).On ESP32 it is confgurable with `AudioOutputSPDIF(gpio_num)`.
|
||||
|
||||
## Using external SPI RAM to increase buffer
|
||||
A class allows you to use a 23lc1024 SPI RAM from Microchip as input buffer. This chip connects to ESP8266 HSPI port and uses an [external SPI RAM library](https://github.com/Gianbacchio/ESP8266_Spiram).
|
||||
You need to choose another pin than GPIO15 for Cs as this pin is already used by the I2S port. Here is an example with the Cs pin plugged to GPIO00 on NodeMCU board.
|
||||
A class allows you to use a 23lc1024 SPI RAM from Microchip as input buffer. This chip connects to ESP8266 HSPI port and provides a large buffer to help avoid hiccus in playback of web streams.
|
||||
|
||||
The current version allows for using the standard hardware CS (GPIO15) or any other pin via software at slightly less performance. The following schematic shows one example:
|
||||
|
||||

|
||||
|
||||
|
||||
Reference in new issue
Block a user