usb otg

Every hacker has a USB thumb drive on their keyring, filled with backup files and a way to boot up a broken computer. One feature that most are missing though is USB On The Go (OTG) support, which allows a USB device to act as a USB host, connecting to devices like cell phones and tablets.

There are a few caveats, though: it needs a USB thumb drive with solderable headers, which most of the smallest drives that have connectors right on the PCB won’t have. Most of the larger drives will have these, though, and they are cheap, so finding a suitable victim isn’t hard.

USB On-The-Go (OTG) is one of the fun aspects of the USB standard. There are feelings about the other aspects, but that one is alright. Regardless, [Francesco] realized one day that the £3 digital picture frames he purchased at a charity sale really didn’t care if the files on the thumb drive mysteriously changed all the time. It would just keep pulling and displaying the latest file at a blistering 0.2 frames per second. That’s right, the concept [Francesco] went after is to show changing data, even animations, with an update of one frame every five seconds!

His initial tests showed good for the concept — the Pi can easily emulate a mass storage device, feeding in data whenever the picture frame looks for it. In addition to the Pi Zero board he added an Ethernet shield, a voltage regulator, a camera, and even some infrared LEDS. We suppose there are dreams for the future.

He has been developing scripts for this rig by logging in through a VNC. A cron job runs his scripts at regular intervals, grabbing useful data and making it available as an image. For example, one script opens up the weather in Epiphany (a web browser), takes a screenshot, and saves that screenshot to the mass storage being emulated using USB OTG. The digital picture frame blissfully updates, unaware of its strange appendages. Now the real limiting factor is how much you can accomplish with your mad Bash skills.

The Raspberry Pi Zero – and the not-perpetually-out-of-stock Raspberry Pi A+ – only have one USB port, but behind that port is a lot of functionality. This is an OTG USB port, and just like the USB port on your smartphone, this little plug can become any kind of USB device. Transforming the Pi into a USB gadget allows it to be a serial connection, MIDI device, audio source or sink, or a USB mass storage device.

The build started with [Andrew Mulholland]’s guide for Pi Zero OTG modes, with just a few modifications. When the Pi is plugged into a PC, it automatically becomes a 100 Megabyte USB storage device. You don’t need that much space on a digital picture frame, anyway.

While setting up a digital picture frame is easy enough, there’s still a tremendous amount of untapped potential in using the Pi Zero as a USB gadget. With enough buttons, switches, and sensors, the Pi can become a wearable MIDI device, or with the Pi camera module, an IP webcam. Neat stuff, and we can’t wait to see what the community comes up with next.

You need to get an SPI bus on something right now, but you left your laptop at home. No problems, because you’ve got your Bus Pirate and cellphone in your pocket. And a USB OTG cable, because you’re going to need one of those. And some probes. And maybe a soldering iron for tacking magnet wire onto those really small traces. And maybe a good magnifying glass. And…

OK, our fantasy of stepping away from the party for a quick JTAG debugging session is absurd, but what’s not at all absurd is the idea of driving your Bus Pirate from a nice GUI app on your Android phone. [James Newton] wrote DroidScriptBusPirate so that he wouldn’t have to hassle with the Bus Pirate’s nested single-character menu system, and could easily save complete scripts to do common jobs from pleasant menus on his phone.

The setup depends on downloading DroidScript, a free Javascript and HTML5 IDE, and then pasting and saving [James]’ code. He’s written up full instructions to help you with the install. It’s not so hard, and once you’re done you’ll be ready to drive the Pirate from the comfort of your phone.

In fact, now that we think of it, we’re missing a Bus Pirate GUI for our desktop as well. Whenever we have complex tasks, we end up scripting something in Python, but there ought to be something more user-friendly. Anyone know of a good GUI solution?

[gbaman] has figured out a simpler way to program the new Raspberry Pi Zero over USB without modifying the board. Why is this useful? One example which appealed to us was setting the Zero’s USB port up as a mass storage device. Imagine plugging in your Pi powered robot, dragging and dropping a Python script into the mass storage device that shows up, and pressing a button on the robot to run the new script. Pretty fancy for $5.00.

You can get the PI to emulate a whole range of devices from a USB MIDI controller to a simple USB serial interface. We’re excited to see what uses people come up with. Unfortunately the Pi Zero is still out of stock most everywhere as we wait for the next production run to finish. Though if you’ve got one, why not check out a few of our thoughts and experiences with the device!

The Raspberry Pi Zero is limited, or so everyone says, and everyone is trying to cram a USB hub and WiFi adapter on this tiny, tiny board. One thing a lot of people haven’t realized is that the Raspberry Pi Zero comes with a USB OTG port, meaning it can function as a USB device rather than a USB host. This means the Raspi can become a serial device with just a USB cable, an Ethernet device, MIDI device, camera, or just about anything else you can plug into a USB port. Adafruit has your back with a tutorial for using the USB OTG port as a serial and Ethernet interface, and the possible applications are extremely interesting.

The only requirement for using the USB OTG port for device applications is an update to the kernel. This is easily installed by dumping a few files on an SD card and a employing bit of command line wizardry. The simplest example is setting up the Pi Zero as a USB serial device, allowing anyone to log into a serial console on the Pi with just a USB cable.

A slightly more interesting application is setting up the Pi as an Ethernet gadget. This effectively tunnels all the networking on the Pi Zero through a USB cable and a separate computer. The instructions are extremely OS-specific, but the end result is the same: you can apt-get on a Pi Zero to your heart’s desire with a new kernel loaded onto the SD card and a USB cable.

This experimentation is just scratching the surface of what is possible with the OTG port on the Pi Zero. MIDI devices are easy, and with a ton of GPIOs, the Pi Zero itself could become a very interesting musical instrument. Want the Pi Zero to be a storage device? That’s easy too. The USB Gadget will end up being one of the most exciting uses for the Pi Zero, and we can’t wait to see what everyone will come up with next.

[pmf], like most of us, I’m sure, spends most of his days on a computer. He also has a smartphone he keeps at his side, but over the years he’s grown accustomed to typing on a real keyboard. He came up with the idea of making a USB switch that would allow his keyboard to control either his computer or his phone, and hit upon a really neat way of doing it. He’s using a BeagleBone Black and a Teensy to switch his keyboard between his computer and his phone with just a press of a button.

This homebrew smart KVM uses a BeagleBone Black for most of the heavy lifting. A keyboard and mouse is connected to the USB host port of the BeagleBone, and the main computer is connected to the device port. The BeagleBone is set up to pass through the USB keyboard and mouse to the computer with the help of what Linux calls a ‘gadget’ driver. This required an update to the Linux 4.0 kernel.

With the BeagleBone capable of being a USB pass through device, the next challenge was sending keypresses to another USB device. For this, a Teensy 2.0 was connected to the UART of the BeagleBone. According to [pmf], this is one of the few examples of the Teensy serving as a composite USB device – sending both keyboard and mouse info.

There are a few neat features for [pmf]’s build: the keyboard and mouse don’t disconnect when switching, and thanks to a slight modification of the USB OTG adapter, this will also charge a phone as well as allow for the use of a keyboard. Because the BeagleBone Black has more than one UART this build can also switch keyboards and mice between more than two computers. For those of us who invest heavily in keyboards, it’s a godsend.