Now in order to convert the USB to standard serial for the Arduino I bought something like this:
From this I ran wiring from the following colors to the following pins:
black -> arduino ground
red -> arduino 5v
white -> 3.3k resistor (for pull up)-> arduino pin 3
green -> 3.3k resistor (for pull up)-> arduino pin 2
basically I roughly followed this guide, including the source code: http://playground.arduino.cc/ComponentLib/BarcodeScanner#.UySMGfldWf1
Now from the serial console I get nothing. When I simply read from the port with no filtering I get stricly 1's or stricly 0's. I cannot seem to get any useful info out of it?
Can anyone comment on the code that I'm using (from the above site) or my arduino connection to the barcode scanner that could possibly help me out?
Now in order to convert the USB to standard serial for the Arduino I bought something like this:
That is not a USB to SERIAL converter.
A USB to serial converter is an FTDI BREAKOUT
I think you may have a misunderstanding about the arduino serial and USB. USB is differential . It may be serial but it is not TTL-SERIAL, so just plugging the USB signal into the arduino is not going to work. The arduino UNO has an FTDI USB-to-serial converter on board in a chip.(whereas the Pro-Mini does not, which is why I have to use an FTDI BASIC to talk to my Pro-Mini.
Thank you for educating me on this. I had thought that simply connecting the digital pins would produce a signal I could use. So your saying with this FTDI board I should be able to read output from the bar code scanner?
I guess I always thought that usb was similar to ps2 and ps2 seems pretty straight forward for manually hooking up to arduino pins.
Is there another more straight forward way to read USB devices on arduino?
I'm saying that if the vendors website states that the interface is USB, then you need a USB to (TTL) Serial converter (like the FTDI BASIC from SPARKFUN). You could also use a simple USB-to RS232 cable (like from RADIOSHACK) connected to an RS232-to-TTL SERIAL converter (like the one I linked) but that is really the long way around . The FTDI-BASIC would be a simpler solution.
Is there another more straight forward way to read USB devices on arduino?
As I stated earlier, (I think), the Arduino UNO has a USB -to-Serial converter chip, which allows you to load the programs from your PC. It looks like the scanner is designed to mimic a keyboard behaviour and keyboards are interpreted by keyboard drivers that are
loaded on a PC. Since the Arduino is not a PC , it doesn't have these drivers and that's what that example code is supposed to mimic.
raschemmel:
I'm saying that if the vendors website states that the interface is USB, then you need a USB to (TTL) Serial converter (like the FTDI BASIC from SPARKFUN).
That assumes that the barcode reader presents a serial device. Perhaps it does - I don't know - but just because it uses USB doesn't mean it presents a serial port. Also, the FTDI type converters are USB slave devices as far as I understand it - I don't know whether they would also work as USB hosts, but I doubt it.
There is an Arduino USB host shield (and some Arduinos have USB host ports as standard) but you would need to find/write a USB driver for your device. If it's just a serial device, that might not be too hard. For anything else, unless you have experience of writing USB device drivers, for practical purposes a device with a USB port is something that you need to plug into a PC running an operating system that is supported by a device driver compatible with that device.
If you're into hacking the device open, you could try to locate the connection between the USB port and the rest of the device and see whether you can locate an interface using a type of signal that you can read. It would take quite a lot of electronic skill and knowledge to do, though.
If you're into hacking the device open, you could try to locate the connection between the USB port and the rest of the device and see whether you can locate an interface using a type of signal that you can read. It would take quite a lot of electronic skill and knowledge to do, though.
Considering that the OP is (presumably) not a technician but has taken it upon himself to hack into a consumer product, I think he might be able to find the output of the USB circuit (the TTL serial connection) but doing that without a schematic would depend on whether or not he can trace the signal to a chip we can look up and verify that the pin the signal is connected to is a TTL compatible pin based on the datasheet. IF he could trace the signal from the output of the USB circuit (which in our case is the side connected to the SCANNER circuitry rather than the side connected to the outside world) to some chip we can research, then it might be possible. Personally, even I would hesitate to attempt that without a schematic, but I would not say it is not doable, but rather that it will require a lot of perseverance and note taking, or circuit drawing and/or photos. It seems like a lot of work. I would be more inclined to try to find an arduino compatible bar-code scanner. Maybe the whole idea of hardware hacking it is the wrong approach. Maybe the software approach is better: https://www.circuitsathome.com/mcu/connecting-barcode-scanner-arduino-usb-host-shield
I think you guys are right. This is not feasible to do manually. I'm sure I could get some output from the Arduino USB host shield but thats another ~$20 on top of Arduino cost. I'm not sure why one would need to write a device driver for the usb host shield. I thought the shield through puts the data via Arduino gpio? I would presumably need to take this data and parse it?
There is always the option of making my own Arduino bar code scanner by using photoresister and led light etc but I would have to rewrite the wheel and parse many commonly known bar code styles. This would be a project on it's own.
I could always opt for a micro controller with built in usb host such as beagle bone or raspberry pi.
There just seems to be no clean way to read usb signal from external device to Arduino.
As I pointed out, the arduino UNO has a USB to serial converter but lacks the keyboard driver. Also , yours is a PS/2 scanner, which is the round keyboard/mouse connector, not USB. (at least not in the sense of having a USB connector on it, right ?) So my last post was a link to a guy who had a scanner that already has a USB connector on it so he plugged it into the arduino and wrote the code to mimic a keyboard USB driver so the scanner would not know the difference.
So the bar code scanner that I bought from amazon is USB and NOT ps/2.
The Arduino Uno does indeed already have on on board FTDI USB breakout(USB to serial) which is the main power/serial source. I need to keep this as power/serial to ease development; so I cannot use this for the scanner. I looked into pins tx/rx which are strictly serial and it seems they tie into the main serial stream of the board and causes all kinds of odd behavior.
The link for the USB scanner to Arduino uses the USB shield which is in itself about 20 dollars. I would prefer not having a shield because of space/money.
I wonder if it would be easier to get a USB to RS232 converter and maybe from there I can connect to the Arduino Uno board?
I read the Q/A on Amazon.
The device is USB & enumerates as a HID keyboard ... So, to use with Arduino you will need USB host mode.
There us no other option, IMO.
You could use with the RasberryPi, however.