Hi all
After making many devices with Arduino Nano and ATMega328P and a LED NTP clock with ESP8266, now I'm trying to make an IP radio using an ESP32-WROOM-32D. I'm starting from this code:
#include "WiFi.h" // libreria wifi compresa nel pacchetto arduino-ESP32
#include "Audio.h" // libreria audio-I2S https://github.com/schreibfaul1/ESP32-audioI2S
#define LED 5 // led sulla board e su gpio 5
char* ssid1 = "***";
char* password1 = "***";
#define STAZIONE "https://icecast.unitedradio.it/Virgin.mp3" // web radio all'accensione
Audio audio(true, I2S_DAC_CHANNEL_BOTH_EN); // usa i due DAC interni a 8 bit su gpio25=L, gpio26=R
void setup() {
Serial2.begin(38400); // baud rate per BT
pinMode(LED,OUTPUT);
WiFi.disconnect(); // disconnette sessione wifi precedente
WiFi.mode(WIFI_STA); // imposta il modo stazione
Serial2.print("Connessione a ");
Serial2.println(ssid1);
WiFi.begin(ssid1, password1); // connette al wifi
while (WiFi.status() != WL_CONNECTED){ // aspetta la connessione al wifi
Serial2.print("."); // stampa punti in attesa
digitalWrite(LED,!digitalRead(LED)); // lampeggia in attesa
delay(1000);
}
digitalWrite(LED,LOW); // connessione al WIFI OK (led cablato a Vcc fisso)
Serial2.print("\n CONNESSO con IP: ");
Serial2.println(WiFi.localIP());
audio.setVolume(20); // volume:int8_t=0 ~ 21 (default=21); mode=0 default quadratic, 1= logaritmic
// audio.setBalance(0); // balance:int8_t=-16 ~ +16 default=0
// audio.setTone(0, 0, 0); // gain:int8_t=-40 ~ +6 dB: LOW, MIDDLE, HIGH
audio.connecttohost(STAZIONE); // <---- connette lo stream
}
//-------------------
void loop(){
audio.loop(); // decodifica lo stream
if(Serial2.available()){ // verifica la seriale2
audio.stopSong(); // ferma la riproduzione corrente
String r=Serial2.readString(); // carica la stringa da seriale2
r.trim(); // elimina <blank>, <CR>, <LF>
if(r.length()>5){ // accetta se la stringa è>5 (https:)
audio.connecttohost(r.c_str()); // <----- connette lo stream
}
}
}
//------------------------------
void audio_info(const char *info1){
Serial2.print("->"); // stampa tutti gli eventi sulla seriale2
Serial2.println(info1);
}
Upload was OK, but nothing happens... Only resetting after power on, I read on the serial monitor @115200 baud (115200???...) :
21:57:53.030 -> ets Jun 8 2016 00:22:57
21:57:53.030 ->
21:57:53.030 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
21:57:53.030 -> configsip: 0, SPIWP:0xee
21:57:53.030 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
21:57:53.030 -> mode:DIO, clock div:1
21:57:53.030 -> load:0x3fff0030,len:1184
21:57:53.030 -> load:0x40078000,len:13260
21:57:53.030 -> load:0x40080400,len:3028
21:57:53.063 -> entry 0x400805e4
I selected DOIT ESP32 DEVKIT V1, but I tried two other boards before...
Can you help me?
Thanks!
Gianluca
.-----------------------------------------------------------------------------
Some previous projects of mine:
Magnetometer: https://youtu.be/C1OvPseLLqw
Power Grid Monitor: https://youtu.be/bRFnRWFU8_s
Geiger counter: https://youtu.be/dXWPT-MWtUo