This commit is contained in:
andre.malo 2023-05-24 15:30:27 +02:00
parent 6cbe0da444
commit 2bb1f8cae8
2 changed files with 29 additions and 78 deletions

View file

@ -1,119 +1,70 @@
/*
ESP32 I2S Microphone Sample
esp32-i2s-mic-sample.ino
Sample sound from I2S microphone, display on Serial Plotter
Requires INMP441 I2S microphone
DroneBot Workshop 2022
https://dronebotworkshop.com
*/
#include <Arduino.h>
/*
Simple Internet Radio Demo
esp32-i2s-simple-radio.ino
Simple ESP32 I2S radio
Uses MAX98357 I2S Amplifier Module
Uses ESP32-audioI2S Library - https://github.com/schreibfaul1/ESP32-audioI2S
DroneBot Workshop 2022
https://dronebotworkshop.com
*/
// Include required libraries
#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"
// Define I2S connections
#define I2S_DOUT 22
#define I2S_BCLK 26
#define I2S_LRC 25
#define I2S_DOUT 22
#define I2S_BCLK 26
#define I2S_LRC 25
// Create audio object
Audio audio;
// Wifi Credentials
String ssid = "cohabit";
String ssid = "cohabit";
String password = "lewifidecohabit";
void setup() {
void setup()
{
// Start Serial Monitor
Serial.begin(115200);
// Setup WiFi in Station mode
WiFi.disconnect();
WiFi.mode(WIFI_STA);
WiFi.begin(ssid.c_str(), password.c_str());
while (WiFi.status() != WL_CONNECTED) {
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
// WiFi Connected, print IP to serial monitor
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("");
Serial.print("coucou");
// Connect MAX98357 I2S Amplifier Module
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
Serial.print("coucou");
// Set thevolume (0-100)
audio.setVolume(100);
// Connect to an Internet radio station (select one as desired)
//audio.connecttohost("http://vis.media-ice.musicradio.com/CapitalMP3");
//audio.connecttohost("mediaserv30.live-nect MAX98357 I2S Amplifier Module
//audio.connecttohost("www.surfmusic.de/m3u/100-5-das-hitradio,4529.m3u");
//audio.connecttohost("stream.1a-webradio.de/deutsch/mp3-128/vtuner-1a");
audio.connecttohost("www.antenne.de/webradio/antenne.m3u");
//audio.connecttohost("https://git.cohabit.fr/andre.malo/Amplificator/raw/branch/master/Mozart%20-%20Lacrimosa.mp3");
//audio.connecttoFS(m_f_localfile,"/Mozart - Lacrimosa.mp3");
//audio.playI2Sremains(m_f_localfile,"/Mozart - Lacrimosa.mp3");
audio.setVolume(50);
Serial.print("coucou");
audio.connecttohost("https://s4-webradio.antenne.de/antenne");
}
void loop()
{
// Run audio player
Serial.print("coucou");
audio.loop();
}
// Audio status functions
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_showstreaminfo(const char *info) {
Serial.print("streaminfo "); 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);
}