QR Code reader

Hi!

This is my first post, so I hope I make some level of sense. I'm the proud owner of a brand new Arduino Uno, I've literally just started working my way through the starter kit, played with analogue inputs, digital outs and PWM. I have in the past self-taught some VBA, html and CSS, and the Arduino sketches make sense to me, but that's about the limit of my programming and electronics knowledge.

I'm trying to develop a hand-held device that will dispense a fluid. The rate of fluid dispensation (amongst other things) will change depending on what kind of fluid is loaded in a cartridge. I think the best way to do this is to label my different fluid cartridges with barcodes/QR codes, and have the device detect them when they're loaded. Various downstream parameters can then be set accordingly to dispense the fluid - yes, I will probably be back to ask about controlling actuators later, but for now I'm focussing on this input.

I have scoured the forums looking for advice on QR code reading with the Arduino, but haven't found anything that addresses this issue specifically. I can't use any off-board processing power, my eventual device needs to be handheld and standalone, so using an Android app or whatever to do the work is not suitable. I also appreciate that the processing power of the Arduino Uno isn't sufficient enough to process images and decode QR codes, so I went and found this:
https://www.ebay.com/itm/124538507503

This looks, to me, like it will process the image taken by the QR code and output whatever number or string that QR code describes via the USB or UART. If I can get my Arduino to read this data, I can then use it to decide which program to run - i.e. how fast the actuator moves etc etc

So, my question is... how? How should I hook this board up to my Arduino? Any breadcrumbs on what to start looking at would be infinitely more useful than me sitting here and staring it out until it cracks and tells me itself. Being as I've bought that little board off eBay already, ideal solution would be to use that, but if there's a simpler solution (I've seen elsewhere that some 1D barcode readers output as PS/2, so this might be easier to read?) then I'm all ears.

Thank you, and I hope I haven't said anything embarrassingly stupid or obvious.

1 Like

The seller at the link below has documentation for what appears to be the same product. From the photos of the bottom of the board and the documentation, I gather that it has 3.3 V / 9600 baud serial at the jumper pins which would be the easiest to interface with an Uno. My experience has been with handheld 1D barcode scanners on a PC and they just emulate a USB keyboard and spit out a string of ASCII characters consistent with the barcode.

Under the Arduino IDE "File -> Examples -> Communication -> ReadASCIIString" is an example of how to implement the software.

The device has a USB HID interface (looks like a USB keyboard to a PC) which is how the handheld scanners, I've used work, but an Arduino Uno can't operate as a USB master.

It also has a USB Serial interface (looks like a serial port to a PC) which also is not easily connected to an Uno.

Amazing, thank you - I'm a little embarrassed that I didn't find that data sheet myself, but can't fix that now!

So am I right in saying that the pin on the bottom of the board labelled S-Tx will be the "Serial transmit" pin? So hook this up to an input on the Arduino and use the example file that you recommended to read the ASCII string and I'm good to go?

If I've understood you correctly then I'm ecstatic - that's exactly what I'm looking for!

You should be able to connect the S-Tx pin on the scanner to the Rx pin on the Uno plus a connection for ground and the Uno will see scanner data on the Serial device.

The complication is that the serial pins on the Uno are also used for programming and debugging so you can't do both at the same time.

One approach would be to disconnect the scanner from the Uno Rx pin during programming and reconnect it for test. If there's no scanner connection to the Uno Tx pin, you'll still be able to use Serial.println() from the Uno to the PC Arduino serial terminal, but you won't be able to send serial from the PC to the Uno.

Another approach would be to use SoftwareSerial and a different I/O pin on the Uno to receive data from the scanner. This has its own set of complications, but it should be fine at 9600 baud, and you can update the program and perform Serial read/write to the Uno without disconnecting anything.

Thank you, this all makes sense. I'm waiting on delivery of some components and will repost to this thread when I can to confirm it worked or ask follow up questions, hopefully this will help someone with the same question at some point.

Thank you so much for your speedy and detailed answers, they've really helped move my project along!

1 Like

Instead of QR codes you may want to look into RFID tags and readers. The tags are cheap, passive ones very cheap even. No optics needed to read the labels.

I had considered RFID tags, but I'm not sure they'd have any significant benefit over QR codes and ultimately the fluid-containing cartridges for my device will be disposable, so even if RFID tags are cheap, they're likely still more expensive than printed labels.

If you're aware of benefits of RFID over QR codes (other than the lack of optics required) or could point me in the direction of some resources I'd definitely check it out.

Thank you for your suggestion!

1 Like

No optics, easy reading, smaller size, no need for correct alignment with the reader, possibly easier deployment... I don't know the exact cost of the things, you'll have to do your research on that.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.