I have an RFID reader hooked up to a bluetooth hm-10, but whenever I write the "cardid" it shows up on the recieving end as "0".
Here is my code:
#include <SD.h>
#include <Wire.h>
#include <SoftwareSerial.h>
#include <SPI.h>
#include <Adafruit_PN532.h>
#define PN532_SCK (2)
#define PN532_MOSI (3)
#define PN532_SS (4)
#define PN532_MISO (5)
#define PN532_IRQ (2)
#define PN532_RESET (3)
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
SoftwareSerial mySerial(8,9);
String stringOne = "k";
#if defined(ARDUINO_ARCH_SAMD)
#define Serial SerialUSB
#endif
void setup(void) {
#ifndef ESP8266
while (!Serial);
#endif
Serial.begin(9600);
mySerial.begin(9600);
Serial.begin(9600);
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
while (1);
}
nfc.SAMConfig();
}
void loop(void) {
uint8_t success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };
uint8_t uidLength;
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
if (success) {
if (uidLength == 4)
{
uint32_t cardid = uid[0];
cardid <<= 8;
cardid |= uid[1];
cardid <<= 8;
cardid |= uid[2];
cardid <<= 8;
cardid |= uid[3];
mySerial.write(cardid);
}
Serial.println("");
}
delay(200);
}
I'm relatively inexperienced, so please try to explain it to me as clearly as possible.
Thanks!