Auteur Rémi Sarrailh (µsini) | Dernière modification 9/11/2020 par Madnerd
arduino, esp8266, esp32, usb host, clavier, souris, manette, xbox, MIDI Brancher_des_périphériques_USB_sur_un_ESP8266_usbhost_wiki.jpg fr none Technique 0
Je jouais avec Mozzi, une bibliothèque de synthèse audio (https://sensorium.github.io/Mozzi/), quand je me suis rendu compte que si je voulais vraiment pouvoir exploiter tout le potentiel de cette bibliothèque, j'allais devoir faire un contrôleur.
Si seulement, je pouvais brancher un clavier, ou un contrôleur midi, ça serait carrément plus simplement ! Mais attends ?! C'est possible en fait!
Youtube
Merci à CircuitatHome pour la création de l'USB Host https://www.circuitsathome.com/usb-host-shield-hardware-manual/
Dans ce tutoriel nous allons utilisé un clone de l'USB Host Mini.
La puce sur celle-ci est un MAX3421E qui ne fonctionne quand 3.3v
Si vous voulez utiliser un microcontrôleur en 5v (comme l'Arduino Uno / Nano) utiliser le Shield USB Host plutôt.
Malheureusement avant de pouvoir brancher notre USB Host, il va nous falloir régler plusieurs problèmes sinon cela ne marchera pas.
If you buy a clone of the USB Host Mini, there is no jumper for VBUS.This means your USB devices will be powered with 3.3v, which didn't works with any of my devices who all require 5V.
You can find more details here: https://ht-deko.com/arduino/shield_usbhost_mini.html (in japanese)
You will have to cut this trace, to fix this.I used a small screw driver to do this, but you probably should use a small cutter instead.
OK, I hope you didn't break your board! Now it is time to plug it!
I used a Wemos Mini D1 with my USB Host Mini device, here is how to plug it.
You may have notice SS (Chip Select/CS) is plugged on D3 instead of D8.
I run into an issue where the USB Host set my Wemos Mini in firmware flashing mode, which stop the sketch from running.https://github.com/felis/USB_Host_Shield_2.0/issues/457
In order to change the SS pin, we need to change a line in the library.
Download USB Host Shield Library 2.0
Open UsbCore.h in libraries/USB_Host_Shield_Library_2.0 and change this line
#elif defined(ESP8266)typedef MAX3421e<P15, P5> MAX3421E; // ESP8266 boards
With this line
#elif defined(ESP8266)typedef MAX3421e<P0, P5> MAX3421E; // ESP8266 boards
Notice we used P0 instead of D3, it is because GPIO0 is D3 on the Wemos Mini.https://escapequotes.net/esp8266-wemos-d1-mini-pins-and-diagram/
OK, we are almost done, if you try to compile an example from the library, it will not works.
Note : This was recently fix, so this step is only required if your version of USB Host Shield Library 2.0 is 1.3.2 or lower.
It is because the library is not compatible with Arduino ESP8266 2.5, you need to downgrade it to 2.4.2https://github.com/felis/USB_Host_Shield_2.0/issues/449
Go to Tools / Boards / Boards Manager and change your version to 2.4.2.
There is a lot of examples in USB Host Shield Library 2.0In order to test that everything is working correctly, you should first try USB_desc.
Note: You can't hot-plug your USB device (at least in the examples), you need to reset the board each times you unplug, plug your device.
You should see a message like this:
If you have an XBOX360 for PC, use the example XBOX/XBOXUSB
I didn't manage to make my mouse works.The example is in HID/USBHIDBootMouse
Open USBH_MIDI/USBH_MIDI_dump example
Most Midi devices, will only use a small part of the buffer (bufMidi)
00001679: 64: 09 90 2F 13 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000174A: 64: 08 80 2F 7F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Using USB devices open up a lot of possibilities for our microcontroller, we only touch the surface of all the thing we can do with this USB Host device.
Draft
Vous avez entré un nom de page invalide, avec un ou plusieurs caractères suivants :
< > @ ~ : * € £ ` + = / \ | [ ] { } ; ? #