Trouble with Feather M0 + WINC1500 using VS1053 for internet

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jenkutler
 
Posts: 4
Joined: Wed Jul 07, 2021 6:14 pm

Trouble with Feather M0 + WINC1500 using VS1053 for internet

Post by jenkutler »

Hi.
I am hoping that someone might be able to help me with a problem I'm having.
I've been trying to adapt the Adafruit Internet Radio Tutorial:
https://learn.adafruit.com/adabox004/internet-radio
to work with the M0 WINC1500 that I have. The sketch has a note that says it was tested with an M0 WINC1500 but it doesn't seem to want to work with mine. I changed a few things to try to make it work like changing the <ESP8266WiFi.h> to <WiFi101.h>, added the USBSerial definitions recommended for SAMD21 based boards and in the setup, I declared the appropriate pins for the wireless module onboard. For some reason, it gets hung during the setup during this line of code: " musicPlayer.sineTest(0x44, 500); // Make a tone to indicate VS1053 is working" which originally lead me to believe that perhaps there was an issue with the DREQ interrupt pin conflicting with one of the SPI pins but I changed the DREQ pin to one that shouldn't conflict with anything and the M0 still locks up in the same place.

Does anyone have any ideas? Any help would be greatly appreciated.

User avatar
Franklin97355
 
Posts: 23938
Joined: Mon Apr 21, 2008 2:33 pm

Re: Trouble with Feather M0 + WINC1500 using VS1053 for inte

Post by Franklin97355 »

Can you post your modified code and your connections?

User avatar
jenkutler
 
Posts: 4
Joined: Wed Jul 07, 2021 6:14 pm

Re: Trouble with Feather M0 + WINC1500 using VS1053 for inte

Post by jenkutler »

Thanks for your reply. Sure.

Here is the code:

Code: Select all

// Tested: ESP8266, ESP32, M0+WINC1500

// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <WiFi101.h>


char* ssid     = "ssid";
const char* password = "pass";

//  http://ice1.somafm.com/u80s-128-mp3
const char *host = "audio.wavefarm.org";
const char *path = "/weatherwarlock.mp3";
//const char *path = "/doomed-128-mp3";
int httpPort = 8000;

// These are the pins used
#define VS1053_RESET   -1     // VS1053 reset pin (not used!)
#define VS1053_CS      16     // VS1053 chip select pin (output)
#define VS1053_DCS     15     // VS1053 Data/command select pin (output)
#define VS1053_DREQ    17     // VS1053 Data request, ideally an Interrupt pin

#define VOLUME_KNOB    A0
#define ON_OFF_SWITCH  4

int lastvol = 30;

Adafruit_VS1053 musicPlayer =  Adafruit_VS1053(VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ);

// Use WiFiClient class to create HTTP/TCP connection
WiFiClient client;

#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
  // Required for Serial on Zero based boards
  #define Serial SERIAL_PORT_USBVIRTUAL
#endif
  
void setup() {
  while (!Serial) { 
    delay(1); 
  }
  Serial.begin(9600);

//WiFi Module Pin Declaration
  
 // WiFi.setPins(8,7,4,2);
  Serial.println("\n\nAdafruit VS1053 Feather WiFi Radio");

  /************************* INITIALIZE MP3 WING */
  if (! musicPlayer.begin()) { // initialise the music player
     Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
     while (1) delay(10);
  }

  Serial.println(F("VS1053 found"));
  musicPlayer.sineTest(0x44, 500);    // Make a tone to indicate VS1053 is working
  
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(lastvol, lastvol);

  // don't use an IRQ, we'll hand-feed

  pinMode(ON_OFF_SWITCH, INPUT_PULLUP);
  /************************* INITIALIZE WIFI */
  Serial.print("Connecting to SSID "); Serial.println(ssid);
  WiFi.begin(ssid, password);
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
 
  Serial.println("WiFi connected");  
  Serial.println("IP address: ");  Serial.println(WiFi.localIP());


  /************************* INITIALIZE STREAM */
  Serial.print("connecting to ");  Serial.println(host);
  
  if (!client.connect(host, httpPort)) {
    Serial.println("Connection failed");
    return;
  }
  
  // We now create a URI for the request
  Serial.print("Requesting URL: ");
  Serial.println(path);
  
  // This will send the request to the server
  client.print(String("GET ") + path + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" + 
               "Connection: close\r\n\r\n");

}

// our little buffer of mp3 data
uint8_t mp3buff[32];   // vs1053 likes 32 bytes at a time

int loopcounter = 0;

void loop() {
 /* if (! digitalRead(ON_OFF_SWITCH)) {
    yield();
    return;
  }*/
  
  loopcounter++;

  // wait till mp3 wants more data
  if (musicPlayer.readyForData()) {
    //Serial.print("ready ");
    
    //wants more data! check we have something available from the stream
    if (client.available() > 0) {
      //Serial.print("set ");
      // yea! read up to 32 bytes
      uint8_t bytesread = client.read(mp3buff, 32);
      // push to mp3
      musicPlayer.playData(mp3buff, bytesread);

      //Serial.println("stream!");
    }
  } else {
    if (loopcounter >= 1000) {
      loopcounter = 0;
      // adjust volume!
      int vol = 0;
      vol = analogRead(VOLUME_KNOB);
      vol /= 10;
      if (abs(vol - lastvol) > 3) {
        Serial.println(vol);
        lastvol = vol;
        musicPlayer.setVolume(lastvol, lastvol);
      }
    }
  }
}
The connections I have at the moment (aside from power) are MP3-DREQ to A3/17, MP3-CS to A2/16 and MP3-DCS to A1/15.
Thank you!

User avatar
jenkutler
 
Posts: 4
Joined: Wed Jul 07, 2021 6:14 pm

Re: Trouble with Feather M0 + WINC1500 using VS1053 for inte

Post by jenkutler »

And obviously MOSI to the MOSI pin, MISO to the MISO pin and SCK to the SCK pin for the SPI connections.

User avatar
rafikii
 
Posts: 69
Joined: Sat Jan 30, 2021 1:18 pm

Re: Trouble with Feather M0 + WINC1500 using VS1053 for inte

Post by rafikii »

I am having a similar issue. I can get a tone to play and read the names of SD card files. However, it doesn't play files, Sometimes it locks up when playing a tone.

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”