@mauimauer, I’m curious if you ever got this shield working with the photon with the ported library?
@wesner0019, I ported the code but have not tested it yet. It is on my todo list
@peekay123, thats awesome, Do you know if any of the examples for the USB host mode would allow simple communication between two photons?
Photon 1: Client
Photon 2: Host
What I am looking to do is some thing like on Photon 1: Serial.print(), then on Photon 2: Serial.read to pass this into a new variable into Photon 2.
In the end, I want to connect a P1 (client) to an Electron (host) via USB to allow the electron to communicate to the cloud if Wifi is not available. The electron would basically clone the publish events of the P1 if WiFi is disconnected or not available.
@wesner0019, the code is designed to work with an Arduino USB Host shield so the answer would be no.
@peekay123 , I would end up making a custom pcb for the electron or P1 with the USB Host Controller IC on the pcb. and then modify the pins defines as needed
@wesner0019, understood. We’ll just have to do some testing then!
@peekay123, Here’s a simple shield I’m planning on making. Do you have any suggestions for improvement? The outline is for the electron but the photon will also work.
@wesner0019, do you have a schematic to go with that? You might want to add a decoupling cap on the USB power line and clean up some of the traces. There are some other items but I need to see the schematics.
With this board i plan on the following diagram: PSU -> USB A - MICRO USB -> Photon/Electron(Host) -> USB A - MICRO USB -> Photon(Client)
The power will be passed thru to power both connected devices.
Here the schematic and an updated board the USB is now a female plug. I didn’t add any decoupling on the VBUS/RAW power because it is a pass thru power connection to the Particle/Electron where these will have the power caps.
I could add a ferrite beat to the USB in though for EMI.
How would you clean up the traces? I’m self taught, so any input will be appreciated.
@peekay123, just wondering if you were able to look at the sketch?
@peekay123, I’ve ordered the board and a test board from Circuits@Home
https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-for-arduino-pro-mini
I can send one of my boards to you if you’d like, once I get them built and tested.
I am new to USB protocol and the library that you ported. Do you have any suggestion how I can get started to start testing communication with photon to photon via USB?
As a basic sketch I would like to send an automatically increment number from the client photon and the host photon reads this then prints it out on the serial monitor every second or two.
Will I need to used the USB_desc example and then use the ACM_terminal example library as a building blocks?
Any help will be vastly appreciated!
@wesner0019, to tell you the truth, I ported the library “blindly” for another member. I haven’t go a lot of experience with USB either and that’s why I looked to others for testing
Thanks for the heads up.
Ill post info here as I am trying to figure it out.
This is a windows program that will dump any USB descriptor info into it. Could be useful.
http://www.thesycon.de/eng/usb_descriptordumper.shtml
From the above program the P1 has the following Descriptors:
Information for device P1 with WiFi (VID=0x2B04 PID=0xC008):
Connection Information:
------------------------------
Connection status: Device connected
Device actual bus speed: Full
Device is hub: No
Device adress: 0x0014
Current configuration value: 0x01
Number of open pipes: 3
Device Descriptor:
------------------------------
0x12 bLength
0x01 bDescriptorType
0x0200 bcdUSB
0x02 bDeviceClass (Communication Device Class)
0x00 bDeviceSubClass
0x00 bDeviceProtocol
0x40 bMaxPacketSize0 (64 Bytes)
0x2B04 idVendor
0xC008 idProduct
0x0200 bcdDevice
0x01 iManufacturer "Particle"
0x02 iProduct "P1 with WiFi"
0x03 iSerialNumber "00000000050C"
0x01 bNumConfigurations
Hex dump:
0x12 0x01 0x00 0x02 0x02 0x00 0x00 0x40 0x04 0x2B
0x08 0xC0 0x00 0x02 0x01 0x02 0x03 0x01
Configuration Descriptor:
------------------------------
0x09 bLength
0x02 bDescriptorType
0x0043 wTotalLength
0x02 bNumInterfaces
0x01 bConfigurationValue
0x00 iConfiguration
0xC0 bmAttributes (Self-powered Device)
0x32 bMaxPower (100 mA)
Hex dump:
0x09 0x02 0x43 0x00 0x02 0x01 0x00 0xC0 0x32
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x00 bInterfaceNumber
0x00 bAlternateSetting
0x01 bNumEndPoints
0x02 bInterfaceClass (Communication Device Class)
0x02 bInterfaceSubClass (Abstract Control Model)
0x01 bInterfaceProtocol (ITU-T V.250)
0x00 iInterface
Hex dump:
0x09 0x04 0x00 0x00 0x01 0x02 0x02 0x01 0x00
CDC Header Functional Descriptor:
------------------------------
0x05 bFunctionalLength
0x24 bDescriptorType
0x00 bDescriptorSubtype
0x0110 bcdCDC
Hex dump:
0x05 0x24 0x00 0x10 0x01
CDC Call Management Functional Descriptor:
------------------------------
0x05 bFunctionalLength
0x24 bDescriptorType
0x01 bDescriptorSubtype
0x00 bmCapabilities
0x01 bDataInterface
Hex dump:
0x05 0x24 0x01 0x00 0x01
CDC Abstract Control Management Functional Descriptor:
------------------------------
0x04 bFunctionalLength
0x24 bDescriptorType
0x02 bDescriptorSubtype
0x02 bmCapabilities
Hex dump:
0x04 0x24 0x02 0x02
CDC Union Functional Descriptor:
------------------------------
0x05 bFunctionalLength
0x24 bDescriptorType
0x06 bDescriptorSubtype
0x00 bControlInterface
0x01 bSubordinateInterface(0)
Hex dump:
0x05 0x24 0x06 0x00 0x01
Endpoint Descriptor:
------------------------------
0x07 bLength
0x05 bDescriptorType
0x82 bEndpointAddress (IN Endpoint)
0x03 bmAttributes (Transfer: Interrupt / Synch: None / Usage: Data)
0x0008 wMaxPacketSize (8 Bytes)
0xFF bInterval
Hex dump:
0x07 0x05 0x82 0x03 0x08 0x00 0xFF
Interface Descriptor:
------------------------------
0x09 bLength
0x04 bDescriptorType
0x01 bInterfaceNumber
0x00 bAlternateSetting
0x02 bNumEndPoints
0x0A bInterfaceClass (CDC Data)
0x00 bInterfaceSubClass
0x00 bInterfaceProtocol
0x00 iInterface
Hex dump:
0x09 0x04 0x01 0x00 0x02 0x0A 0x00 0x00 0x00
Endpoint Descriptor:
------------------------------
0x07 bLength
0x05 bDescriptorType
0x01 bEndpointAddress (OUT Endpoint)
0x02 bmAttributes (Transfer: Bulk / Synch: None / Usage: Data)
0x0040 wMaxPacketSize (64 Bytes)
0x00 bInterval
Hex dump:
0x07 0x05 0x01 0x02 0x40 0x00 0x00
Endpoint Descriptor:
------------------------------
0x07 bLength
0x05 bDescriptorType
0x81 bEndpointAddress (IN Endpoint)
0x02 bmAttributes (Transfer: Bulk / Synch: None / Usage: Data)
0x0040 wMaxPacketSize (64 Bytes)
0x00 bInterval
Hex dump:
0x07 0x05 0x81 0x02 0x40 0x00 0x00
String Descriptor Table
--------------------------------
Index LANGID String
0x00 0x0000 0x0409
Hex dump:
0x04 0x03 0x09 0x04
0x01 0x0409 "Particle"
Hex dump:
0x12 0x03 0x50 0x00 0x61 0x00 0x72 0x00 0x74 0x00
0x69 0x00 0x63 0x00 0x6C 0x00 0x65 0x00
0x02 0x0409 "P1 with WiFi"
Hex dump:
0x1A 0x03 0x50 0x00 0x31 0x00 0x20 0x00 0x77 0x00
0x69 0x00 0x74 0x00 0x68 0x00 0x20 0x00 0x57 0x00
0x69 0x00 0x46 0x00 0x69 0x00
0x03 0x0409 "00000000050C"
Hex dump:
0x1A 0x03 0x30 0x00 0x30 0x00 0x30 0x00 0x30 0x00
0x30 0x00 0x30 0x00 0x30 0x00 0x30 0x00 0x30 0x00
0x35 0x00 0x30 0x00 0x43 0x00
0xEE 0x0000 Request failed with 0x00000079
Hex dump:
------------------------------
Whole Device Descriptor as hex dump:
0x12, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x40, 0x04, 0x2B,
0x08, 0xC0, 0x00, 0x02, 0x01, 0x02, 0x03, 0x01
Whole Configuration Descriptor as hex dump:
0x09, 0x02, 0x43, 0x00, 0x02, 0x01, 0x00, 0xC0, 0x32, 0x09,
0x04, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x00, 0x05, 0x24,
0x00, 0x10, 0x01, 0x05, 0x24, 0x01, 0x00, 0x01, 0x04, 0x24,
0x02, 0x02, 0x05, 0x24, 0x06, 0x00, 0x01, 0x07, 0x05, 0x82,
0x03, 0x08, 0x00, 0xFF, 0x09, 0x04, 0x01, 0x00, 0x02, 0x0A,
0x00, 0x00, 0x00, 0x07, 0x05, 0x01, 0x02, 0x40, 0x00, 0x00,
0x07, 0x05, 0x81, 0x02, 0x40, 0x00, 0x00
------------------------------
Connection path for device:
Intel(R) USB 3.0 eXtensible Host Controller
Root Hub
P1 with WiFi (VID=0x2B04 PID=0xC008)
Brought to you by TDD v1.83.0, Mar 7 2014, 14:22:05
From the above: the P1 communicates through: CDC-ACM, so the ACM example should be a great starting point.
0x02 bInterfaceClass (Communication Device Class)
0x02 bInterfaceSubClass (Abstract Control Model)
@peekay123, does this need to be added in the UsbCore.h file for the core/photon?
Should this definition be changed too to match the defined pins for usbhost.h;
@wesner0019, I’ll check tomorrow. If you are referring to the SS pin then, ya, I will need to look at that. I remember getting a headache trying to figure out the pin assignments
Haha, I know what you mean. It would be for all the SPI pins though not just SS.
in the usbhost.h file, line 106, I think it should look like below: (the commented out line is what was there originally
#elif (PLATFORM_ID == 0) || (PLATFORM_ID == 6) //Core & Photon
//typedef SPi< P11, P13, P12, P10 > spi; //CLK, MOSI, MISO, SS
typedef SPi< P17, P8, P9, P16 > spi; //CLK, MOSI, MISO, SS
#else
@peekay123, just wondering if the example sketch are still in you dropbox download. I re-downloaded but there is no example within it.
Thanks
@wesner0019, the example is USBHIDBootKbd.cpp
. The .cpp was used instead of .ino since I am using a local toolchain.