PIN SIGNAL
2 TXD
3 RXD
4 DSR (Supply Voltage in)
5 GND
Anyways, every variation of code I have tried has either given me bizarre characters or numbers that correlate with weird ASCII characters. When I try the reader on PC it outputs like a charm. When I connect it to the arduino and attempt to view its output on the arduino serial monitor I get craziness. I have tried running at other baud rates too. I have searched the web for other variations on code to get it to work like...
It should output
;682107718698421?
It doesn't...
I have tried (among many other things)
/*
Software serial multple serial test
Receives from the hardware serial, sends to software serial.
Receives from software serial, sends to hardware serial.
The circuit:
* RX is digital pin 10 (connect to TX of other device)
* TX is digital pin 11 (connect to RX of other device)
*/
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
Serial.println("Goodnight moon!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}
The RS232 output is not electrically compatible with the Arduino input. It would probably be +/- 12V whereas the Arduino expects 0 to 5V. Also the RS232 signal is inverted.
You need to run it through an adapter or chip like the MAX232 to convert the electrical signal. Don't keep trying, you will damage the input pin. (Measure the output of the gadget with a meter to confirm this).
So... I ordered the part without really thinking this through. I have it now and wired it up how I presumed it worked, but obviously not how it works... I've begin to search for info/advice, but figured you all would be more knowledgeable. The pictures have my set-up. You can probably tell I'm sorta clueless.
The device is port powered and the converter doesn't seem to supply power. I do have a gardener changer and have tried that. I've skimmed the links (going to keep looking at them right now) but haven't figured out what could be the issue yet.
When I instead put the RX and TX pins into the arduino 1 and 0 pins (also tried digital reader in 10 and 11) I get gibberish. I have tried switching the TX and RX around just to be sure also.
I don't fully understand the Arduino's reading capabilities, so it is possible there is a reason right then and there that the PC can read it and the Arduino can't.
Wiring up this adapter with that is my best guess (probably not very good) as to what should happen gives me no results. I occasionally get 0s and the occasional 255, but this only seems to happen when the card reader loses and regains power. When I read with the PC I get letters, symbols, numbers, etc...
I posted pictures of my setup at this point previously. Going to keep trying things...
The cardreader PDF states it uses DSR, fixed HIGH for power.
I think that's supposed to be at least +5.
So, you'll have to run D-sub pin 4 to Arduino +5, PDF says it runs 8mA or something so that should be OK.
How good is the contact between the sparkfun board and the header pins you're like stuffing through them? Dubious.
That should have header pins in it or wires soldered to and patch the jumper-headers into your breadboard or into the Arduino header, what have you.
I agree the connections are dubious at best. The replacement tip for my soldering iron isn't coming until Wednesday so I've had to resort to this. Going to try and make sure the connections are better for the time being though.
Yea. I've gotten the card reader to work completely on the PC serial link by powering it with the Arduino and linking the TX and RX and ground to the PC. I've gotten it to spit (somewhat consistent) gibberish to the Arduino (as viewed by Arduino serial monitor) by putting the RX and TX in the Arduino pins. Now, with the adapter in place I have a connection to the 5v+ to the adapter and the card reader pin 4; ground to the adapter, the card reader, and the adapter 5 pin; the adapter connected to the Arduino TX and RX pins; and the 2 and 3 pins in the device to the 2 and 3 pins in the adapter.
I see that you are trying to receive a byte from the cardreader and then immediately outputting that to Serial Monitor.
I think that you should collect the cardreader's datastream into an array and once it's all in then output that lot to Serial Monitor (but not one by one as it looks like you are.)
I'll try an array. If I want it to output ASCII characters, what should I be saving the data as? Also, it seems as thought the adapter isn't reading the card reader. When I put some current to the adapter's DB-9 receive pin the TX light turns on, but when I instead put it from the card reader's output pin to the adapter's receive pin I get no light or data.