macsbug

Web Radio of M5Stack PCM5102A I2S DAC

with 6 comments

M5Stack と PCM5102A I2S DAC Board で Web Radio を製作しました。 2021.02.19
………………………………….. Boards Manager 1.05 による改訂:rev1 : 2021.03.04
………………………………….. Boards Manager 1.06 による改訂:rev2 : 2021.05.01
………………………………….. A Button GPIO39 不具合対策追記:rev3 : 2022.08.10
………………………………….. スケッチ Rev.4, リニューアル  :rev4 : 2022.08.21

.
MP3 Board and I2S DAC Board:

VS1053B mp3
Library:
ESP8266 Audio
UDA1334A I2S DAC
Library:
ESP32-audioI2S
PCM5102A I2S DAC
Library:
ESP32-audioI2S
520円 300円 360円

.
仕様:
1. 局 ( Radio Station ) :150局。ボタンで選択。局の追加も可能です。
2. 再生:Stereo。
3. 音質:M5Stack内蔵スピーカーより遥かに良いです。
4. 操作:ボタンで操作します。
_  A button:Volume – 。B button:Channel up 。C button:Volume +
5. 文書発声機能:日本語、英語 等の文章が音声で出ます。

構成:
1. 開発機種:MacBook Pro (16-inch, 2019) , macOS Catalina Ver 10.15.7
2. 開発環境:Arduino IDE 1.8.13
3. 開発環境:Board Manager:ES32 Arduino 1.0.5
4. Library:m5stack / M5Stack
5. Library:schreibfaul1 / ESP32-audioI2S
6. HARD:M5Stack
7. HARD:PCM5102A I2S DAC Module
8. HARD:Speaker Amp or Headphones:ダイソー ミニスピーカー。Volume付き。

費用:1000円。( Without M5Stack )

No. Nomen Price
1 PCM5102A I2S DAC Module 360円
2 M-BUS PCB 100円
3 DAYSO Speaker 300円
4 Other(Case,Screw,Connector) 240円
Total 1000円

1. PCM5102A:Aliexpress $3.4(360円)以下で購入可能。輸送期間=20day.
.


.
🔵 追記:2022.08.21
スケッチ Rev.4, リニューアル:rev5 : 2022.08.21
.
🟢 Down Load:Web_Radio_of_M5Stack_I2S.zip
. Fileは PDF形式で DL後に Web_Radio_of_M5Stack_I2S.zip に変更し解凍します。
.
1. M5STack.h から M5Unified.h に変更。
2. I2S DAC は MAX1334A, UDA1334A, PCM5102A I2S DAC に対応。
3. 表示:
- Play LED , Reseption LED , Wave , Starion Store(保存) 追加。
- Starion Store は Play時の Stationを保存し 再起動時に そのStationから始めます。
- 起動して WiFi 接続中に B Button を押すと Station 0 になります。
- B button は ch 又は vol に切り替えます。
- A button で – , C button で + です。
4. Startionを受信しない時は 次のStationを選択します。
5. Station の見直し:廃止された局や再起動する局の削除。
6. 開発環境:
- Dev environment : Arduino IDE 1.8.19
- Board Manager : arduino-esp32 2.0.3-RC1
- Board : “M5Stack-Core-ESP32”
- Partition Scheme : “No OTA (Large APP)”
- Pord : “dev/cu.wchusbserial52D40039901”
- Library : schreibfaul1 / ESP32-audioI2S 2.0.4
.

.


.
Down Load:
. Web_Radio_of_M5Stack_I2S_DAC.zip を Down Load します。
. Fileは PDF形式で DL後に Web_Radio_of_M5Stack_I2S_DAC.zip に変更し解凍します。

. Library:ESP32-audioI2S


.
PCM5102A I2S DAC Module:
_ 電源(VIN)は 5Vdc。Line Output Load Resistance は MIN 1KΩ, NOR 10KΩ。
_ PCM5102A PDF。 PCM5102 製品詳細, データーシート。 PCM5102A Board Schematic

.


.
回路図:
_ 電源(VIN)は 5Vdc。PCM5102A は 3.3V。基板に LDO 3.3V (S2SL) があります。
_ GND = AGND = DGND

_ Down Load:PCM5102A_circuit_diagram.jpg.zip 1274 × 1178 pixels
.
PIN FUNCTIONS:Select = RED:購入時のセレクト状態。

H Name Description LOW (GND) HIGH (D 3.3V)
H1L FLT Filter select Normal latency Low latency
H2L DEMP De-emphasis control
for 44.1kHz sampling rate
Off On
H3L XMST Soft mute control Soft mute soft un-mute
H4L FMT Audio format selection I2S Left justified


.
LDO (5-terminal Regulator):ME6211C series ME6211C33M5G
_ Marking Code:S2RH , S2SL ( Maker:MicrOne ):ME6211 LDO pdf
_ Operating Voltage Range:2V~6.0V, VOUT=3.3V
_ Maximum Output Current:500mA

.


.
工作:MCP5102A の Jumper端子(SCK と GND) をハンダで接続(Short)します。
_   もしくは 下記 配線の基板上で SCK-GND接続でも良いです。
_   PCM5102Aの内部PLLを使用してシステムクロックを生成します。
_   誘電ノイズを防ぎます。
_   接続しなくても動作はします。


.
配線:5本 ( VIN, GND, LRCK, DIN, BCK )

PCM5102A VIN GND LRCK DIN BCK
M-BUS 5V GND 25 22 26


メモ:CUT(Yellow):基板の左端はGND。VINで使用する為に GNDの部分をCUTします。


.
ノイズ対策:M5Stackの改修。
_ 理由:I2S は M5Stack の GPIO-25 を使用します。
_ GPIO-25 には アンプとSpeakerが接続されており I2S信号でノイズがでます。
_ 対策:M5Stack基板上の T1 端子をハンダ付けでShort させます。
_ Speaker Amp の電源が遮断され ノイズが無くなります。


.
Arduino IDE 開発条件と方法:
_ 1. Additional Boards Manager URLs:ESP32 Stable version
_ 2. Boards Manager:ESP32 by Espresso Systems version 1.0.5
_ 3. Board Selection : M5Stack-Core-ESP32
_ の設定を行ないます。

条件:
1. Aduino IDE Additional Boards Manager URLs に以下のStable verを追加します。
_ 補足:released this Feb 23, 2021:Latest Stable Release and Latest Development Release

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

2. Arduino IDE Boards Manager 設定:
_ Boards Managerを選択し ESP32 で検索。
_ ESP32 by Espresso Systems version 1.05 にします。( released this Feb 23, 2021)
_

3. Arduino IDE 設定:
_ Board Selection : M5Stack-Core-ESP32

方法:スケッチ:宣言
1. include <M5Stack.h>
2. include <Audio.h>

補足:ESP32-audioI2S_Library ( Audio.cpp ) について。
_ Audio.cpp に以下の記述があり、上記設定外でコンパイルエラーが出る時があります。
_ Audio::Audio(const uint8_t BCLK, const uint8_t LRC, const uint8_t DOUT) {
_ clientsecure.setInsecure();
_ // if that can’t be resolved update to ESP32 Arduino version 1.0.5-rc05 or higher
_ //i2s configuration
_
.


.
Library:ESP32-audioI2S:文書発声機能:について。
_ ESP32-audioI2S にある Audio.cpp には 文書発声機能が内蔵されています。
_ https://translate.google.com.vn/translate_tts に WiFi接続し音声合成をする機能です。
_ これにより PCM5102A , UDA1334A I2S DAC から音声を出す事が出来ます。
_ 日本語、英語 等ができます。
_ 例:audio.connecttospeech(“こんにちは”, “ja”)
_ 例:audio.connecttospeech(“Hello”, “en”)
_ 例:audio.connecttospeech(“Wenn die Hunde schlafen”, “de”);
_ 例:audio.connecttospeech(“Este é um exemplo de síntese de voz usando esp 32”, “pt”);
.


.
Option:スケッチに以下を追加すると Serial Monitorで各種情報を見る事ができます。

/--------------------------------------------------------------
// Output infomation to serial output
void audio_info(const char *info){
  Serial.print("info        ");Serial.println(info);}
void audio_id3data(const char *info){  //id3 metadata
  Serial.print("id3data     ");Serial.println(info);}
void audio_eof_mp3(const char *info){  //end of file
  Serial.print("eof_mp3     ");Serial.println(info);}
void audio_showstation(const char *info){
  Serial.print("station     ");Serial.println(info);}
void audio_showstreamtitle(const char *info){
  Serial.print("streamtitle ");Serial.println(info);}
void audio_bitrate(const char *info){
  Serial.print("bitrate     ");Serial.println(info);}
void audio_commercial(const char *info){//duration in sec
  Serial.print("commercial  ");Serial.println(info);}
void audio_icyurl(const char *info){  //homepage
  Serial.print("icyurl      ");Serial.println(info);}
void audio_lasthost(const char *info){//stream URL played
  Serial.print("lasthost    ");Serial.println(info);}
void audio_eof_speech(const char *info){
  Serial.print("eof_speech  ");Serial.println(info);}
//-------------------------------------------------------------

.
Serial Monitorの情報:Station接続時に出力されます。

ESP32-Chimera-Core initializing...OK
info        PSRAM not found, inputBufferSize = 6399 bytes
info        buffers freed, free Heap: 207176 bytes
info        SSL has been established, free Heap: 164112 bytes
info        contentLength=4608 bytes
info        MP3Decoder has been initialized, free Heap: 137472 bytes
info        syncword found at pos 0
info        Channels=1
info        SampleRate=24000
info        BitsPerSample=16
info        BitRate=32000
eof_speech  こんにちは
info        buffers freed, free Heap: 206180 bytes
info        SSL has been established, free Heap: 164056 bytes
info        contentLength=9888 bytes
info        MP3Decoder has been initialized, free Heap: 139084 bytes
info        syncword found at pos 0
info        Channels=1
info        SampleRate=24000
info        BitsPerSample=16
info        BitRate=32000
eof_speech  Web Radio of M5Stack
info        buffers freed, free Heap: 205940 bytes
info        SSL has been established, free Heap: 163848 bytes
info        contentLength=5952 bytes
info        MP3Decoder has been initialized, free Heap: 139068 bytes
info        syncword found at pos 0
info        Channels=1
info        SampleRate=24000
info        BitsPerSample=16
info        BitRate=32000
eof_speech  Smooth Jazz
info        buffers freed, free Heap: 205848 bytes
info        Connect to new host: "http://sj32.hnux.com/stream?type=http&nocache=3104"
info        Connect to "sj32.hnux.com" on port 80, extension "/stream?type=http&nocache=3104"
info        Connected to server
info        HTTP/1.0 200 OK
info        icy-notice1:<BR>This stream requires <a href="http://www.winamp.com">Winamp</a><BR>
info        icy-notice2:SHOUTcast DNAS/posix(linux x64) v2.5.5.733<BR>
info        access-control-allow-origin:*
info        icy-name: SmoothJazz.com Global
station     SmoothJazz.com Global
bitrate     32000
info        icy-sr:22050
info        icyurl
icyurl      http://smoothjazz.com
info        content-type:audio/mpeg, format is mp3
info        MP3Decoder has been initialized, free Heap: 174404 bytes
info        x-clacks-overhead:GNU Terry Pratchett
info        Switch to SWM, bitrate is 32000, metaint is 0
lasthost    sj32.hnux.com/stream
info        inputbuffer is being filled
info        stream ready
info        buffer filled in 290 ms
info        syncword found at pos 0
info        syncword found at pos 0
info        syncword found at pos 0
info        Channels=1
info        SampleRate=22050
info        BitsPerSample=16
info        BitRate=32000

.
課題:時々 ボタンを押さなくとも GPIO 39 に Pulseが発生し Vol – が動作する。
_ 特に Joy Radio Station , http://uk5.internet-radio.com:8174/ で多く発生する。
_ 受信の あるタイミングで GPIO 39 をアクセスします。
_ ソフト検証では、GPIO 39 に 0〜1msec 程度の Pulse が発生します。
_  24msec程度の時も1度経験しました。
対策:M5.BtnA.wasPressed() でなく、M5.BtnA.pressedFor(50) にて
_   50msec以上の場合の時に Vol – を動作する様にしました。
_   メモ:通常、人のボタンをプチッと押す時間は 200〜300msec程度です。
🔴 追記:2022.08.10
M5Stack の ButtonA が 勝手に動作する 原因と対策。
原因は ESP32チップのバグです。
対策:( 回避策 )
_ Arduino IDE:Setup() , WiFi.begin(); の直後に
_ WiFi.setSleep(false); を記載します。

void setup(){
  WiFi.begin();
  WiFi.setSleep(false);
}

参考:
ButtonA on M5Stack does not work properly

ButtonA on M5Stack does not work properly


.


.
感想:
1. 注意:ESP32-audioI2S の Audio.cpp の注意書きの対応が必要です。
_ ESP32 by Espresso Systems version 1.05 を使用します。
2. 速度:PCM5102A と Library ESP32-audioI2S は 通信速度が速く,出力が大きく音が明瞭です。
3. 費用:PCM5102A Module は 360円以下で安価にできます。
_    ただし国内やアマゾンでは高価な価格で販売されています。
4. 局数:150局。現存する Web Radio の中で最大の局数です。
5. ESP32 by Espresso System version:
_ 1.05-rc4:コンパイルエラーが発生しました。
_ 1.05-rc5, 1.05-rc6:たまに M5stackの画面が白くなる現象がありました。
_ 1.05-rc7:M5stackの画面が白くなる現象は治りました。
_  ただし、ESP32-audioI2S ( Audio.cpp ) を使用する為に、
_  ESP32 by Espresso Systems version 1.05-rc7 が必要である事、
_  さらに Board Select を ESP32 Dev Module にする事。
_  M5Stack で使用するには ESP32-Chimera-Core が必要になる事。
_  この為に M5.Lcd の ボタン操作命令が使用出来ないとか
_  一部の画像表示命令が使用出来ない制限がありました。
_ 2021.02.23 に ver 1.0.5 が公開されました。
_ ver 1.05:M5Stackの画面が白くなる現象は無くなりました。
_ ver 1.05:M5Stack.h が使用でき M5Stack開発環境で開発出来る様になりました。
7. 課題と対策:たまに VOL- (GPIO39)が動作する課題がありました。原因不明。
_ VS1053 mp3 Board, I2S DAC UDA1334A, PCM5102A Board にて VOL- が発生します。
_ 対策は VOL- に 50msec Filter を入れました。
_ 追記:2021.05.01
_  原因は ESP32 by Espresso Systems version 1.06 によるものらしい。
_  WiFi 使用時に発生します。
_  対策は WiFi.Begin(); の後に WiFi.setSleep(false); 追加し GPIO39の誤動作は無くなりました。
8. 回路図作成:海外でPCM5102A I2S DAC Board の回路図が無いとの論議が多くあります。
_ 回路図は重要ですので Boardからと情報を集め作成しました。


.
スケッチ:Web Radio of M5Stack and I2S DAC : 2021.02.14 : macsbug
_ Enter your ssid and password:Wifi の ssid , pass は ご自身の値を設定してください。

///===========================================================
// Web Radio of M5Stack I2S DAC 
// UDA1334A : ORG   : 2021.02.14 : macsbug
// PCM5102A : rev 1 : 2021.02.20 : macsbug
// PCM5102A : rev 2 : 2021.03.03 : macsbug
// GPIO39   : rev 3 : 2021.05.01 : macsbug
// Github   : https://macsbug.wordpress.com/2021/04/16/web-radio-with-a-built-in-speaker-in-m5stack/
// Github   : https://macsbug.wordpress.com/2021/02/14/web_radio_of_m5stack_i2s_dac/
// Github   : https://macsbug.wordpress.com/2021/02/19/web-radio-of-m5stack-pcm5102a-i2s-dac/
// Github   : https://macsbug.wordpress.com/2021/01/08/web-radio-of-m5stack/
// Development environment : Aduino IDE ver 1.8.13
// Additional Boards Manager URLs : 
//            https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
// Boards Manager  : ESP32 by Espresso System version 1.06
// Board selection : M5Stack-Core_ESP32
// Library  : schreibfaul1/ESP32-audioI2S_Library
//            https://github.com/schreibfaul1/ESP32-audioI2S
// HardWare : M5Stack and UDA1334A I2S DAC Board
// HardWare : M5Stack and PCM5102A I2S DAC Board
// M5Stack  : Short T1 of M5stack Board(M5 Speaker Nois Cut)
// M5.BtnA.wasPressed() conflicts with WiFi? #52
//            https://github.com/m5stack/M5Stack/issues/52 
// After 1.0.6 update WiFi won't connect to other network // connection time increased #4980
//            https://github.com/espressif/arduino-esp32/issues/4980
//===========================================================

#pragma GCC optimize ("Ofast")
#include <M5Stack.h>
#include <M5StackUpdater.h> // SD-Upadate
#include "Free_Fonts.h"
#include <Arduino.h>
#include <WiFi.h>
#include <Audio.h>
Audio audio;
#define I2S_BCK  26 // M5Stack Node I2S pins
#define I2S_WS   25 // M5Stack Node I2S pins
#define I2S_DOUT 22 // M5Stack Node I2S pins
//        Enter your ssid and password. ------------
char ssid[] = "xxx"; // your network SSID (name) 
char pass[] = "xxx"; // your network password
int counter=0, old_counter=0, new_counter=0; 
int playflag=0, led=0, vol=5;
char URL[100], sname[100];

int Number_of_urls = 164 -1; // Change depending on the number of URLs
char *url[164] = {           // url*Station nam 
 "http://sj32.hnux.com/stream?type=http&nocache=3104*Smooth Jazz",
 "http://listen.181fm.com/181-beatles_128k.mp3*181-beatles_128k",
 "http://us2.internet-radio.com:8023/*Love Radio 93.9",
 "http://us5.internet-radio.com:8096/*I Love Smooth Jazz",
 "http://us5.internet-radio.com:8201/*Keith Jarrett - Over The Rainbow",
 "http://us3.internet-radio.com:8639/*Smooth Jazz Planet",
 "http://us5.internet-radio.com:8022/*Smooth Jazz DC",
 "http://us2.internet-radio.com:8046/*Matt Johnson Radio",
 "http://uk2.internet-radio.com:8236/*Funky Jazz/Soul 101 Radio",
 "http://us4.internet-radio.com:8171/*Smooth Jazz - Tampa Bay",
 "http://uk5.internet-radio.com:8174/*Joy Radio",
 "http://us3.internet-radio.com:8485/*Smooth Jazz CD 101.9 New York",
 "http://us1.internet-radio.com:8212/*KHIH-DB Colorado Smooth Jazz",
 "http://us2.internet-radio.com:8443/*MEGATON CAFE RADIO",
 "http://us4.internet-radio.com:8193/*RADIO ESTILO LEBLON",
 "http://us3.internet-radio.com:8297/*The Ranch - Classic Country",
 "http://uk7.internet-radio.com:8000/*MoveDaHouse",
 "http://uk1.internet-radio.com:8004/*Pink Noise Radio",
 "http://us5.internet-radio.com:8267/*CLASSIC ROCK RADIO HD",
 "http://us4.internet-radio.com:8258/*Classic Rock Florida HD",
 "http://us4.internet-radio.com:8266/*Smooth Jazz Florida",
 "http://us3.internet-radio.com:8297/*The Ranch - Classic Country",
 "http://uk6.internet-radio.com:8120/*Radio West Middlesex",
 "http://us3.internet-radio.com:8232/*Bach - C Major Prelude",
 "http://uk6.internet-radio.com:8144/*Radio Cherwell - Hospital Radio in Oxford",
 "http://uk5.internet-radio.com:8237/*Stoke Mandeville Hospital Radio",
 "http://us2.internet-radio.com:8075/*Classic Hits Global HD",
 "http://uk7.internet-radio.com:8226/*Box UK Radio danceradiouk",
 "http://us4.internet-radio.com:8193/*RADIO ESTILO LEBLON",
 "http://us4.internet-radio.com:8258/*Classic Rock Florida HD",
 "http://us4.internet-radio.com:8197/*EZ Hits South Florida",
 "http://uk7.internet-radio.com:8040/*Ava Max - Sweet But Psycho",
 "http://us5.internet-radio.com:8021/*Bill Evans",
 "http://uk2.internet-radio.com:31491/*A Heavenly World of Sound",
 "http://sj32.hnux.com/stream?type=http&nocache=1257*Smooth Lounge",
 "http://relay4.slayradio.org:8200/*SlayRadio", 
 "http://allstream.rainwave.cc:8000/all.mp3*Rainwave All",
 "http://tx.sharp-stream.com/icecast.php?i=planetrock.mp3*Planet Rock",
 "http://s1.viastreaming.net:8000*Smooth Choice",
 "http://sc6.radiocaroline.net:8040/listen.pls*Radio Caroline",
 "http://sc6.radiocaroline.net:10558/listen.pls*Radio Caroline Flashback",
 "http://listen.181fm.com/181-uktop40_128k.mp3*181 F M Top 40",
 "http://listen.181fm.com/181-90scountry_128k.mp3*181 F M Country",
 "http://listen.181fm.com/181-oldschool_128k.mp3*181 F M Old School",
 "http://listen.181fm.com/181-90sdance_128k.mp3*181 F M Nineties Dance",
 "http://listen.181fm.com/181-chilled_128k.mp3*181 F M Chilled",
 "http://listen.181fm.com/181-classical_128k.mp3*181 F M Classical", //
 "http://ice2.somafm.com/christmas-128-mp3*SomaFM Xmas",
 "http://www.internet-radio.com/station/sanfranciscos70shits/*San Franciscos 70s Hits",
 "http://5.152.208.98:8058/*Ancient FM",
 "http://streamer.radio.co/s06b196587/listen*KPop Way Radio",
 "http://jenny.torontocast.com:8134/stream*Mega Shuffle",
 "http://wbgo.streamguys.net/wbgo96*WBGO FM 96",
 "http://wbgo.streamguys.net/thejazzstream*jazzstream",
 "http://stream.srg-ssr.ch/thejazzstream*mp3_128",
 "http://icecast.omroep.nl/3fm-sb-mp3*3fm-sb-mp3",
 "http://media-ice.musicradio.com:80/ClassicFMMP3*Classic FM",
 "http://113fm-edge2.cdnstream.com/5185_48*BigR - 80s Lite",
 "http://streaming307.radionomy.com/WOKEmemories_64.aac*WOKEmemories ",
 "http://streaming316.radionomy.com/W1RS-blues--Rock-s-Radio*W1RSblues&Rock'sRadio",
 "http://streaming307.radionomy.com/bleudream-80_64.aac*bleudream-8",
 "http://streaming211.radionomy.com/ClassicRock-HardRock_64.aac*ClassicRock&HardRock",
 "http://streaming211.radionomy.com/kingdom-rap-radio*KingdomRapRadio",
 "http://streaming211.radionomy.com/radio-delight-kwitonta*Delight Kwitonta FM",
 "http://streaming308.radionomy.com/ViejitasPeroBonitasRadio*Viejitas Pero Bonitas Radio",
 "http://streaming307.radionomy.com/mmabathofm-live*Mmabatho FM LIVE",
 "http://streaming211.radionomy.com/sjl-radio*SjlRadio",
 "http://188.138.9.183/lounge-austria-mobile.mp3*Unspecified name",
 "http://ais-edge24-nyc06.cdnstream.com/2316_128.mp3*Foster Care Warrior Radio",
 "http://play.global.audio/bgradio128*RADIO BGRADIO",
 "http://webradio.antennevorarlberg.at/live*ANTENNE VORARLBERG HD",
 "http://s2.cdnradio.ru/ru-mp3-128*RUSSIAN SONGS",
 "http://live.coolradio.rs/cool128*COOL radio | Serbia",
 "http://streaming315.radionomy.com/foxnews*FOX News Radio",
 "http://ais-edge16-jbmedia-nyc04.cdnstream.com/hot108*HOT 108 JAMZ",
 "http://streams.iloveradio.de/iloveradio1.mp3*I Love Radio",
 "http://live.antenne.at/as*Antenne Steiermark",
 "http://webstream.schlagerparadies.de/schlagerparadies128k.mp3*SCHLAGERPARADIES",
 "http://streaming211.radionomy.com/rtl-1025*RTL 102.5",
 "http://retesport.newradio.it/1*RETE SPORT",
 "http://icy.unitedradio.it/VirginRogerWaters.mp3*PinkFloyd",
 "http://live.m2stream.fr/m280-128.mp3*M2 80's",
 "http://live.m2stream.fr/m2hit-128.mp3*M2 Hit's",
 "http://live.m2stream.fr/m2club-128.mp3*M2 Club",
 "http://live.m2stream.fr/m2love-128.mp3*M2 Love",
 "http://live.m2stream.fr/m2rock-128.mp3*M2 Rock",
 "http://live.m2stream.fr/m2sunshine-128.mp3*M2 Sunshine",
 "http://100radio-90.ice.infomaniak.ch/100radio-90-64.aac*100  0",
 "http://100radio-80.ice.infomaniak.ch/100radio-80-64.aac*1000",
 "http://100radio-hit.ice.infomaniak.ch/100radio-hit-64.aac*100",
 "http://icecast.vgtrk.cdnvideo.ru/vestifm_aac_32kbps*FM News",
 "http://nashe1.hostingradio.ru/nashe20-128.mp3*Our Radio",
 "http://mp3.ffh.de/radioffh/hqlivestream.aac*hqlivestream",
 "http://radiostreaming.ert.gr/ert-kosmos*ert-kosmos",
 "http://ic6.101.ru:8000/a161*Italo Disco",
 "http://cmr-hosting.com/*8050**CLUB MUSIC RADIO - ITALO DISCO",
 "http://den.101.ru:4000/ar_66_03*101.ru - AutoRadio Ekaterinburg",
 "http://ic7.101.ru:8000/a79*101.ru - Cyber Space",
 "http://ic7.101.ru:8000/a161*101.ru - Italo Disco",
 "http://ic7.101.ru:8000/a175*ENIGMA",
 "http://vladfm.com:8000/vfm*Radio Vladivostok FM",
 "http://jfm1.hostingradio.ru:14536/rcstream.mp3*Radio Classic",
 "http://retroserver.streamr.ru:8043/retro128*Radio Retro FM",
 "http://retro70.hostingradio.ru:8025/retro70-128.mp3*Radio Retro FM 70e",
 "http://91.211.56.218:8080/piramida/nazarovo*Radio Piramida FM",
 "http://sea.1tvcrimea.ru:9003/stream_sea.mp3*Radio More",
 "http://kommersant77.hostingradio.ru:8016/kommersant128.mp3*Radio Kommersant FM",
 "http://bfmstream.bfm.ru:8004/fm64*Business FM Moscow 87.5",
 "http://ep128server.streamr.ru:8030/ep128*Europe plus",
 "http://212.26.146.50:8000/rusrock.mp3*Russian rock music",
 "http://listen2.myradio24.com:9000/8144*Radio Magic",
 "http://media2.brg.ua:8000/shanson_l*Radio Chanson",
 "http://online1.gkvr.ru:8000/radiola_eka_128.mp3*Radio Radiola",
 "http://online.radiorecord.ru:8102/sd90_128*Disco 90х",
 "http://online.radiorecord.ru:8102/sd90_128*Superdisco 90х",
 "http://airspectrum.cdnstream1.com:8000/1261_192*Magic Oldies Florida",
 "http://37.187.79.93:8368/stream2*stream2",
 "http://tropicalisima.net:8020/stream/1/*stream",
 "http://192.173.28.222:3690/KRSHFMAAC_SC*The Krush - Wine Country Radio",
 "http://ice.creacast.com/myzen-aac-64*MyZen Radio",
 "http://cms.stream.publicradio.org/cms.aac*Classical 24",
 "http://ais-sa3.cdnstream1.com/2440_128.aac*Oregon Public Broadcasting",
 "http://nis.stream.publicradio.org/nis.aac*MPR News - Minnesota Public Radio",
 "http://current.stream.publicradio.org/current.mp3*The Current",
 "http://stm29.conectastm.com:18860/stream*Nativa FM",
 "http://stream.haarlem105.nl:8000/haarlem105low.mp3*Haarlem 10",
 "http://rockthecradle.stream.publicradio.org/radioheartland.mp3*Radio Heartland - MPR",
 "http://studioone-stream.iowapublicradio.org/StudioOne.mp3*Iowa Public Radio News and Studio One",
 "http://opera-stream.wqxr.org/wnycam-app*WNYC-AM - New York Public Radio",
 "http://bbcmedia.ic.llnwd.net/stream/bbcmedia_radio4fm_mf_p*BBC Radio 4",
 "http://bbcwssc.ic.llnwd.net/stream/bbcwssc_mp1_ws-einws*BBC World Service",
 "http://sc8.radiocaroline.net/;*Radio Caroline",
 "http://108.61.154.147:6978/*The Nemesis Radio",
 "http://198.50.156.92:8439/*Power 945 ~Your Anime & Gaming Connection~",
 "http://198.50.158.92:8803/*Japannext Radio",
 "http://62.75.215.7:8016/*Blue Heron Radio",
 "http://23.29.71.154:8062/*Friends Forever",
 "http://184.75.223.178:8011/*J-Idols Project Radio - Global Edition",
 "http://radio.kahoku.net:8000/*FMkahoku",
 "http://51.81.46.118:3350/*J-Club Powerplay HipHop",
 "http://51.81.46.118:3340/*J-Rock PowerPlay",
 "http://184.75.223.178:8083/*J-Pop Project Radio - Global Edition",
 "http://uk5.internet-radio.com:8306/*Moon Mission Recordings, Tokyo Deep and Electronic",
 "http://sj32.hnux.com/stream?type=http&nocache=3104*Smooth Jazz",
 "http://uk7.internet-radio.com:8226/*Box UK Radio danceradiouk",
 "http://uk6.internet-radio.com:8230/*Brassbandradio Radio",
 "http://uk1.internet-radio.com:8355/*The Zone - Dublin",
 "http://uk5.internet-radio.com:8011/*Top 80 radio",
 "http://uk7.internet-radio.com:8281/*SWEET ONE RADIO (FRENCH RADIO)",
 "http://uk2.internet-radio.com:8288/*Lymm Community Radio",
 "http://us3.internet-radio.com:8496/*RaveRocksRadio",
 "http://uk3.internet-radio.com:8288/*Relaxing Music",
 "http://us3.internet-radio.com:8157/*Amaghana Radio",
 "http://uk1.internet-radio.com:8465/*Great relaxing music, a nice journey away of the daily problems",
 "http://us3.internet-radio.com:8157/*Amaghana Radio",
 "http://uk1.internet-radio.com:8235/*Hospital Radio",
 "http://us5.internet-radio.com:8026/*Ukiss Radio",
 "http://uk6.internet-radio.com:8224/*Breaking Barriers Bulgaria",
 "http://us2.internet-radio.com:8075/*Classic Hits Global HD",
 "http://uk7.internet-radio.com:8168/*242 RADIO stream",
 "http://uk3.internet-radio.com:8405/*Majestic Jukebox Radio #HIGH QUALITY SOUND",
 "http://us2.internet-radio.com:8443/*MEGATON CAFE RADIO"
};
//  http://icecast.omroep.nl
//  http://github.com/pilnikov/KaRadio32_fork/blob/master/playlist/WebStations.txt
//  http://fmstream.org
//  http://www.internet-radio.com

//============================================================
void setup() {
  // M5Stack Initialize --------------------------------------
  M5.begin();
  Wire.begin();if(digitalRead(BUTTON_A_PIN)==0){updateFromFS(SD);ESP.restart();}
  M5.Lcd.setRotation(1);
  M5.Lcd.fillScreen  (BLUE);               // 0x657F
  M5.Lcd.setFreeFont (FMB12);              // font
  MP(0,1,0xFFFF," Web Radio of M5Stack");  // x,yLine,WHITE
  // WiFi Connection ----------------------------------------
  WiFi.disconnect();
  WiFi.begin(ssid,pass);                   // Set ssid,pass
  WiFi.setSleep(false);                    // Prevent GPIO39 Pulse
  M5.Lcd.setTextColor(WHITE);M5.Lcd.setCursor(0,44);
  while(WiFi.status()!=WL_CONNECTED){delay(50);M5.Lcd.print(".");}
  MP(0,2,0xFFFF,"Connected to Wifi");      // Infomation
  // UDA1334A or PCM5102A I2S DAC Initialize ----------------
  audio.setPinout(I2S_BCK,I2S_WS,I2S_DOUT);// Setup I2S Pin
  audio.setVolume(vol);                    // Set Vol 0...21
  speech("こんにちは","ja");                 // Speech
  speech("Web Radio of M5Stack","en");     // Speech
  // Button Initialize --------------------------------------
  Button_(0xD6DA,0xD6DA,0xD6DA);           // ch Button off
  delay(1000);
}
//============================================================
void loop() {
  M5.update();
  audio.loop();//Executes an internal loop of the audio library
  // playflag 0 ---------------------------------------------
  if (playflag == 0){
    // Station up -------------------------------------------
    Button_(0xD6DA,0x762F,0xD6DA);       // ch Button on
    MP(0,2,0xFFFF,"Wait...");            // Infomation
    url_sname(counter);                  // station,url,sname
    speech(sname,"en");                  // speech
    audio.connecttohost(URL);            // URL connection
    playflag = 1;
    // Display update ---------------------------------------
    MP(0,3,0xFFFF,"Station:"+String(counter));// Staion NO.
    M5.Lcd.fillRect (0,110,320,80,BLUE);      // clear
    MP(0,4,0xFFFF,"Playing:"+String(sname));  // Staion name
    set_vol_btn();                       // Volume and Button
    M5.Lcd.fillRect (0,30,320,20,BLUE);  // Clear info Line
    MP(0,2,0xFFFF,"Playing");            // Infomation
  }
  // playflag 1 ----------------------------------------------
  // Play LED ------------------------------------------------
  led = led + 1;
  if (led>1){led=0;M5.Lcd.fillCircle(310,8,5,GREEN);// led on
    }else{         M5.Lcd.fillCircle(310,8,5,BLUE );// led off
  }
  // ch+ -----------------------------------------------------
  if(M5.BtnB.wasPressed()){                // B Button
    M5.Lcd.fillRect (0,110,320,88,BLUE);   // Clear Sta,sname Line
    Button_(0xD6DA,0x762F,0xD6DA);         // ch Button on
    old_counter=counter;                   // old counter set
    counter=counter+1;                     // Station UP
    if(counter>Number_of_urls){counter=0;} // url count
    new_counter=counter;                   // New Station UP
    playflag = 0;                          // Start Play
  }
  // Vol- -----------------------------------------------------
  if(M5.BtnA.wasPressed()){                // A Button
    Button_(0x762F,0xD6DA,0xD6DA);         // vol Button on
    vol=vol-1; if(vol<0){vol=0;}           // Vol -
    set_vol_btn();                         // Volume and Button
  }
  // Vol+ ------------------------------------------------------
  if(M5.BtnC.wasPressed()){                // C Button
    Button_(0xD6DA,0xD6DA,0x762F);         // vol Button on
    vol=vol+1; if(vol>21){vol=20;}         // Vol +
    set_vol_btn();                         // Volume and Button
  }
} // End of Loop
//==============================================================
void MP(int xpos, int yLine, int16_t color, String str){
  M5.Lcd.fillRect (xpos,30*yLine-30,320,20,BLUE); // clear
  M5.Lcd.setCursor(xpos,30*yLine-16);             // yLine:0-8
  M5.Lcd.setTextColor(color);M5.Lcd.println(str); // Display
// https://github.com/m5stack/m5-docs/blob/master/docs/ja/api/lcd.md
}
//--------------------------------------------------------------
void set_vol_btn(){
  audio.setVolume(vol);                    // Set Volume
  MP(0,7,0xFFFF,"Volume:");MP(100,7,0xFFFF,String(int(vol*5)));
  M5.Lcd.progressBar(150,180,160,16,vol*5);// ProgressBar
  delay(250);Button_(0xD6DA,0xD6DA,0xD6DA);// vol Button off
}
//--------------------------------------------------------------
void Button_(long BA,long BB,long BC){     // Button display
  // https://trolsoft.ru/en/articles/rgb565-color-picker
  M5.Lcd.setTextColor(BLACK);              // BLACK
  M5.Lcd.fillRoundRect( 37,210,60,30,5,BA);
  M5.Lcd.setCursor( 40,230);M5.Lcd.println("vol-");
  M5.Lcd.fillRoundRect(133,210,60,30,5,BB);
  M5.Lcd.setCursor(149,230);M5.Lcd.println("ch");
  M5.Lcd.fillRoundRect(226,210,60,30,5,BC);
  M5.Lcd.setCursor(229,230);M5.Lcd.println("vol+");
}
//--------------------------------------------------------------
void url_sname(int c){ // Separate into URL, sname
  // URL -------------------------------------------------------
  String u=String(url[c]).substring(0,String(url[c]).indexOf("*")+1); 
  u.toCharArray(URL,u.length());           // URL
  // Sname -----------------------------------------------------
  String s=String(url[c]).substring(String(url[c]).indexOf("//")+2); 
  String n=s.substring(s.indexOf("*")+1)+1;
  n.toCharArray(sname,n.length());         // sname
}
//--------------------------------------------------------------
void speech(char* speech, char* Lang){ // Increase volume by +5
  audio.setVolume(vol+5);audio.connecttospeech(speech,Lang);
  audio.setVolume(vol);
}
//--------------------------------------------------------------

.
,
M5Stack , Web Radio , UDA1334A , I2S DAC , 1334A , PCM5102A , Boards Manager .

Written by macsbug

2月 19, 2021 @ 3:14 pm

カテゴリー: M5STACK

6件のフィードバック

Subscribe to comments with RSS.

  1. […] 上記のDACモジュール基板は部品面の裏側にPIN FUNCTION設定をする必要があるらしい。 Web Radio of M5Stack PCM5102A I2S DAC | macsbugを参考にさせてもらった。 […]

    • サイトへの訪問をありがとうございます。
      ブログを拝見致しました。
      「はじめに」から 目的に引き込まれ、どうしたら良いかの流れに
      共感する物がありじっくり読ませて頂きました。
      >開発環境のESP-IDFは「古い記事が多く(2018年前後)、その後は見付からない」

      >コンパイル時にエラーが出てしまう。
      確かに その通りで開発環境 Arduino IDEの選択に心響くものがあります。
      >最終的に辿り着いたのがBluetooth Audio for Arduinoだ。
      素晴らしいです!
      私は、此処に辿り着かずで、感心致しました。
      丁寧でコツコツと進める姿に教わる物があり、ありがとうございました。

      macsbug

      4月 13, 2023 at 3:51 am

  2. […] of the information I gleaned about the PCM5102 board I got from this macsbug blog post. It is very handy. From it is also the schematic for the PCM5102 board, included […]

  3. こんにちは DACを調べています。
    出力のオフセット「Bipolar zero error」等はどれくらいに収まっていましたでしょうか?

    nekomaeru

    5月 19, 2023 at 3:35 am


コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト /  変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト /  変更 )

%s と連携中

%d人のブロガーが「いいね」をつけました。