1


I will be getting my RaspberryPi Zero tomorrow and I wanted to use it in combination with the RFID-RC522 module as some sort of USB-RFID-Tag-Reader.

This works with the RaspberryPi 3 Model B I own (over a network-socket instead of USB), but since the Zero is lacking a LAN / WLAN Interface and I didn't quite find anything useful on a Java Socket equivalent which uses USB or, more specifically, serial communcation with the Zero over its USB port with java, I thought I would ask the question here.

Thanks a bunch,
rocket_doge_

2
  • Do you want to use the Pi Zero as a USB device (connecting it to a "real" computer)? How do you connect the RC522 to the pi?
    – Bex
    Commented Nov 21, 2016 at 15:44
  • @Bex I want to use the RasPi as a USB device on e.g. my Laptop / PC and I connect the RC522 over the GPIO pins / SPI Commented Nov 21, 2016 at 15:45

1 Answer 1

1

This sounds like a very interesting and educating project!

Sadly, what you want to do is probably not as easy as you would like. USB is a complex protocol, and not as high-level as network sockets. Java does not support it very well, and while you could write a minimal custom driver and interface to that through java, it would be easier just scrapping the java part altogether.

Have a look here for how to use Pi Zero as a device: Can the Pi Zero act as an USB peripheral device?

Or add networking to your pi zero: What's the cheapest way to get network connectivity to the Pi Zero?

If you want to make a "device" out of the pi, you want to make what in linux-lingo is called a "gadget driver". (The device driver is on the host machine, talking to the device. The gadget driver is the sw on the device that the device driver talks to.)

To write a gadget driver, start out at http://www.linux-usb.org/gadget/. It seems ADA Fruit has a tutorial about how to make a serial or an ethernet gadget: https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/overview

You would want to go on, to create a custom type of gadget, with a custom device driver, that loads when your gadget is detected. From there, you could do an interrupt type USB-channel, that tells the host system when there has been an event on the gadget.

So, on the pi zero, you would build a gadget driver, and on the host you would make a device driver.

If you want to go ahead with this, you should have a look at the horse book.

6
  • 1
    If it is connected as an ethernet device (which is probably the most useful way to go), then it will have an IP address and you can connect to it using a normal network socket, etc.
    – goldilocks
    Commented Nov 21, 2016 at 16:11
  • Thank you very much ^.^ I initially thought about putting the thing into my laptop so I could login and secure passwords with an RFID tag (theres some space in the case left) but I guess I will have to scrap that idea. Just out of interest; what would I need for the custom driver / interface part? Commented Nov 21, 2016 at 16:17
  • "what would I need for the custom driver / interface part" -> A few textbooks for starters (such as LDD3), and it is a C only realm...
    – goldilocks
    Commented Nov 21, 2016 at 17:01
  • @goldilocks LDD3 == "the horse book". ;)
    – Bex
    Commented Nov 22, 2016 at 6:35
  • 1
    Oh I thought you meant this. ;] Actually I had not heard it called the horse book before but I have a paper copy and I think I understand why. I have a paper copy of the dragon book too but there is no dragon on it :(
    – goldilocks
    Commented Nov 22, 2016 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.