Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
a73ebaa
Delete unused files of the forked project
baldram Jul 2, 2017
bbfbf27
Refactor VS1053 library class
baldram Jul 2, 2017
d073918
Add PlatformIO library configuration files
baldram Jul 2, 2017
80d2e11
Limit target platforms
baldram Jul 2, 2017
d11eaf4
Add debug logger util
baldram Jul 2, 2017
553e74c
Remove a typo
baldram Jul 2, 2017
f04744b
Update documentation
baldram Jul 2, 2017
7d697c6
Fix typos
baldram Jul 2, 2017
e94f9cc
Update documentation and license information
baldram Jul 3, 2017
bfa28d8
Add an example sketch and update documentation
baldram Jul 5, 2017
4b9b205
Add an example wiring picture
baldram Jul 5, 2017
83adb1f
Introduce 3rd party logging framework
baldram Jul 5, 2017
0f9194d
Simplify the example
baldram Jul 6, 2017
ac892e0
Extract 'switch to MP3 mode' functionality to be called explicitly
baldram Jul 7, 2017
cf8d263
Limit supported architectures to known ones
baldram Jul 7, 2017
b56a153
Update library version
baldram Jul 7, 2017
f16e37b
Update documentation and examples
baldram Jul 9, 2017
02c3185
Convert examples from .cpp to .ino
baldram Jul 10, 2017
3752c3d
add esp32 to architectures
gtalusan Nov 11, 2017
7083a92
Merge pull request #3 from gtalusan/master
baldram Nov 16, 2017
46cbc64
Update SimpleMp3Player.ino
baldram Mar 12, 2018
a8c0c6d
Fix import method to tell preprocessor to look in the same directory
baldram Mar 12, 2018
b70f7af
Merge pull request #6 from baldram/DEV
baldram Mar 12, 2018
ce9e817
Add PlatformIO related information (#7)
baldram Jul 7, 2018
a86b027
Update library version
baldram Jul 8, 2018
dd6e904
Update library version
baldram Jul 8, 2018
bb80235
Update description text
baldram Jul 8, 2018
dd6fba4
Merge pull request #8 from baldram/baldram-patch-1
baldram Jul 8, 2018
4d83078
Reword the description for cleaner understanding
baldram Jul 8, 2018
410ab2d
Merge pull request #9 from baldram/DEV-1
baldram Jul 8, 2018
91191ae
Add a new example sound (#5) (#11)
baldram Jul 20, 2018
0444cf9
Bump version for the next release (#12)
baldram Jul 20, 2018
1a707b4
Remove ArduinoLog dependency (#13)
baldram Jul 28, 2018
1c4be61
Clean up examples (#14)
baldram Jul 28, 2018
fc15200
Bump the library version (#15)
baldram Jul 28, 2018
6e9b41a
Clean up (#16)
baldram Jul 28, 2018
07b900e
Update spec with mp3 to C conversion solution #18 (#19)
baldram Aug 1, 2018
856bcbd
Add web radio example (#20)
vincegellar Aug 2, 2018
71d4f78
Bump the library version (#21)
baldram Aug 2, 2018
cce9ead
Use valid version in library.properties (#22)
per1234 Aug 3, 2018
fc49833
Use "SemVer" compliant library version number
baldram Aug 3, 2018
aeddbd3
Introduce isChipConnected() method. (#27)
wmarkow Oct 20, 2018
0d1aa59
Set the volume always (#28)
wmarkow Oct 20, 2018
369cbff
Provide MP3 instead of RIFF WAVE file (#31)
rpoisel Dec 27, 2018
31f3a7c
Bump version (#33)
baldram Jan 9, 2019
7ecc51e
Refine the description of the functionality #35
baldram Jul 3, 2019
aa80f2b
Update examples for compatibility with both ESP8266 and ESP32 (#40)
nopnop2002 Oct 30, 2019
c8dd35a
Add support for reading and clearing decoded time by SCI_DECODE_TIME …
baldram Dec 1, 2019
0df71d1
Changed buffer size of the webradio example to 64 (#45) #44
LucasMaciuga Jan 19, 2020
0d3e4a4
Define coding style settings #49 (#50)
baldram Mar 24, 2020
c5347c3
Add left and right volume balance enhancement (#53)
fabitom Mar 31, 2020
1c02f52
Make write_register public. (#65)
CelliesProjects Jun 10, 2021
90279c6
#64: Add data rate adjusting support (#67)
baldram Jun 12, 2021
9e4e14a
Adjust write_register method description (#68)
baldram Jun 12, 2021
bae6fed
Load VLSI firmware patches. (#69)
CelliesProjects Jun 18, 2021
046fd7e
Release patches support (#76)
baldram Aug 7, 2021
3f5464b
Release 1.1.4 (#77)
baldram Aug 7, 2021
ba1803f
Add Get Chip Version and Stream Mode activation support (#79)
Dr-Dawg Sep 2, 2021
fdbe2a0
Adjust syntax highlight in docs
baldram Sep 2, 2021
f501eb7
Fix load user code bug (#82)
Dr-Dawg Sep 16, 2021
16044ba
Add I2S output feature (#91)
episource Mar 22, 2022
022ffd9
Fix compiler error in Arduino IDE 2.0.x (#103)
CelliesProjects Jan 12, 2023
824f82c
Adjust code documentation (#96)
mmakaay Feb 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org

[*]
indent_style = space
indent_size = 4
continuation_indent_size = 8
max_line_length = 100
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[{Makefile,*.mk,*.bat}]
indent_style = tab
indent_size = 2

[{*.cmake,CMakeLists.*}]
max_line_length = 120

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.pioenvs
.piolibdeps
CMakeListsPrivate.txt
CMakeLists.txt
cmake-build-debug/
.idea
.vscode
65 changes: 65 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < http://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < http://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < http://docs.platformio.org/page/userguide/cmd_ci.html >
#
#
# Please choice one of the following templates (proposed below) and uncomment
# it (remove "# " before each line) or use own configuration according to the
# Travis CI documentation (see above).
#


#
# Template #1: General project. Test it using existing `platformio.ini`.
#

# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# install:
# - pip install -U platformio
#
# script:
# - platformio run


#
# Template #2: The project is intended to by used as a library with examples
#

# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# env:
# - PLATFORMIO_CI_SRC=path/to/test/file.c
# - PLATFORMIO_CI_SRC=examples/file.ino
# - PLATFORMIO_CI_SRC=path/to/test/directory
#
# install:
# - pip install -U platformio
#
# script:
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
Binary file removed ESP-radio.pdf
Binary file not shown.
3,093 changes: 0 additions & 3,093 deletions Esp_radio.ino

This file was deleted.

636 changes: 636 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

264 changes: 204 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,205 @@
# Esp-radio
Internet radio based on Esp8266 and VS1053. Will compile in Arduino IDE. New version 24-may-2017.

Features:
- Can connect to thousands of Internet radio stations that broadcast MP3 or Ogg audio streams.
- Can connect to a standalone mp3 file on a server.
- Can connect to a local mp3 file on SPIFFS.
- Support for .m3u playlists.
- Uses a minimal number of components; no Arduino required.
- Handles bitrates up to 320 kbps.
- Has a preset list of maximal 100 favorite radio stations in configuration file.
- Configuration file can be edited through web interface.
- Can be controlled by a tablet or other device through a build-in webserver.
- Can be controlled over MQTT.
- Can be controlled over Serial Input.
- Optional one or three button control to skip to the next preset station.
- The strongest available WiFi network is automatically selected.
- Heavily commented source code, easy to add extra functionality.
- Debug information through serial output.
- 20 kB ring buffer to provide smooth playback.
- SPIFFS filesystem used for configuration of WiFi SSIDs, passwords and small MP3-files.
- Software update over WiFi possible (OTA).
- Saves volume and preset station over restart.
- Bass and treble control.
- Configuration also possible if no WiFi connection can be established.
- Can play iHeartRadio stations.

See documentation in pdf-file.

Last changes:
- 31-may-2017: Volume indicator on display.
- 26-may-2017: Correction playing .m3u playlists.
- 24-may-2017: Correction. Do not skip first part of .mp3 file.
- 11-may-2017: Convert UTF8 characters before display, thanks to everyb313.
- 09-may-2017: Fixed issue on analog input.
- 04-may-2017: Integrate iHeartRadio, thanks to NonaSuomy
- 03-may-2017: Prevent to start inputstream if no network.
- 26-feb-2017: Better output webinterface on preset change.
- 01-feb-2017: Bugfix uploading files.
- 30-jan-2017: Allow chunked transfer encoding of streams.
- 23-jan-2017: Correction playlists.
- 16-jan-2017: Correction playlists.
- 02-jan-2017: Webinterface in PROGMEM.
- 28-dec-2016: Add support for resume after stop.
- 23-dec-2016: Add support for mp3 files on SPIFFS.
- 15-nov-2016: Support for .m3u files.
- 22-oct-2016: Correction mute/unmute.
- 14-oct-2016: Update for AsyncMqttClient version 0.5.0. Added extra documentation for MQTT.
- 11-oct-2016: Allow stations that do not specify bitrate. Allow standalone MP3s.
- 04-oct-2016: Version with MQTT and configuration in radio.ini file.
- 04-jul-2016: WiFi.disconnect clears old connection now (thanks to Juppit)
- 27-may-2016: Fixed restore station at restart.
- 26-may-2016: Bugfix BUTTON3 handling (if no TFT). Update pdf-document.
- 23-may-2016: Bugfix EEPROM handling.
- 17-may-2016: 3 button control over analog or digital input.
- 13-may-2016: Better detection of Ogg streams.
- 07-may-2016: Added selection of preset stations to sketch and web page.
- 06-may-2016: Added hidden SSID, added feature to web page.
- 04-may-2016, Allow stations like "skonto.ls.lv:8002/mp3".
- 03-may-2016, Add bass/treble settings (see also new index.html).
# VS1053 library

This is a PlatformIO library for the generic **[VS1053 Breakout](http://www.vlsi.fi/en/products/vs1053.html)** by VLSI Solution.<br/>
A powerful Ogg Vorbis / MP3 / AAC / WMA / FLAC / MIDI Audio Codec chip.<br/>
Read more: [http://www.vlsi.fi/en/products/vs1053.html](http://www.vlsi.fi/en/products/vs1053.html).

The library enables the possibility to play audio files (recording is not supported).<br />
Eg. it may be a base to build your own webradio player or different audio device.

Designed specifically to work with the **Espressif ESP8266** and **ESP32** boards.

Don't hesitate to create issues or pull requests if you want to improve ESP_VS1053_Library!

## Introduction

#### How to use the library?

There are currently two official methods to program the ESP boards: the ESP-IDF and the ESP8266/ESP32 arduino Core.
The library was created to work with the **arduino Core**.

The ESP8266 is the most popular Wi-Fi MCU (known also as ESP12, NodeMCU, WeMos, ...).

#### Why PlatformIO?

As mentioned in first paragraph, the library was prepared to be used with PlatformIO, which is kind of dependency management tool. It is highly recommended environment to be used while developing your electronics/IoT projects. The build automation lets you deal much easier while working with the project. It will help you to have all project dependencies simply resolved out of the box. What more, it provides very good IDE integration (any of popular), debugging possibility, remote unit testing and firmware updates. [Learn more about PlatformIO here](https://platformio.org/).

## Usage

#### Configure and use the library

To use this library in your PlatformIO project, simply add to your `platformio.ini` a dependency (id=1744) as following:

```ini
lib_deps =
ESP_VS1053_Library
```

From your `.cpp` or `.ino` code include VS1053 library.

```c++
#include <VS1053.h>
```

Afterwards simply instantiate an object of VS1053 player as below:

```c++
VS1053 player(CS, DCS, DREQ);
```

Then initialize the player and use as in following example:

```c++
player.begin();
if (player.getChipVersion() == 4) { // Only perform an update if we really are using a VS1053, not. eg. VS1003
player.loadDefaultVs1053Patches();
}
player.setVolume(VOLUME);
player.switchToMp3Mode();
player.playChunk(sampleMp3, sizeof(sampleMp3));
```

For complete code please check [examples](https://github.com/baldram/ESP_VS1053_Library/tree/master/examples) folder.
The example plays the sound like this [(click to listen to the sound)](https://drive.google.com/open?id=1Mm4dc-sM7KjZcKmv5g1nwhe3-qtm7yUl) every three seconds.

Please note that `player.switchToMp3Mode()` is an optional switch. Some of VS1053 modules will start up in MIDI mode. The result is no audio when playing MP3.
You can modify the board, but there is a more elegant way without soldering. For more details please read a discussion here: [http://www.bajdi.com/lcsoft-vs1053-mp3-module/#comment-33773](http://www.bajdi.com/lcsoft-vs1053-mp3-module/#comment-33773).
<br />No side effects for boards which do not need this switch, so you can call it just in case.

#### Additionall functionality

Below briefly described. For detailed information please see [VS1053b Datasheet specification](http://www.vlsi.fi/fileadmin/datasheets/vs1053.pdf).

##### Test VS1053 chip via `SCI_STATUS`
To check if the VS1053 chip is connected and able to exchange data to the microcontroller use the `player.isChipConnected()`.

This is a lightweight method to check if VS1053 is correctly wired up (power supply and connection to SPI interface).

For additional information please see [this issue](https://github.com/baldram/ESP_VS1053_Library/issues/24).

##### Get chip version via `SCI_STATUS`
A lot of the VS1003 and VS1053 devices completely look the same. They are even both labeled with "VS1003/1053 MP3 CODEC". To check which chip you are using use the `player.getChipVersion()`. It should return 4 for VS1053 and 3 for VS1003. This is also a lightweight method to check whether your VS10xx device is wired up correctly.

##### Check and reset decoding time by `SCI_DECODE_TIME`

`uint16_t seconds = player.getDecodedTime(); `

Above example and self-explanatory method name tells everything. It simply provides current decoded time in full seconds (from `SCI_DECODE_TIME` register value).

Optionally available is also `player.clearDecodedTime()` which clears decoded time (sets `SCI_DECODE_TIME` register to `0x00`).

##### Enable I2S output

```
player.enableI2sOut(/* i2sRate: optional sampling rate, default is 48kHz */);
player.disableI2sOut();
```
I2S output of the VS1053 chip can be enabled/disabled using methods `enableI2sOut` and `disableI2sOut`. When enabled, the gpio lines won't be available for other purposes. On reset the I2S output is disabled. The assignment to I2S lines is according to the table below:

| VS1053 GPIO | I2S |
|--------------|----------------|
| 4 | LROUT / WSEL |
| 5 | MCLCK |
| 6 | SCLK / BCLK |
| 7 | SDATA / DOUT |

Refer to the [VS1053 datasheet](https://www.vlsi.fi/fileadmin/datasheets/vs1053.pdf) for details: the pin assignment is specified in section 5.1 on page 12, the I2S DAC interface is described in section 11.14 on page 83.

#### Logging / debugging

The library uses ESP Arduino framework built in logger (Arduino core for [ESP32](https://github.com/espressif/arduino-esp32/issues/893#issuecomment-348069135) and [ESP8266](https://github.com/esp8266/Arduino/blob/master/doc/Troubleshooting/debugging.rst#debug-level)).<br />

To see debug messages please add build flags to your `platformio.ini` as below (depending on platform):

- for ESP8266:

`build_flags = -D DEBUG_ESP_PORT=Serial`

- for ESP32:

`build_flags = -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG`

The Serial Interface needs to be initialized in the `setup()`.

```c++
void setup() {
Serial.begin(115200);
}
```
Now if something is wrong, you'll see the output like below (from ESP32):

```shell
[I][main.cpp:117] setup(): Hello # VS1053!
[D][VS1053.cpp:156] begin():
[D][VS1053.cpp:157] begin(): Reset VS1053...
[D][VS1053.cpp:161] begin(): End reset VS1053...
[D][VS1053.cpp:119] testComm(): VS1053 not properly installed!
```
In successful case it would start with something like this:

```shell
[I][main.cpp:117] setup(): Hello # VS1053!
[D][VS1053.cpp:156] begin():
[D][VS1053.cpp:157] begin(): Reset VS1053...
[D][VS1053.cpp:161] begin(): End reset VS1053...
[D][VS1053.cpp:132] testComm(): Slow SPI,Testing VS1053 read/write registers...
[D][VS1053.cpp:132] testComm(): Fast SPI, Testing VS1053 read/write registers again...
[D][VS1053.cpp:183] begin(): endFillByte is 0
```

## Example wiring

An example for ESP8266 based board like eg. LoLin NodeMCU V3 or WeMos D1 R2.

| VS1053 | ESP8266 |
|----------|----------|
| SCK | D5 |
| MISO | D6 |
| MOSI | D7 |
| XRST | RST |
| CS | D1 |
| DCS | D0 |
| DREQ | D3 |
| 5V | VU |
| GND | G |

For ESP32 and other boards wiring examples please see thread [Supported hardware](https://github.com/baldram/ESP_VS1053_Library/issues/1) and [Tested boards](https://github.com/baldram/ESP_VS1053_Library/blob/master/doc/tested-boards.md) list.

<img alt="VS1053B and NodeMCU v3" title="VS1053B and NodeMCU v3" src="https://user-images.githubusercontent.com/16861531/27875071-3ead1674-61b2-11e7-9a69-02edafa7b286.jpg" width="300px" />

## Library developement

**Please feel invited** to provide your pull request with improvement or a bug fix.

A hint for CLion developers.
The IDE files are added to `.gitignore`, but once you clone the code you should be able to develop the
library easily with CLion after calling the command from terminal as below:

```sh
$ platformio init --ide=clion
```
Then please import the project and run the PIO task: `PLATFORMIO_REBUILD_PROJECT_INDEX`.<br />
Read more here: [PlatformIO & CLion integration](http://docs.platformio.org/en/latest/ide/clion.html).

## Additional hints

If you think how to convert the mp3 file into C header file, please find a [thread here](https://www.avrfreaks.net/comment/884247#comment-884247). It's as simple as calling:

`xxd -i your-sound.mp3 ready-to-use-c-header.h`

The `xxd` is available for any platform like Linux or Windows (distributed with Vim editor).
It will produce something like in the example [here](https://github.com/baldram/ESP_VS1053_Library/blob/master/examples/Mp3PlayerDemo/SampleMp3.h).
Of course as the file will be a part of firmware, it should be small enough according to limited microcontroller's resources The memory is at a premium ;-) I would suggest to use mp3 instead of wave, convert file from stereo to mono and use lower MP3 bit rate if possible (like 112kbps or less instead of 320kbps). Please also find [additional hints here](https://github.com/baldram/ESP_VS1053_Library/issues/18#issuecomment-408984920).


## Credits

Based on library/applications:
* [maniacbug/VS1053](https://github.com/maniacbug/VS1053) by [J. Coliz](https://github.com/maniacbug)
* [Esp-radio](https://github.com/Edzelf/Esp-radio) by [Ed Smallenburg](https://github.com/Edzelf)
* [smart-pod](https://github.com/MagicCube/smart-pod) by [Henry Li](https://github.com/MagicCube)

## License

Copyright (C) 2017<br/>
Licensed under GNU GPLv3
Binary file removed TFT_ILI9163C-master.zip
Binary file not shown.
Loading