Replies: 2 comments 1 reply
-
That's an interesting thing. I have added the NetworkClient. But unfortunately I don't have an Ethernet board. Would a complete sketch look like this? #include "Arduino.h"
#include "Audio.h"
#include "SD.h"
#include "FS.h"
// Digital I/O used
#define SD_CS 5
#define SPI_MOSI 2
#define SPI_MISO 4
#define SPI_SCK 17
#define I2S_DOUT 12
#define I2S_BCLK 14
#define I2S_LRC 15
#define ETH_PHY_TYPE ETH_PHY_LAN8720
#define ETH_PHY_MDC 23
#define ETH_PHY_MDIO 18
#define ETH_CLK_MODE ETH_CLOCK_GPIO0_IN
Audio audio;
static bool eth_connected = false;
void onEvent(arduino_event_id_t event) {
switch (event) {
case ARDUINO_EVENT_ETH_START:
Serial.println("ETH Started");
// The hostname must be set after the interface is started, but needs
// to be set before DHCP, so set it from the event handler thread.
ETH.setHostname("esp32-ethernet");
break;
case ARDUINO_EVENT_ETH_CONNECTED: Serial.println("ETH Connected"); break;
case ARDUINO_EVENT_ETH_GOT_IP:
Serial.println("ETH Got IP");
Serial.println(ETH);
eth_connected = true;
break;
case ARDUINO_EVENT_ETH_LOST_IP:
Serial.println("ETH Lost IP");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_DISCONNECTED:
Serial.println("ETH Disconnected");
eth_connected = false;
break;
case ARDUINO_EVENT_ETH_STOP:
Serial.println("ETH Stopped");
eth_connected = false;
break;
default: break;
}
}
void setup() {
pinMode(SD_CS, OUTPUT); digitalWrite(SD_CS, HIGH);
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
Serial.begin(115200);
SD.begin(SD_CS);
Network.onEvent(onEvent);
ETH.begin();
while (!eth_connected) delay(100);
// Eth Connected,
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(21); // default 0...21
audio.connecttohost("http://stream.antennethueringen.de/live/aac-64/stream.antennethueringen.de/"); // aac
}
void loop()
{
audio.loop();
}
void audio_info(const char *info){
Serial.print("info "); Serial.println(info);
}
Then I would use it as an example or template. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes - I made some small changes to the example and tested it successfully on my board (WT32-ETH01 in Board Manager):
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello together, especially hello Wolle,
with some small changes in
audio.h
and the sample application it is possible to use a wired Ethernet connection (eg the ESP32-Eth0 boards) instead of WiFi for ESP32-audioI2S to increase the availability:Fortunately the WiFi and Eth API is more or less the same - in the
audio.h
source the changes are just the inclusion of other headers and other base classes for client/clientsecure instances:and
Changes in the Application are definitions for the PHY/Pin assignment
and afterwards (!) the inclusion of
Eth.h
insteadWiFi.h
.Unfortunately the "standard" pin assignement for the I2S interface (and SD-Card) have to be changed because the "standard" pins are used for the PHY, but IO12,IO14 and IO15 work as well:
(I have to admit, though, that I didn't test the SD card functionality on these pins...)
For ETH-Interface we need an additional Event handler and a status variable:
static bool eth_connected = false;
and from the Eth-Example:The
setup()
routine is short:That's it. (Tested with a WROOM-based ETH01 clone + PCM5102A board and Arduino IDE and some mp3 streams)
Because I am an absolute beginner with Git... is anybody interested in the wired ETH interface and/or would you, Wolle like to merge this into the master branch? Do I really need to fork, commit, pull-request and so on to contribute... or can I just send you my sources?
Best regards,
Chris
(PS: Thank you for your wonderful piece of code!)
Beta Was this translation helpful? Give feedback.
All reactions