Hey Everyone I have an ID-12LA I am trying to get to get to work with my core. What would be the best way to get this to work? I am using this breakout board: https://www.sparkfun.com/products/13030 . I am new to the hardware aspect and could really use some help. Thanks!

Do a search for the reader on the arduino forums and you will find some example code that could be modified to work on the core. you will want to change all the Serial calls (ie. Serial.available() and Serial.read()) to Serial1 to use the TX and RX on the core.

here is a bit of code recycling that may work to display the data from the reader in a terminal window on your computer

void setup()  
  // Open serial communications and wait for port to open:


void loop() // run over and over
  while (Serial1.available())
  while (Serial.available())

Hi @jakeboyles,

This device spits serial dataout, so connect the output pin to the receive (rx,4) pin of the spark.
then write a sketch where you open serial port 1. read the port in the loop function and process the data. useful link [spark doc serial][1].
Datasheet of the device, read it carefully [rfid datasheet][2]

Connect pin 9 to pin 4 of the spark,11 to vin, pin 1, pin 1 to spark gnd, pin 2.
I am pretty sure pin 8 it the correct output, if you get garbage on your screen try 9.

Reading the data can be done by installing the CLI and connecting your core to your pc with the usb cable. Then open e cmd box and type: spark serial monitor.
Make sure you also type Serial.begin(115200) in the setup, and print to that port your output.
AND USE @Hootie81 's code :grinning:
[1]: http://docs.spark.io/firmware/#serial-begin
[2]: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/ID/ID-2LA,%20ID-12LA,%20ID-20LA2013-4-10.pdf

Thanks guys. I have it working and printing out using the cli. I just need to figure out how I can use that in my node.js app. . I would need it to publish on reading of a code. Is that possible?

Well that is certainly possible,
check the tutorials on this site search for publish + node.js. The function that let you publish (duh) stuff in the cloud. read the manual entry spark.publish() to start with.

good luck, and I am interested in your final nodes.js solution, I can use some help there!

Thanks. I know how to use the publish function the problem is converting the serial data into something I can send. I tried to write the serial.read into a string and then use that as a variable but it didnt work. Im guessing that serial.read reads it as an int and needs converted per byte then added to a char array then converted to a string and sent over.

Wait a minute, I dig up some code

This reads the serial input an puts every character in the buffer. Check the datasheet to see what the end of message indicator is, a CR/LF or something like that

int ndx=0;
char buffer[123];

void loop() {
  while (Serial.available()) {
    char chr=(char)Serial.read();  
    if (chr=="END_OF_MESSAGE" || ndx>122){ end of message should be figured out..
       Spark.publish("rfid", buffer, 21600);  //I copied this out the manual...

Maybe this helps.

Only a side note:

Since I can’t see an initialization of buffer, and it’s not always best to rely on auto initialization, I’d add buffer[ndx] = '\0'; just before Serial.println(buffer);.
And don’t check for > 122 but for >= 122!

This way you could even drop the memset().

This code was written to inspire. Not to use directly.
If I would write it as production code the 122 would be replaced with sizeof(). And setup () would initialize et cetera. The memset is necessary because the next message can have a different format, length or content. You never know…
It is good practice to all ways clean your buffers before you use them.

Agreed, and I’m also a big fan of enabling people to solve a problem rather than solve it for them :+1:

And I didn’t intend to criticize, but if @jakeboyles did take that code as is - and I don’t know how his coding and code analyzing skills are - he might run into unexpected results, that might confuse him more than help him, if he didn’t heed the warnings.

And as for the buffer init, there are different ways to ensure a clean buffer - even without wiping it (while wiping is always a save bet ;-)).
Depending on the use (e.g. string), it may even be considered clean when only terminated propperly (combined with careful index handling).

@ScruffR and @marcus, looking at both your great contributions I realize that it may be worth putting a clear disclaimer when anyone contributes a “prototype” solution instead of plug-and-play code. Something like:


I agree with @ScruffR that folks need to solve their own problems. The disclaimer covers @marcus’ contribution while still allowing the user to actually code their own and come back with questions. :smiley:


About buffer init’s I follow the adagium from good old Peter Norton: a routine should always take of it’s own variable states.
And another old school genius, I had a change once to look at the code of Novell Network Server (!), every function started with a memset. and to top it all, I checked the source of string classes, memset is all over the place, in different forms off course.
I took your remark not as criticism, don’t worry :grinning:

1 Like

Maybe a RED background :relaxed:

1 Like

Thanks everyone. I am a web dev so the whole low level stuff is kinda foreign to me. I appreciate the help though!

1 Like