Hi, hoping somebody can help. I think that my issue may be similar to that experienced in this recent thread:
https://forum.pjrc.com/threads/45689-Problem-with-sending-audio-data-over-ethernet, although my application is different.
I'm making an audio player that will download a file over FTP, save it to an SD card and subsequently play it when triggered. I'm using a Teensy 3.2 with a WIZ820io module and audio shield.
Against the odds, perhaps, this is more or less working. I can pick up an IP address on my LAN using DHCP, connect and download a file. I can also play audio apart until the Ethernet.begin, after which once can hear something, but audio is corrupted.
I'm struggling to find out where the problem is. I don't know whether the Teensy is struggling to process both the ethernet and audio data at the same time, or whether there's something else going on. I have thought about using a 3.6 instead should that be the case.
To make the WIZ820io work with the audio shield, I have, of course had to switch to using differing pins. This seems to be working fine. I've also tried resetting and powering down the WIZ before trying audio again and this doesn't help.
My test code is below. For completeness, 1.wav is a 126kB file at 1411kbps.
Any input or thoughts would be greatly appreciated.
Thanks in advance
David
https://forum.pjrc.com/threads/45689-Problem-with-sending-audio-data-over-ethernet, although my application is different.
I'm making an audio player that will download a file over FTP, save it to an SD card and subsequently play it when triggered. I'm using a Teensy 3.2 with a WIZ820io module and audio shield.
Against the odds, perhaps, this is more or less working. I can pick up an IP address on my LAN using DHCP, connect and download a file. I can also play audio apart until the Ethernet.begin, after which once can hear something, but audio is corrupted.
I'm struggling to find out where the problem is. I don't know whether the Teensy is struggling to process both the ethernet and audio data at the same time, or whether there's something else going on. I have thought about using a 3.6 instead should that be the case.
To make the WIZ820io work with the audio shield, I have, of course had to switch to using differing pins. This seems to be working fine. I've also tried resetting and powering down the WIZ before trying audio again and this doesn't help.
My test code is below. For completeness, 1.wav is a 126kB file at 1411kbps.
Any input or thoughts would be greatly appreciated.
Thanks in advance
David
Code:
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7
#define SDCARD_MISO_PIN 12
#define SDCARD_SCK_PIN 14
#define W5100_RESET_PIN 1
#define W5100_PWDN_PIN 2
#define W5100_SS_PIN 21
#include <Audio.h>
#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0xDD };
IPAddress ip(192, 168, 1, 105);
EthernetClient client;
EthernetClient dclient;
char ftp_server[] = "aaa.co.uk";
String fileName = "public_html/styles.css";
#define ftp_username aaa
#define ftp_password aaa
char outBuf[128];
char outCount;
File fh;
AudioPlaySdWav sd_card;
AudioOutputI2S soundcard;
AudioConnection patchcords[]={
AudioConnection(sd_card,0,soundcard,0),
AudioConnection(sd_card,1,soundcard,1)
};
AudioControlSGTL5000 sgtl5000_1;
void setup() {
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
Serial.begin(57600);
Serial.println("hello");
pinMode(W5100_RESET_PIN, OUTPUT);
pinMode(W5100_PWDN_PIN, OUTPUT);
digitalWrite(W5100_RESET_PIN, LOW); // begin reset the WIZ820io
delay(1000);
pinMode(W5100_SS_PIN, OUTPUT);
digitalWrite(W5100_SS_PIN, HIGH); // de-select WIZ820io
pinMode(SDCARD_SCK_PIN, OUTPUT);
digitalWrite(SDCARD_SCK_PIN, HIGH); // de-select the SD Card
delay(1000);
digitalWrite(W5100_PWDN_PIN, LOW);
digitalWrite(W5100_RESET_PIN, HIGH); // end reset pulse
AudioMemory(100);
// Enable the first audio shield, select input, and enable output
sgtl5000_1.enable();
sgtl5000_1.inputSelect(AUDIO_INPUT_LINEIN);
sgtl5000_1.volume(0.5);
//sgtl5000_1.adcHighPassFilterDisable();
sgtl5000_1.lineInLevel(0);
Serial.println("W5100 restarted");
delay(3000);
if (!(SD.begin(SDCARD_CS_PIN))) Serial.println("Unable to access the SD card");
else Serial.println("accessed sd card");
sd_card.play("1.wav");
delay(5);
while(sd_card.isPlaying()){
//
}
Ethernet.init(W5100_SS_PIN);
Serial.println("Attempting to get an IP address using DHCP:");
if (!Ethernet.begin(mac)) {
// if DHCP fails, start with a hard-coded address:
Serial.println("failed to get an IP address using DHCP, trying manually");
Ethernet.begin(mac, ip);
}
//Ethernet.begin(mac, ip, dns, gateway, subnet);
Serial.print("My address:");
Serial.println(Ethernet.localIP());
delay(2000);
//digitalWrite(W5100_RESET_PIN, LOW); // begin reset the WIZ820io
digitalWrite(W5100_PWDN_PIN, HIGH);
delay(2000);
sd_card.play("1.wav");
delay(5);
while(sd_card.isPlaying()){
//
}
Serial.println("READY");
//fDoFTP();
}
void loop() {
// put your main code here, to run repeatedly:
}