Skip to content

Added support for ESP8266 #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Jun 14, 2017
Merged

Added support for ESP8266 #263

merged 30 commits into from
Jun 14, 2017

Conversation

Lauszus
Copy link
Collaborator

@Lauszus Lauszus commented Oct 25, 2016

See: #262

@Lauszus Lauszus mentioned this pull request Oct 25, 2016
The Wifio is not supported for now
@Lauszus
Copy link
Collaborator Author

Lauszus commented Nov 2, 2016

@huming2207 I just merged in your changes ;)

@Lauszus
Copy link
Collaborator Author

Lauszus commented Nov 2, 2016

@huming2207 now I just need you to test all this.

@huming2207
Copy link
Contributor

@Lauszus Got it, thanks mate!

@Lauszus
Copy link
Collaborator Author

Lauszus commented Nov 27, 2016

@huming2207 any updates?

@huming2207
Copy link
Contributor

@Lauszus Sorry for the delay. I've got an intern so I'm a bit busy now. I'll try it in the following days.

* master:
  The Xbox button on the Xbox One controller was not read properly
  Added support for Teensy 3.5 and 3.6

# Conflicts:
#	.travis.yml
@huming2207
Copy link
Contributor

@Lauszus Sorry for the delay, now I've tested that GPIO0 for INT doesn't work, it will let the SoC boot into bootloader mode. So perhaps we need to change to another pin. I'll try GPIO16 now.

@huming2207
Copy link
Contributor

Okay I've tested both GPIO0 and 16, neither of them work. I guess it may has some issues with power supply as my USB output only has 4.5v. My laptop (Macbook Pro mid-2015) should be fine, but something may went wrong with my circuit.

@huming2207
Copy link
Contributor

@Lauszus Okay so here is the result.

I'm testing with the newest library code from ESP8266 branch (this one: 46a036c), and I compiled and downloaded the USB HID sample code to one of my NodeMCU 1.0 board (the one with a ESP-12E module).

If I set GPIO0 as INT pin, the board sometimes won't boot, it seems has entered the bootloader mode and waiting me transfer a new firmware to it. Then if I unplug the INT cable from my board and reset it, the serial prints "OSC did not start." (module didn't initialized???)

If I set GPIO16 as INT, then it won't boot completely.

If I set GPIO5 as INT, then it will boot normally, but if I connect a keyboard to it, it doesn't have any further output.

@huming2207
Copy link
Contributor

By the way, I'm very sorry for the long delay.

@huming2207
Copy link
Contributor

Also I have tested with an external power supply for the target USB device, my keyboard, but it doesn't work too.

@Lauszus
Copy link
Collaborator Author

Lauszus commented Dec 10, 2016

What do you mean by "it doesn't have any further output". Did you enable serial debugging: https://github.com/felis/USB_Host_Shield_2.0#enable-debugging. Btw please run the following example: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/board_qc/board_qc.ino.

@huming2207
Copy link
Contributor

Here is the output from board_qc with the debug option enabled:

Circuits At Home 2011
USB Host Shield Quality Control Routine
Reading REVISION register... Die revision invalid. Value returned: FF
Unrecoverable error - test halted!!
0x55 pattern is transmitted via SPI
Press RESET to restart test
Soft WDT reset

ctx: cont 
sp: 3ffef780 end: 3ffef9d0 offset: 01b0

>>>stack>>>
3ffef930:  00000055 00000055 3ffee8b0 402037d3  
3ffef940:  018cba80 00000001 3ffe849e 3ffee9a8  
3ffef950:  00000057 00000055 3ffee8b0 40201c80  
3ffef960:  018cba80 00000001 00000000 4020349c  
3ffef970:  3ffee7cc 3ffee984 000000ff 40201ce8  
3ffef980:  3fffdad0 3ffee984 000000ff 402022ba  
3ffef990:  feefeffe feefeffe feefeffe feefeffe  
3ffef9a0:  feefeffe feefeffe feefeffe 3ffee9a8  
3ffef9b0:  3fffdad0 00000000 3ffee9a0 40203ec0  
3ffef9c0:  feefeffe feefeffe 3ffee9b0 40100114  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld
�
Circuits At Home 2011
USB Host Shield Quality Control Routine
Reading REVISION register... Die revision invalid. Value returned: FF
Unrecoverable error - test halted!!
0x55 pattern is transmitted via SPI
Press RESET to restart test

@huming2207
Copy link
Contributor

I have checked my circuit and I didn't connect the RESET pin from the USB module. Do I need to connect it to my ESP board?

@Lauszus
Copy link
Collaborator Author

Lauszus commented Jun 13, 2017

@Ognian I only picked P0 based on feedback, since I have not really played around with the ESP8266 myself. I will change it to P5 now then.

@Lauszus
Copy link
Collaborator Author

Lauszus commented Jun 13, 2017

I have now changed it to pin 5: c2b6dbf.

@Ognian
Copy link

Ognian commented Jun 13, 2017

@Lauszus ok some more results:
It correctly detects:

  • my wireless keyboard and mouse (usb receiver)
  • my old ms usb mouse
  • a bluetooth dongle
  • a usb chipcard reader
    But on board_qc I get:

Circuits At Home 2011
USB Host Shield Quality Control Routine
Reading REVISION register... Die revision 03
SPI long test. Transfers 1MB of data. Each dot is 64K................ SPI long test passed
GPIO test. Connect GPIN0 to GPOUT7, GPIN1 to GPOUT6, and so on
Test failed. Value written: 00 Value read: FF 
Press any key to continue...
GPIO test passed.
PLL test. 100 chip resets will be performed
Current oscillator state unexpected.
Press any key to continue...
Resetting oscillator

Reset number 0
Reset number 1
Reset number 2
Reset number 3
Soft WDT reset

ctx: cont 
sp: 3ffefd60 end: 3ffeffe0 offset: 01b0

>>>stack>>>
3ffeff10:  3ffeedd0 00000020 0000003f 46000040  
3ffeff20:  3ffeedd0 feefeffe feefeffe 33feefac  
3ffeff30:  00000000 000000cb 3ffeefc0 3ffeef88  
3ffeff40:  00000009 fffffff0 40203ff8 00006d96  
3ffeff50:  0000ffff 00000068 3ffeedd0 40203bab  
3ffeff60:  018cba80 3ffe0001 3ffeedd0 40201eac  
3ffeff70:  0000ffff 00000068 3ffeedd0 40201ede  
3ffeff80:  0000ffff 3ffe0001 00000003 40203ec0  
3ffeff90:  0000ffff 3ffeef88 00000003 402026d5  
3ffeffa0:  00000000 000000f0 000000f0 0000afff  
3ffeffb0:  feefeffe feefeffe feefeffe 3ffeefac  
3ffeffc0:  3fffdad0 00000000 3ffeefa4 4020403c  
3ffeffd0:  feefeffe feefeffe 3ffeefc0 40100108  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(1,6)


 ets Jan  8 2013,rst cause:4, boot mode:(1,6)

wdt reset

I'll try with the USBHID examples...

@Ognian
Copy link

Ognian commented Jun 13, 2017

@Lauszus Ok continue testing...

@Lauszus
Copy link
Collaborator Author

Lauszus commented Jun 13, 2017

This commit should fix the issue with board_qc : c8b7c9a.

If you could test any of the Bluetooth examples as well, then that would be great!

@Ognian
Copy link

Ognian commented Jun 13, 2017

@Lauszus Ok tested with newest version of board_qc, is this OK? It looks different from the output...


Circuits At Home 2011
USB Host Shield Quality Control Routine
Reading REVISION register... Die revision 03
SPI long test. Transfers 1MB of data. Each dot is 64K................ SPI long test passed
GPIO test. Connect GPIN0 to GPOUT7, GPIN1 to GPOUT6, and so on
Test failed. Value written: 00 Value read: FF 
Press any key to continue...
GPIO test passed.
PLL test. 100 chip resets will be performed
Current oscillator state unexpected.
Press any key to continue...
Resetting oscillator

Reset number 0
Reset number 1
Reset number 2
Reset number 3
Reset number 4
Reset number 5
Reset number 6
Reset number 7
Reset number 8
Reset number 9
Reset number 10
Reset number 11
Reset number 12
Reset number 13
Reset number 14
Reset number 15
Reset number 16
Reset number 17
Reset number 18
Reset number 19
Reset number 20
Reset number 21
Reset number 22
Reset number 23
Reset number 24
Reset number 25
Reset number 26
Reset number 27
Reset number 28
Reset number 29
Reset number 30
Reset number 31
Reset number 32
Reset number 33
Reset number 34
Reset number 35
Reset number 36
Reset number 37
Reset number 38
Reset number 39
Reset number 40
Reset number 41
Reset number 42
Reset number 43
Reset number 44
Reset number 45
Reset number 46
Reset number 47
Reset number 48
Reset number 49
Reset number 50
Reset number 51
Reset number 52
Reset number 53
Reset number 54
Reset number 55
Reset number 56
Reset number 57
Reset number 58
Reset number 59
Reset number 60
Reset number 61
Reset number 62
Reset number 63
Reset number 64
Reset number 65
Reset number 66
Reset number 67
Reset number 68
Reset number 69
Reset number 70
Reset number 71
Reset number 72
Reset number 73
Reset number 74
Reset number 75
Reset number 76
Reset number 77
Reset number 78
Reset number 79
Reset number 80
Reset number 81
Reset number 82
Reset number 83
Reset number 84
Reset number 85
Reset number 86
Reset number 87
Reset number 88
Reset number 89
Reset number 90
Reset number 91
Reset number 92
Reset number 93
Reset number 94
Reset number 95
Reset number 96
Reset number 97
Reset number 98
Reset number 99
Checking USB device communication.

Reset complete. Waiting for the first SOF...
Getting device descriptor
Descriptor Length:	12
Descriptor type:	01
USB version:		0110
Device class:		00
Device Subclass:	00
Device Protocol:	00
Max.packet size:	08
Vendor  ID:		046D
Product ID:		C517
Revision ID:		3810
Mfg.string index:	01
Prod.string index:	02
Serial number index:	00
Number of conf.:	01

All tests passed. Press RESET to restart test

@Lauszus
Copy link
Collaborator Author

Lauszus commented Jun 13, 2017

@Ognian yes that looks fine. The GPIO test is normally only used for internal testing as not many people use the GPIO pins on the shield anyway.

@xxxajk
Copy link
Contributor

xxxajk commented Jun 13, 2017 via email

@Lauszus
Copy link
Collaborator Author

Lauszus commented Jun 13, 2017

@xxxajk yes exactly. It looks fine to me.

@Ognian
Copy link

Ognian commented Jun 13, 2017

Yes it looks really good now:
USB_desc is working; USBHID_desc is working; a Keyboard and another Mouse is working...
only problem seems to be that when pressing the reset button sometimes I do not get the initial answer from the usb device attached...
I'm continuing with the tests...

@xxxajk
Copy link
Contributor

xxxajk commented Jun 13, 2017 via email

@xxxajk
Copy link
Contributor

xxxajk commented Jun 13, 2017 via email

@Ognian
Copy link

Ognian commented Jun 13, 2017

@Lauszus OK keyboard and mouse just works, and some other devices are properly detected too.
Now I inserted a bluetooth dongle and started BTHID.ino. I have a MacBook and a bluetooth mouse connected to the Mac. Searching for bluetooth devices on the mac showed a new one called CSR-bc4
when clicking on it it asked for the pin I entered 0000 and voila it is connected...
Any Ideas what I could test now? Initially a wanted to connect the bluetooth mouse but I have no idea how to do it...

HID Bluetooth Library Started
Bluetooth Dongle Initialized
No response to HCI Reset
HCI Reset complete
Write class of device
Local Bluetooth Address: 00:1B:DC:0F:B2:92
Please enable discovery of your device
Gamepad found
HID device found
Now just create the instance like so:
BTHID bthid(&Btd);
And then press any button on the device
Connecting to HID device
Connected to HID device
Received Key Request
Bluetooth pin is set too: 0000
Pairing successful with HID device
Send HID Control Connection Request

@Lauszus
Copy link
Collaborator Author

Lauszus commented Jun 13, 2017

Please test the following example on your Mac: https://github.com/felis/USB_Host_Shield_2.0/blob/master/examples/Bluetooth/SPP/SPP.ino. If it works it then it should create a serial port named /dev/tty.Arduino-TKJSP.

Please see the following blog post on how to connect a Bluetooth mouse using the BTHID example: http://blog.tkjelectronics.dk/2013/12/bluetooth-hid-devices-now-supported-by-the-usb-host-library/.

@Ognian
Copy link

Ognian commented Jun 13, 2017

@Lauszus
SPP.ino looks like it works:
there is a /dev/tty.Arduino-TKJSP
tried to open it but it was busy
what baud rate should it be?

SPP Bluetooth Library Started
Bluetooth Dongle Initialized
No response to HCI Reset
HCI Reset complete
Write class of device
Local Bluetooth Address: 00:1B:DC:0F:B2:92
The name is set to: Arduino
Wait For Incoming Connection Requestrd�l⸮⸮|�⸮#�⸮o⸮l⸮"|⸮⸮�⸮�⸮{⸮#⸮#⸮p~⸮o⸮dno⸮⸮⸮�c�p⸮l{l{lp⸮n⸮���⸮⸮⸮l�⸮⸮�Bo⸮|�l⸮�⸮p�⸮|~⸮o⸮�$⸮⸮l �⸮��on�l ���nr⸮ےn�b⸮�l�{⸮⸮o�#�⸮�l⸮⸮�⌜⸮⸮⸮⸮�rd⸮⸮N⸮�
SPP Bluetooth Library Started
Bluetooth Dongle Initialized
No response to HCI Reset
HCI Reset complete
Write class of device
Local Bluetooth Address: 00:1B:DC:0F:B2:92
The name is set to: Arduino
Wait For Incoming Connection Request
Gamepad is connecting
Incoming Connection Request
Remote Name: ogi-it-mac
Connected to Device: E4:CE:8F:2C:D9:69
Bluetooth pin is set too: 0000
SDP Incoming Connection Request
SDP Successfully Configured
Disconnected SDP Channel
Wait For Incoming Connection Request
HCI Disconnected from Device
Wait For Incoming Connection Request

@Lauszus
Copy link
Collaborator Author

Lauszus commented Jun 13, 2017

@Ognian okay. Try to disable and enable Bluetooth. The baudrate does not matter, as it is an emulated serial port.

@Ognian
Copy link

Ognian commented Jun 14, 2017

@Lauszus sorry for the late answer, had to leave my desk very quickly yesterday...
OK tested with BTHID.ino and my Apple BT Mouse:
changed:

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

turn mouse off, reset board, turn mouse on
and everything works, buttons, positions , so I would say this works perfect.

With the SPP.ino I'm still not able to connect to /dev/tty.Arduino-TKJSP but I think that the sketch works and the problem is with my very very old bluetooth dongle since this is the output from the bluetooth info in OSX:

 Arduino:
  Adresse:	00-1B-DC-0F-B2-92
  Major Type:	Unknown
  Minor Type:	Unknown
  Dienste:	TKJSP
  Verbindung eingerichtet:	Ja
  Konfiguriert:	Ja
  Verbunden:	Nein
  Hersteller:	Cambridge Silicon Radio (0x3, 0xC5C)
  Geräteklasse:	0x08 0x01 0x0804
  EDR wird unterstützt:	Ja
  eSCO wird unterstützt:	Ja
  SSP wird unterstützt:	Nein

It says SPP supported: No
or is this something to set in the sketch?

@Lauszus
Copy link
Collaborator Author

Lauszus commented Jun 14, 2017

@Ognian no worries. I will merge the PR now, as it looks to me like everything is working, as it creates the serial port. To be honest I think the problem is something with your computer.

Thanks a lot for testing!

@Lauszus Lauszus merged commit ff8bdb2 into master Jun 14, 2017
@Lauszus Lauszus deleted the ESP8266 branch June 14, 2017 11:31
@Ognian
Copy link

Ognian commented Jun 14, 2017

@Lauszus you where totally right: rebooting the mac, and SPP.ino is working too...

@Lauszus
Copy link
Collaborator Author

Lauszus commented Jun 14, 2017

@Ognian good to hear that it is working! Please open up a new issue if you encounter any bugs :)

@baghdasaryan
Copy link

Hi guys,

A noob here. I am trying to connect NodeMcu ESP8266 board to Mini USB Host Shield (v2.0 dated Aug. 16, 2014), same USB Host Shield as the one @huming2207 posted a picture of above.

When running board_qc sketch on ESP8266, I keep on getting the following error message:

Circuits At Home 2011
USB Host Shield Quality Control Routine
Reading REVISION register... Die revision invalid. Value returned: FF
Unrecoverable error - test halted!!
0x55 pattern is transmitted via SPI
Press RESET to restart test

I have double-checked my soldering and tried validating connections. Unfortunately, I am not 100% sure if I got all of the connections between USB Shield and ESP8266 right.
img_1672
(the red wire going out of the screen at the bottom is connected to a 5V source)

Wondering if you guys have any suggestions on connecting the boards and what other things I could try to continue debugging.

One of my concerns is that the Mini USB Host Shield I have could be damaged, so I am purchasing a new one to see if that works.

All the help is highly appreciated!

Thanks,
Georgi

@gdsports
Copy link
Contributor

gdsports commented Sep 4, 2017

@baghdasaryan Does the yellow wire connect to RX? If so, it looks off-by-one.

Here is my hook up for a USB host mini board with Adafruit Feather ESP8266.

esp8266usbhostmini

@baghdasaryan
Copy link

Thanks, @gdsports! Your picture got me looking in the right direction.

After mapping all the pins correctly, I got it working on HiLetgo NodeMCU ESP8266 board that I have.

So, following are the issues that prevented me from getting the setup working from the first try:

  • Miso and SCK pin names on USB Host Shield (v2.0 dated Aug. 16, 2014) by duinofun are incorrectly labeled (should be swapped). So, we should disregard labels on the board and use the ones in this picture (which are correct despite the new board looking differently):
    uhm11_manual
  • HiLetgo NodeMCU ESP8266 pin names located on the board and in documentation don't correspond to actual ESP8266 pin numbers, which is another thing that confused me.

Was able to get connections between the two boards right using the following mappings:

  • USB Host Shield to ESP8266 pin mappings, available here
  • HiLetgo NodeMCU ESP8266 pin to onboard name mappings, available here

I also connected both ESP8266 and USB Host Shield to an external 5V power supply (before I was only connecting USB Host Shield to external 5V power supply).

Following are pictures of my most up-to-date working setup.

img_1675

img_1674

Thanks for the help!

@dvit007
Copy link

dvit007 commented Jan 2, 2022

Hi!
For a long time I could not understand why USB Host mini does not work.
Didn't pass SPI test.
Everything worked when I connected the Reset pin to + 3.3v.
Maybe this will help you.

http://i.imgur.com/yhIApGT.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants