Search Results

Keyword: ‘usb’

USB Host Shield Mini in webshop

March 30th, 2014 2 comments

After some great success with the USB Host shield development and the sales of the USB Host shield for Arduino thru our webshop, we are happy to announce that we have also started carrying the compact version of the shield, the USB Host Shield for Arduino Pro Mini.

USB Host Shield for Arduino Pro Mini

USB Host Shield for Arduino Pro Mini

The shield is just a compact version of the well known USB Host shield for Arduino’s and it makes you able to add the USB Host functionality such as Bluetooth control with PS3, Wii or your Android phone, to any Arduino Pro Mini equipped projects. Please note that your Arduino Pro Mini must be running 3.3V though!

We will be selling the mini shield at an introductory price of $20.00 USD and it can be bought including pre-cut headers for stacking.

Visit our webshop for more information:

Categories: Arduino, News, USB Tags:

PS4 controller now supported by the USB Host library

January 12th, 2014 159 comments

I am very pleased to announce that I have now added support for the PS4 controller via Bluetooth. This will allow you to read all the buttons and joysticks with the same API as all the other libraries I have written for the USB Host library.

PS4 controller

To get started you should look at the provided example. It shows how to read the different buttons and joysticks. I still haven’t figured out how to control the light, rumble and read the accelerometer, gyroscope and touchpad, but hopefully I will figure that out soon.
Read more…

Categories: Arduino, Bluetooth, TKJ Electronics, USB Tags:

Bluetooth HID devices now supported by the USB Host library

December 1st, 2013 68 comments

I am glad to announce that Bluetooth HID devices are now supported by the USB Host library. The library already supports PS3 and Wiimote controllers, but now it also supports more general devices, like Bluetooth keyboard and mice.

An example is available at the following link:

First time you run the code, you will have to pair with your device, this is done by creating the instance like so:

BTHID bthid(&Btd, PAIR, "0000");

You can of course set the pin to anything you like.

Now you should enable discovery of your device and it should automatically detect any mouse or keyboard present and then connect to them. On Bluetooth mice there is no need to enter any pin, but on a keyboard you should enter the pin on the keyboard and then afterwards press enter.

So in this example you should press 0 four times on the keyboard and then press enter afterwards.

After you have paired with the device, you can simply create the instance like so:

BTHID bthid(&Btd);

When you press any button on your device it will automatically connect to the last paired device i.e. your Arduino.
Read more…

Categories: Arduino, Bluetooth, TKJ Electronics, USB Tags:

Documentation added for the USB Host Library

February 20th, 2013 22 comments

I’m happy to announce that documentation is now available for all the libraries I have written for the USB Host Shield library.
The documentation is available at the following link:
The documentation is generated using Doxygen which is a free documentation-generator based upon the header files in the source code.

For instance the following comment will end up looking like this in the documentation:

I hope this will be useful for people who is new to the USB host library or even people who just want a quick overview.
If you spot any typos or got any comments please let me know in the comments below.

Categories: Arduino, Bluetooth, TKJ Electronics, USB Tags:

USB Host Shield is now available in the webshop

January 17th, 2013 72 comments

This is a short announcement regarding the USB Host Shield from Circuits@Home, which we are now carrying in in our store.
By buying the official shield you will support the continous development of the library and get support from us!
The shield can be found and bought here: USB Host Shield 2.0 for Arduino.

The shield can be used with almost any kind of Arduino including the most popular Arduino Uno, Arduino Mega, Arduino Leonardo etc. If you are in doubt if your Arduino is supported please don’t hesitate to write a comment below.

The USB Host Shield will allow you to use any of the Bluetooth and USB libraries I wrote.
Read more…

Categories: Arduino, Bluetooth, TKJ Electronics, USB Tags:

Xbox 360 receiver added to the USB Host Library

December 29th, 2012 104 comments

You asked for it and here it is.
I finally got the time to implement support for Wireless Xbox 360 controllers to the USB Host Library. This is done via a Xbox 360 Wireless receiver that is normally intended for Windows computers.

The source code can be found at github:
There is an example as well:

The receiver supports up to four controllers internally, so it was fairly easy to implement it.

Actually I havn’t tested the library with more than one controller, but if somebody out there could confirm if it’s working or not, with more than one controller, I would really appreciate it!
Thanks to Tim, multiple controllers is now confirmed to work!
Read more…

Categories: Arduino, TKJ Electronics, USB Tags:

Wiimote added to USB Host library

August 21st, 2012 72 comments

This is yet again a new announcement regarding the USB Host library. I just added support for the Wiimote via Bluetooth.
Check out the source code at github: and the example sketch as well.
I will work on implementing support for the Nunchuck and Wii Motion Plus extension in the near future.

The library now also supports the Nunchuck controller and the Motion Plus extensions. The newest version of the library can be found at github.

Another Update:
The library now also work with the new Wiimote where the Motion Plus extension is built-in.
Check out my commit to see what where needed in order to make the new Wiimote work as well – the main difference is that you now have to send the data using the interrupt channel.
To tell if your Wiimote is the new type, it should have a label at the bottom saying “Wii MotionPlus INSIDE”. If you are in doubt take a look at this picture.

Yet another update:
The IR camera inside the Wiimote is now also supported. The the following commit for more information.

A new update once again:
The Wii U Pro Controller is now also supported via Bluetooth.

Categories: Arduino, Bluetooth, TKJ Electronics, USB Tags:

Xbox 360 controller support added to the USB Host Library

July 18th, 2012 88 comments

A wireless Xbox 360 controller is now also supported via a Wireless receiver. For more information see the blog post.

Hi everyone. I just wanted to let you know, that I just added support for the Xbox 360 controller via USB to the USB Host Library. The code can as always be found at github:

Categories: Arduino, TKJ Electronics, USB Tags:

FEZ Panda and USB Host

March 24th, 2011 14 comments

As I promised in my previous post, I would show you how to get USB Host working on the FEZ Panda.

FEZ Panda - USB Host Cable

When I first glanced at the LPC2387 datasheet (the ARM on the Panda), I notice that it actually supported USB Host. Then I thought why it wasn’t possible to use USB Host on the Panda, and I quickly found out that it was because it required some hardware modifications.

USB Cable Wiring

The difference in the hardware between USB Client and USB Host is that the Host is powering the Client, and the Panda had a protection diode so no power would go “out” the USB port. Another thing to notice is that USB Host requires two 15K resistors to pull D+ and D- to ground.

FEZ Panda - USB Host cable wiring

SMD solution
So how did I do it? I didn’t want to modify the FEZ Panda board, as the USB port would then be a permanent USB Host port. Instead I thought it would be nice just to have a cable for the USB Host thing, which should include the two resistors, and a power wire for the +5V power supply.
The first image in this post is my cable, and the second image shows the connections, where there is soldered two 15K SMD 0805 resistors inside. This took a long time to make because it was so small, and SMD resistors can’t handle much force. On a longer term basis it would be better to make an adapter PCB instead.

USB Host cable Schematic

Above you can see the simple schematic of the changes that has to be made to the cable, including where to solder/connect the two 15K resistors.

Thru Hole solution
Instead of using SMD resistors I recommend you to use Thru Hole resistors, and they can handle a lot more force, and the joint will also be more reliable.

FEZ Panda - USB Host Cable

The assembly method is the same as with the SMD resistors. If you don’t have any 15K resistors in hand, we have also tested it with a 12K instead, and everything seems to be running fine with that too.

FEZ Panda - USB Host cable wiring

Oh, and please notice the USB Mini-B to USB Female A adapter at the end. This can be bought at Amazon for $1.87!

USB Connector Pinout

After I made the cable the last thing I had to do was to update the firmware on the FEZ Panda, as the firmware (USBizi) for the FEZ Panda, didn’t support USB Host until V4.1.5.0, though the processor did. After I uninstalled the old firmware/SDK, downloaded the new one, and installed it, I was ready to update the firmware. I just followed this simple Youtube guide:

After the firmware was updated, I connected a cable from the MODE pin to GND to enable Serial Port (COM1) debugging, as the USB port will now be used for USB Host functions.
Then I just followed the “USB Host – Mass Storage” chapter in the Beginners Guide to .NETMF.

To help you guys getting started, I used this code to test the USB Host function. The applications outputs which device is connected, and if a Mass Storage device is detected, the files- and folder tree is shown too.

using System;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;

using Microsoft.SPOT.IO;
using GHIElectronics.NETMF.IO;
using GHIElectronics.NETMF.USBHost;
using System.IO;

using System.IO.Ports;
using System.Text;

namespace FEZ_Panda_Application1
    public class Program
        static bool ledState = false;
        static OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);

        static SerialPort UART = new SerialPort("COM2", 115200);

        // Hold a static reference in case the GC kicks in and disposes it
        // automatically, note that we only support one in this example!
        static PersistentStorage ps;

        public static void Main()


            // Subscribe to RemovableMedia events
            RemovableMedia.Insert += RemovableMedia_Insert;
            RemovableMedia.Eject += RemovableMedia_Eject;

            // Subscribe to USB events
            USBHostController.DeviceConnectedEvent += DeviceConnectedEvent;
            USBHostController.DeviceDisconnectedEvent += DeviceDisconnectedEvent;
            // Sleep forever

            int read_count = 0;
            byte[] rx_byte = new byte[1];

            while (true)
                // read one byte
                read_count = UART.Read(rx_byte, 0, 1);
                if (read_count > 0) // do we have data?
                    //WriteSerial("I recieved: " + (char)rx_byte[0]);
                    switch ((char)rx_byte[0])
                        case 'W':
                            WriteSerial("Writing content to test file:");
                            WriteTestFile("Hello there!");
                            WriteSerial("   Hello there!");
                        case 'R':
                            WriteSerial("Reading content from test file:");
                            WriteSerial("   " + ReadTestFile());

        static void DeviceConnectedEvent(USBH_Device device)
            string USBDeviceType = "";

            switch (device.TYPE)
                case USBH_DeviceType.HID:
                    USBDeviceType = "HID";
                case USBH_DeviceType.Hub:
                    USBDeviceType = "Hub";
                case USBH_DeviceType.Joystick:
                    USBDeviceType = "Joystick";
                case USBH_DeviceType.Keyboard:
                    USBDeviceType = "Keyboard";
                case USBH_DeviceType.MassStorage:
                    USBDeviceType = "Mass Storage";
                case USBH_DeviceType.Mouse:
                    USBDeviceType = "Mouse";
                case USBH_DeviceType.Printer:
                    USBDeviceType = "Printer";
                case USBH_DeviceType.Serial_CDC:
                case USBH_DeviceType.Serial_FTDI:
                case USBH_DeviceType.Serial_Prolific:
                case USBH_DeviceType.Serial_Sierra_C885:
                case USBH_DeviceType.Serial_SiLabs:
                    USBDeviceType = "USB to Serial converter";
                case USBH_DeviceType.Sierra_Installer:
                    USBDeviceType = "Sierra Installer";
                case USBH_DeviceType.Unknown:
                    USBDeviceType = "Unknown";
                    USBDeviceType = "Unknown";

            WriteSerial("USB Device connected: " + USBDeviceType);
            WriteSerial("ID: " + device.ID + ", Interface: " + device.INTERFACE_INDEX + ", Type: " + device.TYPE);


            if (device.TYPE == USBH_DeviceType.MassStorage)
                WriteSerial("Mounting Mass Storage...");
                ps = new PersistentStorage(device);

        static void DeviceDisconnectedEvent(USBH_Device device)
            WriteSerial("USB Device disconnected...");

        static void RemovableMedia_Insert(object sender, MediaEventArgs e)
            WriteSerial("Storage "" + e.Volume.RootDirectory + "" is inserted.");
            WriteSerial("Getting files and folders:");
            if (e.Volume.IsFormatted)
                WriteFilesAndFolders(e.Volume.RootDirectory, e);
                WriteSerial("Storage is not formatted. Format on PC with FAT32/FAT16 first.");

        static void RemovableMedia_Eject(object sender, MediaEventArgs e)
            WriteSerial("Storage "" + e.Volume.RootDirectory + "" is ejected.");

        static string[] files, filesSub;
        static string[] folders, foldersSub;
        static void WriteFilesAndFolders(string path, MediaEventArgs e)
            files = Directory.GetFiles(path);
            folders = Directory.GetDirectories(path);
            WriteSerial("Files available on " + path + ":");
            for (int i = 0; i < files.Length; i++)
                WriteSerial("   " + files[i]);

            WriteSerial("Folders available on " + path + ":");
            for (int i = 0; i < folders.Length; i++)
                WriteSerial("   " + folders[i]);
                WriteSubFilesAndFolders(folders[i], e);

        static void WriteSubFilesAndFolders(string path, MediaEventArgs e)
            filesSub = Directory.GetFiles(path);
            foldersSub = Directory.GetDirectories(path);
            WriteSerial("Files available on " + path + ":");
            for (int i = 0; i < filesSub.Length; i++)
                WriteSerial("   " + filesSub[i]);

            WriteSerial("Folders available on " + path + ":");
            for (int i = 0; i < foldersSub.Length; i++)
                WriteSerial("   " + foldersSub[i]);
                WriteSubFilesAndFolders(foldersSub[i], e);

        static void WriteTestFile(string dataToWrite)
            if (VolumeInfo.GetVolumes().Length < 1) return;
            // Assume one storage device is available,
            // access it through NETMF
            string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
            FileStream FileHandle = new FileStream(rootDirectory + @"\hello.txt", FileMode.Create);
            byte[] data = Encoding.UTF8.GetBytes(dataToWrite);
            // write the data and close the file
            FileHandle.Write(data, 0, data.Length);

        static string ReadTestFile()
            if (VolumeInfo.GetVolumes().Length < 1) return "No Mass Storage found!";
            // Assume one storage device is available,
            // access it through NETMF
            string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
            if (!new FileInfo(rootDirectory + @"\hello.txt").Exists) return "File not found!";
            FileStream FileHandle = new FileStream(rootDirectory + @"\hello.txt", FileMode.Open, FileAccess.Read);
            byte[] data = new byte[100];
            // write the data and close the file
            int read_count = FileHandle.Read(data, 0, data.Length);
            //Debug.Print("The size of data we read is: " + read_count.ToString());
            //Debug.Print("Data from file:");
            //Debug.Print(new string(Encoding.UTF8.GetChars(data), 0, read_count));
            return new string(Encoding.UTF8.GetChars(data), 0, read_count);
        static void WriteSerial(string StringToWrite)
            // convert the string to bytes
            byte[] buffer = Encoding.UTF8.GetBytes(StringToWrite + "\r\n");
            // send the bytes on the serial port
            UART.Write(buffer, 0, buffer.Length);

This video is just an example of what you can use the USB-host functionality for:

Kristian has succesfully connected the PS3 Controller to the FEZ Panda, for more information, take a look at his post.

Categories: ARM, USB Tags:

Minimal PIC18 USB connection schematic

October 2nd, 2010 No comments

While cleaning up my computer files I stumbled over this schematic, which I used in the early stage of the USB LED Matrix development, and I thought it might be usefull to others.

Minimal PIC18 USB Schematic

Categories: PIC Tags: