Dear Adafruit,
We want to design a custom board using the following parts from Adafruit for an application that will connect Arduino Mega ADK to an Android system. If prototyping is successful, we will order more parts from you.
1. Arduino Board: ATmega2560 ADK R3: $76.46
https://www.adafruit.com/products/563
2. Thermal Printer Pack : $61.95
https://www.adafruit.com/products/600
3. RFID/NFC Shield: $39.95
http://www.adafruit.com/products/364
4. Fingerprint sensor: $74.95
https://www.adafruit.com/products/751
5. Bluetooth Shield
(You don't seem to carry a bluetooth shield, so we will use a simple one from Seeedstudio: http://www.seeedstudio.com/wiki/index.p ... oth_Shield)
We have the following questions:
1. First, do you foresee any compatiblity issues in the hardware - Arduino Mega ADK with the peripherals? If so, please suggest alternatives.
2. Does the Arduino Mega ADK come with the A-type and B-type USB connectors for connecting to PC and Android device?
3. Regarding the NFC shield, does the break-out board (https://www.adafruit.com/products/364) support Arduino Mega R3. Also, apart from being a shield, what are the differences between this rev 1.3 and the shield (https://www.adafruit.com/products/789) rev 1.0?
Thanks,
Alfatek
Arduino Mega ADK with peripherals.
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88037
- Joined: Sat Feb 07, 2009 10:11 am
Re: Arduino Mega ADK with peripherals.
There should be no compatibility issues with that hardware. Keep in mind that the RFID/NFC breakout is a 3.3v device and needs level shifting (chip included) to talk to the Arduino ADK. The shield version (#789) is 5v friendly and can plug directly into the Arduino - including R3 models.
The ADK has both A & B connectors and functions as a USB host. Full specs for this board can be found here: http://www.arduino.cc/en/Main/ArduinoBoardADK
The ADK has both A & B connectors and functions as a USB host. Full specs for this board can be found here: http://www.arduino.cc/en/Main/ArduinoBoardADK
-
- Posts: 10
- Joined: Tue Nov 13, 2012 9:05 am
Re: Arduino Mega ADK with peripherals.
Hi,
We are now trying to integrate the NFC shield with the Android ADK.. Both the ADK and shield are fine. I was able to load the basic sketches and read ids, etc..
Now, I am trying to make a sketch that can read the Mifare cards and send the id to the ADK and then to the Android device. I am using the following code:
The logic works like this.. Use the adb event handler when it gets a response from the Android device, initialize the NFC shield, read the id, and store in EEPROM.. To send the data to the Android device, basically read the last ID stored in the EEPROM and send it to the Android device.. The code is all good - but with one problem - after the RFID tag is read (the board detects the PN532 and reads the card id), it seems to hang - i have to do a reset to make it work. Please help on how to make it work without reset..
Thx.
We are now trying to integrate the NFC shield with the Android ADK.. Both the ADK and shield are fine. I was able to load the basic sketches and read ids, etc..
Now, I am trying to make a sketch that can read the Mifare cards and send the id to the ADK and then to the Android device. I am using the following code:
Code: Select all
#include <SPI.h>
#include <Adb.h>
#include <max3421e.h>
#include <PN532.h>
#include <EEPROM.h>
#define PN532_CS 10
//CS of NFC is pin 10
PN532 nfc(PN532_CS);
// Adb connection.
Connection * connection;
// Elapsed time for ID sampling.
long lastTime;
// ID of the MiFare Card
uint32_t id;
uint8_t idbk[5];
// Event handler for the shell connection.
void adbEventHandler(Connection * connection, adb_eventType event, uint16_t length, uint8_t * data)
{
// Data packet contains one byte from Android to determine when to start reading NFC
if (event == ADB_CONNECTION_RECEIVE)
{
{
digitalWrite(6, HIGH);
// ADB::closeAll();
//NFC Begins
{
// look for MiFare type cards
nfc.begin();
//Read the NFC Shield version
uint32_t versiondata = nfc.getFirmwareVersion();
//Warning for non-compatible NFC shields
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);
Serial.print("Supports ");
Serial.println(versiondata & 0xFF, HEX);
// configure board to read RFID tags and cards
nfc.SAMConfig();
id =0;
while (id==0)
{
id = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A);
if (id != 0) {
Serial.println();
Serial.print("Read card #");
Serial.println(id);
}
}
// nfc.end();
// Store the NFC ID read to the EEPROM
EEPROM.write(10,id>>24);
EEPROM.write(11,id>>16);
EEPROM.write(12,id>>8);
EEPROM.write(13,id);
}
digitalWrite(6, LOW); // Change the state of LED to indicate NFC ready to read
delay(500);
digitalWrite(6,HIGH);
}
}
}
void setup()
{
//NFC Read Next Init
pinMode(12, OUTPUT);
digitalWrite(12, LOW);
//Read the ID stored from EEPROM
id = ((uint32_t) EEPROM.read(10)<<24) | ((uint32_t) EEPROM.read(11)<<16) | ((uint32_t) EEPROM.read(12)<<8)|((uint32_t) EEPROM.read(13));
//Serial port debug purpose
Serial.begin(19200);
// Set Digital pin 6 (LED is connected) as output to indicate that NFC ready to be read.
pinMode(6,OUTPUT);
digitalWrite(6,LOW);
// Note start time
lastTime = millis();
// Initialise the ADB subsystem.
ADB::init();
// Open an ADB stream to the phone's shell. Auto-reconnect. Use any unused port number eg:4568
connection = ADB::addConnection("tcp:4568", true, adbEventHandler);
}
void loop()
{
uint32_t lgval=(uint32_t)10000000000.0;
//Display the last ID read
if ((millis() - lastTime) > 1000)
{
Serial.print("Last ID Read: ");
Serial.println(id);
idbk[0]=id%100;
idbk[1]=(id%10000)/100;
idbk[2]=(id%1000000)/10000;
idbk[3]=(id%100000000)/1000000;
idbk[4]=(id%lgval)/100000000;
/*
Serial.println(idbk[0]);
Serial.println(idbk[1]);
Serial.println(idbk[2]);
Serial.println(idbk[3]);
Serial.println(idbk[4]);
*/
//Write the ID to Android
connection->write(5,(uint8_t*)&idbk);
lastTime = millis();
}
// Poll the ADB subsystem.
ADB::poll();
}
Thx.
- adafruit_support_bill
- Posts: 88037
- Joined: Sat Feb 07, 2009 10:11 am
Re: Arduino Mega ADK with peripherals.
Is it pulsing the led when it detects the card?
I'm not familiar with the adb event system. Are there any restrictions on what can be done in an event handler? Any interrupts to re-arm etc?
I'm not familiar with the adb event system. Are there any restrictions on what can be done in an event handler? Any interrupts to re-arm etc?
-
- Posts: 10
- Joined: Tue Nov 13, 2012 9:05 am
Re: Arduino Mega ADK with peripherals.
Yes, the LED blinks fine and the id is recorded as well. It is just that after this, the micro-controller hangs..I think when we initialize the SPI specs for the PN532, it messes up the communications between the USB and the android device.. Any clues on how to restore the SPI specs back up?
Thanks.
Thanks.
- adafruit_support_bill
- Posts: 88037
- Joined: Sat Feb 07, 2009 10:11 am
Re: Arduino Mega ADK with peripherals.
The shield can talk i2c as well. Can you use that?I think when we initialize the SPI specs for the PN532, it messes up the communications between the USB and the android device.
Please be positive and constructive with your questions and comments.