Wave Shield and RFID Shield - I followed the Babel Fish Tuto

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
TheodoreNaiv
 
Posts: 7
Joined: Thu Feb 06, 2014 1:44 pm

Wave Shield and RFID Shield - I followed the Babel Fish Tuto

Post by TheodoreNaiv »

Hi!

I wanna do a similar project like "The Babel Fish". I bought the AUDIO Shield and RFID Shield. I setted up first the RFID Shield (I cuttet the connection between the IRQ and the header pin and solder a wire from irq pin and the digital pin 6, if You said in this tutorial --> http://learn.adafruit.com/babel-fish/ma ... fid-shield), then I followed step by step the tutorial (learn.adafruit.com/babel-fish/) and it works, i can play an audio file when the RIFD shield read a mifare card. The problem is that the RFID shield can check only one card (the first attempt), after that, when i try another card (or already the same), it doesn't work anymore, I must every time (after the first attempt) restart manually the shields (with the reset button present on the audio shield), and then the RFID shield is already able to check another Card and play the sound.

I tried both the shields standalone (not connected each other, i tried both Shields with the basic Examples present in the Library, dahpc for the Wave Shield, readMifare for the RFID Shield). They works perfectly, with the Wave Shield I can play without problem sounds present in the SD Card and with The RFID Shield works perfectly too if is standalone (without the audio shield), it reads the cards without need to restart the shield.

I just wanna ask how can I check 2 or more times the cards without restart every time the shields after the first attempt?

Normally, if I follow step by step the tutorial, it should play every time a card, without restart the shields?

I used this code ---> http://learn.adafruit.com/babel-fish/programming. I just only change the cardidentifier number and the wave file name to play, the rest is the same.

Thanks in advance

Ivan

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Wave Shield and RFID Shield - I followed the Babel Fish

Post by adafruit_support_mike »

Could you post your code and a photo of your hardware please? That will help us see exactly what's going on.

The forum has a limit on file sizes, but 800x600 images usually let us see details well.

TheodoreNaiv
 
Posts: 7
Joined: Thu Feb 06, 2014 1:44 pm

Re: Wave Shield and RFID Shield - I followed the Babel Fish

Post by TheodoreNaiv »

Hi!

Thank you for you reply!

Here is my Code:

Code: Select all

#include <WaveHC.h>
#include <WaveUtil.h>
#include <Wire.h>
#include <Adafruit_NFCShield_I2C.h>


#define IRQ 6 // this trace must be cut and rewired!
#define RESET 8

Adafruit_NFCShield_I2C nfc(IRQ, RESET);

SdReader card; // This object holds the information for the card
FatVolume vol; // This holds the information for the partition on the card
FatReader root; // This holds the information for the volumes root directory
FatReader file; // This object represent the WAV file for a pi digit or period
WaveHC wave; // This is the only wave (audio) object, since we will only play one at a time
/*
* Define macro to put error messages in flash memory
*/
#define error(msg) error_P(PSTR(msg))

//////////////////////////////////// SETUP

void setup() {
  // set up Serial library at 9600 bps
  Serial.begin(9600);
  
  PgmPrintln("Pi speaker");
  
  if (!card.init()) {
    error("Card init. failed!");
  }
  if (!vol.init(card)) {
    error("No partition!");
  }
  if (!root.openRoot(vol)) {
    error("Couldn't open dir");
  }

  PgmPrintln("Files found:");
  root.ls();
  
  // find Adafruit RFID/NFC shield
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }
  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
  
  // configure board to read RFID tags
  nfc.SAMConfig();

}

/////////////////////////////////// LOOP

unsigned digit = 0;

void loop() {
  uint8_t success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
  uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

  // wait for RFID card to show up!
  Serial.println("Waiting for an ISO14443A Card ...");

    
  // Wait for an ISO14443A type cards (Mifare, etc.). When one is found
  // 'uid' will be populated with the UID, and uidLength will indicate
  // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);

  uint32_t cardidentifier = 0;
  
  if (success) {
    // Found a card!

    Serial.print("Card detected #");
    // turn the four byte UID of a mifare classic into a single variable #
    cardidentifier = uid[3];
    cardidentifier <<= 8; cardidentifier |= uid[2];
    cardidentifier <<= 8; cardidentifier |= uid[1];
    cardidentifier <<= 8; cardidentifier |= uid[0];
    Serial.println(cardidentifier);

  // repeat this for loop as many times as you have RFID cards
    if (cardidentifier == 4153873581) { // this is the card's unique identifier
      playcomplete("oca.WAV"); // these are file names for the sample audio files - change them to your own file names
      delay(1000);  
  }
  
    if (cardidentifier == 2786539018) {
      playcomplete("pollo.WAV");
      delay(1000);
    }
  }
}

/////////////////////////////////// HELPERS

/*
* print error message and halt
*/
void error_P(const char *str) {
  PgmPrint("Error: ");
  SerialPrint_P(str);
  sdErrorCheck();
  while(1);
}
/*
* print error message and halt if SD I/O error
*/
void sdErrorCheck(void) {
  if (!card.errorCode()) return;
  PgmPrint("\r\nSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  PgmPrint(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}
/*
* Play a file and wait for it to complete
*/
void playcomplete(char *name) {
  playfile(name);
  while (wave.isplaying);
  
  // see if an error occurred while playing
  sdErrorCheck();
}
/*
* Open and start playing a WAV file
*/
void playfile(char *name) {
  if (wave.isplaying) {// already playing something, so stop it!
    wave.stop(); // stop it
  }
  if (!file.open(root, name)) {
    PgmPrint("Couldn't open file ");
    Serial.print(name);
    return;
  }
  if (!wave.create(file)) {
    PgmPrintln("Not a valid WAV");
    return;
  }
  // ok time to play!
  wave.play();
}
I post the pics of my hardware, I use an Arduino UNO for this project.

Hope this Help!

Ivan
Attachments
Here is my RFID Shield. I cutted the connection between the IRQ pin and pin header, then i connected with a wire the IRQ with the pin 6.
Here is my RFID Shield. I cutted the connection between the IRQ pin and pin header, then i connected with a wire the IRQ with the pin 6.
Foto 2.JPG (149.44 KiB) Viewed 521 times
Here you can see my wave shield.
Here you can see my wave shield.
Foto 1.JPG (138.13 KiB) Viewed 521 times
This is the final Setup. I use an Arduino Uno.
This is the final Setup. I use an Arduino Uno.
Foto 4.JPG (129.71 KiB) Viewed 521 times

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Wave Shield and RFID Shield - I followed the Babel Fish

Post by adafruit_support_mike »

I see you've rerouted some of the signals to different pins. Have you cut the traces that go to the original pins for those signals?

TheodoreNaiv
 
Posts: 7
Joined: Thu Feb 06, 2014 1:44 pm

Re: Wave Shield and RFID Shield - I followed the Babel Fish

Post by TheodoreNaiv »

Do you speak about the Wave Shield? I followed the solder tutorial here --> http://learn.adafruit.com/adafruit-wave ... ino/solder

As You described in the tutorial, i have rerouted the signals in these pins:

Pin 2 -> LCS
Pin 3 -> CLK
Pin 4 -> DI
Pin 5 -> LAT
Pin 10 -> CCS

But I haven't cut anything on the wave shield, i cutted only the connection between the IRQ and the pin headers on the RFID Shield... Should I cut the traces even in the wave shield?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Wave Shield and RFID Shield - I followed the Babel Fish

Post by adafruit_support_mike »

That was my mistake.. I'd forgotten that the Wave Shield requires jumpers.

It looks like you've exchanged the 10k and 100k resistors. The one with the yellow band needs to be between the SD card holder and IC3, while the one with the orange band needs to be between IC2 and IC4:
cermplace.jpg
cermplace.jpg (138.48 KiB) Viewed 492 times
Try swapping those and see if that solves the problem.

TheodoreNaiv
 
Posts: 7
Joined: Thu Feb 06, 2014 1:44 pm

Re: Wave Shield and RFID Shield - I followed the Babel Fish

Post by TheodoreNaiv »

Hi,

Yes I changed the place of the resistor, now are both in the right place but it doesn't solve the problem. Maybe is the ICSP header (near the reset button) the problem? It's maybe broken or maybe I solded it in the wrong way?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Wave Shield and RFID Shield - I followed the Babel Fish

Post by adafruit_support_mike »

Your ICSP header shouldn't be connected to anything, so that isn't likely to be the problem. In fact, with that small change in the resistors, the hardware looks pretty good.

Let's see if there's a problem with the data. Change the 'playcomplete()' function to look like this:

Code: Select all

void playcomplete(char *name) {
Serial.print("entering playcomplete() with ");
Serial.println( name );
  playfile(name);
Serial.println("called playfile()");
  while (wave.isplaying);
Serial.println("finished playing");
  // see if an error occurred while playing
  sdErrorCheck();
Serial.println("leaving playcomplete()");
}
That will tell us whether the Arduino is hanging before, during, or after playing the sound.

TheodoreNaiv
 
Posts: 7
Joined: Thu Feb 06, 2014 1:44 pm

Re: Wave Shield and RFID Shield - I followed the Babel Fish

Post by TheodoreNaiv »

I added the code that you sent me. I think all the process are correct called (entering of playcomplete() with the wave file, called playfile, finished playing and leaving the playcomplete function). After that, it comes the Message "Waiting for an IS014443A Card ..." every second in loop and I can't play another card, is it normal? I think the problem is the communication between the pin532 Board and the wave shield, is it possible that i didn't cut properly the connection between the IRQ pin and the pin headers?

here the serial monitor output, You can see what it happens:
Attachments
serial.png
serial.png (199.84 KiB) Viewed 453 times

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Wave Shield and RFID Shield - I followed the Babel Fish

Post by adafruit_support_mike »

Well, it isn't a problem with the code that plays the sounds. Let's see if there's some kind of memory problem.

Add this function to your code:

Code: Select all

int freeRam () 
{
  extern int __heap_start, *__brkval; 
  int v; 
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); 
}
then call it at the beginning of every pass through 'loop()':

Code: Select all

void loop() {
  uint8_t success;
  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
  uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)

  Serial.print("free RAM: ");
  Serial.println( freeRam() );
  // wait for RFID card to show up!
  Serial.println("Waiting for an ISO14443A Card ...");

TheodoreNaiv
 
Posts: 7
Joined: Thu Feb 06, 2014 1:44 pm

Re: Wave Shield and RFID Shield - I followed the Babel Fish

Post by TheodoreNaiv »

Ok, this is the output present in the serial monitor:
Attachments
ram.png
ram.png (46.09 KiB) Viewed 425 times

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: Wave Shield and RFID Shield - I followed the Babel Fish

Post by adafruit_support_mike »

Well, it doesn't look like the Arduino is losing any memory..

I'll have to ask some of the other folks to handle support have any suggestions.

TheodoreNaiv
 
Posts: 7
Joined: Thu Feb 06, 2014 1:44 pm

Re: Wave Shield and RFID Shield - I followed the Babel Fish

Post by TheodoreNaiv »

Ok another thing that it can help you to understand what's the problem: Sometimes When I turn on the arduino It appears in the serial monitor the message "Didn't find PN53x board". I'm sure it's a RFID shield problem by initializing the board. Anyway, i don't know why but it works if I try to read an rfid tag, after that it works anymore (so the main problem). So I tried to copy and paste the part of code present in the void setup() into the the void loop(), after the if loops (the if loops where it checks the rfid id number and play a file audio) to see if the rfid board will find after playing the file audio, well it didn't, it come already the message "Didn't find PN53x board".

The part of the code that i copied and pasted in the void loop() is:

Code: Select all

 PgmPrintln("Pi speaker");
  
  if (!card.init()) {
    error("Card init. failed!");
  }
  if (!vol.init(card)) {
    error("No partition!");
  }
  if (!root.openRoot(vol)) {
    error("Couldn't open dir");
  }

  PgmPrintln("Files found:");
  root.ls();
  
  // find Adafruit RFID/NFC shield
  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }
  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
  
  // configure board to read RFID tags
  nfc.SAMConfig();
I know it's a noobie trick, but I wanted to see what happens with the rfid shield after playing an audio. (if it will find the board after playing an audio file or not).

Also hope this helps.

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

Return to “Arduino Shields from Adafruit”