Hi all,
I'm very new to arduino, so please excuse any silly comments or mistakes below!
I'm trying to use an arduino uno as a datalogger - I want it to read serial data coming from a Texas Instruments RFID reader and log it to a file.
I have an arduino uno, with a sparkfun microSD shield (SparkFun microSD Shield - DEV-12761 - SparkFun Electronics), and am using a sparkfun max3232 breakout (SparkFun Transceiver Breakout - MAX3232 - BOB-11189 - SparkFun Electronics)
I'm connecting the max3232 breakout to the RX and TX pins, and initially am looking at using SerialEvent to do this. Connected to my PC via USB (with the RX and TX pins connecting to the max3232 on the arduino unplugged) and using the arduino serial monitor to send text, it works great and things are logged to the SD card. Connected to my PC via the serial port I've wired to the max3232 also works fine
My code is below
#include <SD.h>
// SPI settings
// MOSI, MISO, SCLK set by default
// CS = ChipSelect
// pow_pin = power for SD card shield
int CS_pin = 8;
int pow_pin = 10;
String inputString = ""; // a string to hold incoming data
boolean stringComplete = false; // whether the string is complete
void setup()
{
Serial.begin(9600);
inputString.reserve(200);
Serial.println("Initializing card");
// CS Pin as output
pinMode(CS_pin, OUTPUT);
// power PIN for SD card
pinMode(pow_pin, OUTPUT);
digitalWrite(pow_pin, HIGH);
// Check if card is ready
if(!SD.begin(CS_pin))
{
Serial.println("Card failed");
return; // return ends the program right here!
}
Serial.println("Card ready");
// open the log file
// if you don't specify FILE_WRITE it will open the file read-only
}
void loop()
{
// print the string when a newline arrives:
if (stringComplete) {
Serial.println(inputString);
File logFile = SD.open("log.txt", FILE_WRITE); // open the log file
logFile.println(inputString);
logFile.close();
// clear the string:
inputString = "";
stringComplete = false;
}
}
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag
// so the main loop can do something about it:
if (inChar == '\n') {
stringComplete = true;
}
}
}
The problem is, when I connect the serial port to the TI RFID reader, I get absolutely nothing!! written to the SD card
Connecting the RFID reader to my PC, and using serial port settings 9600-8-1-N everything works fine. Here is an example of what it spits out
LI
LI
LI
LI
LI
LI
LI
LI
LI
LI
LR 0113 0379091200509523
LR 0113 0379091200509523
LR 0113 0379091200509523
LR 0113 0379091200509523
LR 0113 0379091200509523
LR 0113 0379091200509523
LR 0113 0379091200509523
LR 0113 0379091200509523
LR 0113 0379091200509523
LI just seems to be a default, the LR lines are actual reads of a RFID tag
Can anyone help me out? I'm really not sure what to do from here
Thanks!
Dylan