Throughout my tests, I found that you can ignore this warning message and your Pi Zero works as a keyboard without any additional configuration or drivers installation. Sometimes you might see this warning message saying “USB device not recognized”. Let’s test it, if you plug the Pi Zero to Computer #1, after a few seconds you’ll see an alert message or sound that indicates that a keyboard was connected successfully. Write_report(NULL_CHAR*2+chr(9)+NULL_CHAR*5) Write_report(NULL_CHAR*2+chr(8)+NULL_CHAR*5) Write_report(NULL_CHAR*2+chr(7)+NULL_CHAR*5) Write_report(NULL_CHAR*2+chr(6)+NULL_CHAR*5) Write_report(NULL_CHAR*2+chr(5)+NULL_CHAR*5) Write_report(NULL_CHAR*2+chr(4)+NULL_CHAR*5) That micro USB will both power the Pi Zero and act as a keyboard to the connected computer.Įstablish an SSH connection with your Pi and use the next command to create a new Python script: $ nano RPi_Keyboard_Example.pyĬopy and paste the next Python script to your Raspberry Pi. Here’s how your file should look like in the end (to save the file, press Ctrl+X followed by Y and Enter):Īfter preparing your Raspberry Pi Zero, connect it to a laptop or desktop computer through the micro USB port that is used for data and peripherals. Leave the default values, but you could even change the serial number, manufacturer and product name to fit your specific needs. Open the file with: $ sudo nano /usr/bin/isticktoit_usb Here’s how your file should look like (to save the file, press Ctrl+X followed by Y and Enter):įor this project, we will turn the Raspberry Pi into a USB keyboard, but you could make it work as a Serial adapter, Ethernet adapter, and Mass Storage. Then, you need to run this script automatically at startup. Open /etc/rc.local with this command: $ sudo nano /etc/rc.localĪdd the following before the line containing exit 0: /usr/bin/isticktoit_usb # libcomposite configuration Create a new file called isticktoit_usb in /usr/bin/ and make it executable: $ sudo touch $ sudo chmod +x /usr/bin/isticktoit_usb The configuration is volatile, so it must run on each startup. The configuration is done via ConfigFS, a virtual file system located in /sys/. Now, you have to define your Pi Zero (HID gadget) as a USB keyboard. First, you need to run these three commands to enable the necessary modules and drivers: $ echo "dtoverlay=dwc2" | sudo tee -a $ echo "dwc2" | sudo tee -a $ sudo echo "libcomposite" | sudo tee -a /etc/modules 2. These next steps to prepare the Pi Zero board are based on the instructions from iSticktoit. Important: this tutorial doesn’t work with a Raspberry Pi 3 board. Parts Requiredįor this project you’ll need a Raspberry Pi Zero board. I recommend that you download my course: Build a Home Automation System for $100. If you like home automation and you want to learn more about Node-RED, Raspberry Pi, ESP8266 and Arduino. You should have the Raspbian operating system installed in your Raspberry Pi – read Installing Raspbian Lite, Enabling and Connecting with SSH.You should be familiar with the Raspberry Pi – read Getting Started with Raspberry Pi. After following some simple steps, you can write a Python script to make your Pi act as a USB keyboard. In this project you’ll learn how to turn a Raspberry Pi Zero board into a USB keyboard or HID (Human Interface Device).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |