0
votes

I have a parallax RFID reader and I am confused on where to start when using johnny-five with it. I am trying to use this as guidance - http://www.gumbolabs.org/2009/10/17/parallax-rfid-reader-arduino/ - but obviously that does not use johnny-five.

I don't know if I should be starting with a johnny-five object to read the data and interact with the sensor, or if I should skip that and be using serialport directly. If I use serialport how exactly do I do that?

https://github.com/RyanHirsch/j5-rfid

Output:

1381834286406 Board Connecting... 
1381834286421 Serial Found possible serial port /dev/cu.usbmodemfa141
1381834286422 Board -> Serialport connected /dev/cu.usbmodemfa141
open
err undefined
results 3

Code:

var sp = new SerialPort("/dev/cu.usbmodemfa141", {
  parser: serialport.parsers.readline("\r") ,
  baudrate: 2400
}, false);

sp.open(function () {
  console.log('open');
  sp.on('data', function(data) {
    console.log('data received: ' + data);
  });
  sp.write("ls\n", function(err, results) {
    console.log('err ' + err);
    console.log('results ' + results);
  });
});
2

2 Answers

3
votes

Johnny five is Node.js for robots but on your computer. The javascript code is executed on your computer. On the Arduino, you need to upload StandarFirmata as explained on their github page.

The code from the Arduino <--> RFID tutorial you gave us if for Arduino only. If you want to use it with johnny five, you need to implement the code by your self or look for someone who did that for you on github. If you're having this problem, chances are someone else also had it and might have found an answer.

With node serialport, you'll be able to read the Serial.print() outputs of the Arduino. You can output json and parse it with javascript on your computer using serialport.

Hope it helps !

If you need more help, feel free to ask! :)

EDIT 1:

So if I understand it correctly: you have the RFID reader connected to the Arduino. The Arduino is connected to a computer. You want to read the RFID and send the information to the computer. The computer must be running a server and must be able to get the data from the USB port. All people connected to the server from the iPad should see the information in realtime. Is that correct?

If so, you need a node server, node-serialport to get the data from the USB and a web app such as express.js to show the data to your clients. The best way to do that would be to format your data as json so that it could be easily parsable on the server.

EDIT 2: Okay! So here you can find two great tutorials by Tom Igoe on how to use Arduino and Node.js.

  • Arduino Serial to Browser: Here you'll learn the basics of node-serialportand how to use it with your Arduino.
  • Serial to Browser using node.js : Here you'll learn how to JSONize your Arduino data so that they can be easily accessible through your web app and websocket. He uses an accelerometer for his data, but I guess you can directly use your RFID data.

I'm sure that you'll have many more questions after this but it will be a good start!

Hope it helps! :)

2
votes

The Firmata protocol (that which Johnny-Five uses to communicate with an Arduino) does not support SoftwareSerial or relinquishing the RX/TX lines of the board. That means that Johnny-Five cannot support this device.

Edit: Firmata protocol recently added support for hardware and software serial, which means RFID component support will likely soon be added