I want to connect a barcode reader to the spark usb and read the barcode using the reader .
Does the Spark core able to do this? i mean use the USB as USB host.
The core cannot be a USB host and have a slave connected, but there is a solution using another small board. The MAX3421 is a USB host controller and the site below (as well as Sparkfun.com) sell a board based on it. The library at this site has lots of examples that could be ported to Spark.
Another option if you don’t already have the bar code reader, is to buy the PS/2 interface version instead of the USB version. PS/2 is a lot easier to interface and should work well on the core. There has been a port of the library for this and I think it is still being debugged but there has been some good progress.
I see. Does this board (MAX3421) is compatible for the spark core directly?
Also , i don’t find the spark with PS2 ? where can i find it for buying?
The Arduino libraries for the MAX3421 board would need to be ported to Spark. It is an SPI device that is compatible with any small board computer than can do SPI, but needs driver software.
You can buy a PS/2 scanner here:
The PS/2 “port” are just 4/5 wires connected to some pins on the Core. Once you run the library on it, the Core speaks PS/2
Oh wow, I have a keyboard very close to one of the old IBM Model M’s, there is something wonderfully devious about wiring that to a Core… Maybe a 1980’s twitter machine? Is there a PS/2 library floating around?
Yes there is
I think it’s in @kennethlimcp 's Dropbox - http://community.spark.io/t/porting-arduino-serial-ps2-keyboard-library/8131/13
I’ve once used the PS/2 capability of a USB mouse to make a prank mouse (but also useful for real world applications) which also listened to Bluetooth commands (mouse movement and keyboard presses ;-)) - quite alarming for unaware users - hihihi
I’m interested in USB host for one of my projects as well. It looks like the STM32F205 in the new Spark Photon will be able to support this. Can anybody confirm?
I quickly looked at the datasheet and it seems like the micro USB port might be able to switch over to become OTG/HOST but i’m not 100% sure
Yes, the Photon can in principle function as a USB OTG host. What cool things would you do with it?
I was looking to control a DSLR camera using the PTP protocol. A few libraries exist for the Arduino USB Host shield that I was looking to tinker with once my Photon gets delivered (https://github.com/felis/PTP_2.0).
After reading more posts from @mdma about this, I still don’t see a definite answer on whether or not USB OTG will be possible on the Photon. Most recently, I saw this statement from another post (https://community.particle.io/t/usb-master-on-photon/12246/11):
Just a note to say I was wrong about OTG on the photon. I didn’t realize there was some missing hardware, such as a 5v source, that would be needed to support OTG.
What hardware is missing to prevent the Photon from supporting OTG?
If the Photon is acting as a USB Host (like a PC) then it needs to supply +5V to USB peripherals which it is not setup out of the box to do.
You could accomplish this in a number of ways including making a special cable that splices in +5V to the Photon USB connector or replacing the protection diode D1 in the schematic linked below with a wire. This diode normal separates a power source on Vin from the USB connector to avoid a problem when you are powering your Photon with a stand-alone supply but also want to USB for say serial debug messages.
You need a “funny” cable anyway since you will want a USB A female connector for the peripheral, so I would splice the power in there instead of modifying the Photon itself.
Makes sense, thanks @bko! Can’t wait to start experimenting…
Hey all, I got my photon this week and love the experience so far! After creating a few test programs I’m anxious to start working with the USB host functionality discussed in this thread. I went ahead and created my ‘funny’ OTG cable with 5V power, so now the only missing piece of the puzzle seems to be the actual USB OTG driver on the Photon.
After browsing through the firmware I found the usb_hal.c file with some references to OTG. Is this support currently in the works?