Best regards
Fernando
Explore... Chat... Share...
Moderator: igrr
#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);
}
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]