Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By danbicks
#29592
redflag2k wrote:
Tolipwen wrote:
Do you mind sharing the sound board you are using for this project? I'm interested in using an ESP for a WebRadio myself.



Hi. This is very simple question.

I use VS1053 module (see this link : http://www.aliexpress.com/item/1PCS-New ... 5,201409_2 )

and Please check this great job... http://www.serasidis.gr/circuits/Arduin ... player.htm


Hi @redflag2k,

Have you now managed to get this all working with the VS1053?

Would really like to make one of these up and have it connected to my Hifi as a web player. Would be great if you have the full code working, I will order a VS1053.

Great project guys.

Dans
User avatar
By danbicks
#29910
danbicks wrote:
redflag2k wrote:
Tolipwen wrote:
Do you mind sharing the sound board you are using for this project? I'm interested in using an ESP for a WebRadio myself.



Hi. This is very simple question.

I use VS1053 module (see this link : http://www.aliexpress.com/item/1PCS-New ... 5,201409_2 )

and Please check this great job... http://www.serasidis.gr/circuits/Arduin ... player.htm


Hi @redflag2k,

Have you now managed to get this all working with the VS1053?

Would really like to make one of these up and have it connected to my Hifi as a web player. Would be great if you have the full code working, I will order a VS1053.

Great project guys.

Dans


Guys are there any updates on this project?

Big thanks

Dans
User avatar
By Roman Kis
#30642
redflag2k wrote:Hi.. Did you solve the problem?

I have same issue with ESP8266 (Arduino IDE)+ VS1053 audio module.
Max play time is 53sec. in general, 10~15 sec.

My code is as follows (Selected line)
-- ----
Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <SPI.h>
const char* ssid     = "...";
const char* password = "...";

#define BUFFER_LENGTH 512       //Ethernet data bufer length.
#define BUFFER_LENGTH2 32       //VS1053 data buffer length

////////////////////////////////////////////////////////////////////////
//VS1053 player(0, 2, 4, 5); // cs_pin, dcs_pin, dreq_pin, reset_pin
#define cs_pin 0
#define dcs_pin 2
#define dreq_pin 4
#define reset_pin 5

const uint8_t vs1053_chunk_size = 32;

void setup () {
    //for ESP8266 SPI Pin setting (2015.06.20)
    pinMode(12, FUNCTION_2); //MISO
    pinMode(13, FUNCTION_2); //MOSI
    pinMode(14, FUNCTION_2); //SCLK
     
    SPI.begin();   // Start SPI
    Serial.begin(115200); // Start Serial

  Serial.println("Booting VS1053...");   // Boot VS1053D
  delay(1);
  SPI.setClockDivider(SPI_CLOCK_DIV64); // Slow!
  digitalWrite(reset_pin,HIGH);    //Mp3ReleaseFromReset();

  write_register(SCI_VOL,0xffff); // Volume
  write_register(SCI_AUDATA,10);    /* Declick: Slow sample rate for slow analog part startup */ // 10 Hz

  delay(100);
......
  modeSwitch(); //Change mode from MIDI to MP3 decoding (Vassilis Serasidis).
  setVolume(0x20);   //Set the volume to the maximux.

//--------End of SPI  setting ---.
//--------Wifi connecting------------------//
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);    Serial.print(".");
  }
  Serial.println("");  Serial.println("WiFi connected");  Serial.println("IP address: ");  Serial.println(WiFi.localIP());
 
}   // End of Setup()

void loop() {
    if(Serial.available()){
       int temp = Serial.parseInt();
      if(temp == 1) {
         Serial.println("Input 1");
         playWebRadioStation(station1_IP, station1_Port, "01");
      } else if(temp == 2) { 
         Serial.println("Input 2");
         playWebRadioStation(station2_IP, station2_Port, "02");     
      } else if(temp == 3) {
         Serial.println("Input 3");
         playWebRadioStation(station3_IP, station3_Port, "03");           
      }
    }
}   // End of loop()

//=====================================================================================================
void playWebRadioStation ( const char* host, const int hisPort, char* preset )
{
  Serial.print("\n\n<"); //Print the station info to the serial port
  Serial.print(host); Serial.print(hisPort);
  Serial.println(preset);
  Serial.println("> ============================================================");

  stopSong();
  ViewStationInfo = false;
  indexCounter = 0;

  WiFiClient client;

  if (!client.connect(host, hisPort)) {
    Serial.println("Connection failed");
  }
  else {
    client.print(String("GET ") + "/" + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
    Serial.println(String("GET ") + "/" + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");

    delay(10);

   while(client.available()){
        client.readBytes(VS1053DATA, BUFFER_LENGTH);
       while ( !digitalRead(dreq_pin) );
       playChunk(VS1053DATA,BUFFER_LENGTH);
  }
      delay(1);
}


Hi @redflag2k

Can you please share full code?
User avatar
By danbicks
#32458 Hi Roman,

Did you manage to find a solution to the loss of playing after 53secs?

This would be so brilliant and seems such a shame that this thread is not moving. I have asked several questions here and not had a response. Seems like now a dead thread, real shame this would be awesome to have as a webradio device.

I think some of the guru's here should pick this up and roll with it. The vs1053 module looks great as a solution to reproduce audio from I2S let's hope someone picks this up and makes some positive progress.

Fingers crossed.

Dans