Headless pi zero HID keyboard

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1














I am trying to get my pi zero to act as a HID USB keyboard when plugged in to a computer, following this guide.



I finished the configuration, and I get to the "Keyboard / Mouse / Joystick (HID)" section. I added these commands to the bottom of /etc/rc.local:



sudo echo -ne "x4" > /dev/hidg0
sudo echo -ne "" > /dev/hidg0


When I plug the pi zero into the target computer, it recognizes the USB device, as shown by dmesg:



[26919.807536] usb 1-1: new high-speed USB device number 48 using xhci_hcd
[26919.828689] usb 1-1: New USB device found, idVendor=1d6b, idProduct=0104
[26919.828698] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[26919.828704] usb 1-1: Product: iSticktoit.net USB Device
[26919.828709] usb 1-1: Manufacturer: Tobias Girstmair
[26919.828713] usb 1-1: SerialNumber: fedcba9876543210
[26919.831132] input: Tobias Girstmair iSticktoit.net USB Device as /devices/pci0000:00/0000:00:15.0/usb1/1-1/1-1:1.0/0003:1D6B:0104.0007/input/input21
[26919.888595] hid-generic 0003:1D6B:0104.0007: input,hidraw1: USB HID v1.01 Keyboard [Tobias Girstmair iSticktoit.net USB Device] on usb-0000:00:15.0-1/input0


But the computer does not receive any keystrokes at all. I am really struggling to figure this out, and I would apreciate any help. Thanks!










share|improve this question

















  • 1




    Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. Following the recommendation of the developers from systemd you should avoid using it. Maybe writing to /dev/hidg0 comes to early?
    – Ingo
    Dec 15 at 19:09










  • @Ingo Thanks for the suggestion. How would you recommend I do it instead? I was thinking maybe cron, but that might also come too early.
    – eeze
    Dec 15 at 19:23










  • I have made an answer.
    – Ingo
    Dec 15 at 19:45















1














I am trying to get my pi zero to act as a HID USB keyboard when plugged in to a computer, following this guide.



I finished the configuration, and I get to the "Keyboard / Mouse / Joystick (HID)" section. I added these commands to the bottom of /etc/rc.local:



sudo echo -ne "x4" > /dev/hidg0
sudo echo -ne "" > /dev/hidg0


When I plug the pi zero into the target computer, it recognizes the USB device, as shown by dmesg:



[26919.807536] usb 1-1: new high-speed USB device number 48 using xhci_hcd
[26919.828689] usb 1-1: New USB device found, idVendor=1d6b, idProduct=0104
[26919.828698] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[26919.828704] usb 1-1: Product: iSticktoit.net USB Device
[26919.828709] usb 1-1: Manufacturer: Tobias Girstmair
[26919.828713] usb 1-1: SerialNumber: fedcba9876543210
[26919.831132] input: Tobias Girstmair iSticktoit.net USB Device as /devices/pci0000:00/0000:00:15.0/usb1/1-1/1-1:1.0/0003:1D6B:0104.0007/input/input21
[26919.888595] hid-generic 0003:1D6B:0104.0007: input,hidraw1: USB HID v1.01 Keyboard [Tobias Girstmair iSticktoit.net USB Device] on usb-0000:00:15.0-1/input0


But the computer does not receive any keystrokes at all. I am really struggling to figure this out, and I would apreciate any help. Thanks!










share|improve this question

















  • 1




    Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. Following the recommendation of the developers from systemd you should avoid using it. Maybe writing to /dev/hidg0 comes to early?
    – Ingo
    Dec 15 at 19:09










  • @Ingo Thanks for the suggestion. How would you recommend I do it instead? I was thinking maybe cron, but that might also come too early.
    – eeze
    Dec 15 at 19:23










  • I have made an answer.
    – Ingo
    Dec 15 at 19:45













1












1








1







I am trying to get my pi zero to act as a HID USB keyboard when plugged in to a computer, following this guide.



I finished the configuration, and I get to the "Keyboard / Mouse / Joystick (HID)" section. I added these commands to the bottom of /etc/rc.local:



sudo echo -ne "x4" > /dev/hidg0
sudo echo -ne "" > /dev/hidg0


When I plug the pi zero into the target computer, it recognizes the USB device, as shown by dmesg:



[26919.807536] usb 1-1: new high-speed USB device number 48 using xhci_hcd
[26919.828689] usb 1-1: New USB device found, idVendor=1d6b, idProduct=0104
[26919.828698] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[26919.828704] usb 1-1: Product: iSticktoit.net USB Device
[26919.828709] usb 1-1: Manufacturer: Tobias Girstmair
[26919.828713] usb 1-1: SerialNumber: fedcba9876543210
[26919.831132] input: Tobias Girstmair iSticktoit.net USB Device as /devices/pci0000:00/0000:00:15.0/usb1/1-1/1-1:1.0/0003:1D6B:0104.0007/input/input21
[26919.888595] hid-generic 0003:1D6B:0104.0007: input,hidraw1: USB HID v1.01 Keyboard [Tobias Girstmair iSticktoit.net USB Device] on usb-0000:00:15.0-1/input0


But the computer does not receive any keystrokes at all. I am really struggling to figure this out, and I would apreciate any help. Thanks!










share|improve this question













I am trying to get my pi zero to act as a HID USB keyboard when plugged in to a computer, following this guide.



I finished the configuration, and I get to the "Keyboard / Mouse / Joystick (HID)" section. I added these commands to the bottom of /etc/rc.local:



sudo echo -ne "x4" > /dev/hidg0
sudo echo -ne "" > /dev/hidg0


When I plug the pi zero into the target computer, it recognizes the USB device, as shown by dmesg:



[26919.807536] usb 1-1: new high-speed USB device number 48 using xhci_hcd
[26919.828689] usb 1-1: New USB device found, idVendor=1d6b, idProduct=0104
[26919.828698] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[26919.828704] usb 1-1: Product: iSticktoit.net USB Device
[26919.828709] usb 1-1: Manufacturer: Tobias Girstmair
[26919.828713] usb 1-1: SerialNumber: fedcba9876543210
[26919.831132] input: Tobias Girstmair iSticktoit.net USB Device as /devices/pci0000:00/0000:00:15.0/usb1/1-1/1-1:1.0/0003:1D6B:0104.0007/input/input21
[26919.888595] hid-generic 0003:1D6B:0104.0007: input,hidraw1: USB HID v1.01 Keyboard [Tobias Girstmair iSticktoit.net USB Device] on usb-0000:00:15.0-1/input0


But the computer does not receive any keystrokes at all. I am really struggling to figure this out, and I would apreciate any help. Thanks!







usb pi-zero headless gadget hid






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 15 at 17:43









eeze

1063




1063







  • 1




    Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. Following the recommendation of the developers from systemd you should avoid using it. Maybe writing to /dev/hidg0 comes to early?
    – Ingo
    Dec 15 at 19:09










  • @Ingo Thanks for the suggestion. How would you recommend I do it instead? I was thinking maybe cron, but that might also come too early.
    – eeze
    Dec 15 at 19:23










  • I have made an answer.
    – Ingo
    Dec 15 at 19:45












  • 1




    Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. Following the recommendation of the developers from systemd you should avoid using it. Maybe writing to /dev/hidg0 comes to early?
    – Ingo
    Dec 15 at 19:09










  • @Ingo Thanks for the suggestion. How would you recommend I do it instead? I was thinking maybe cron, but that might also come too early.
    – eeze
    Dec 15 at 19:23










  • I have made an answer.
    – Ingo
    Dec 15 at 19:45







1




1




Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. Following the recommendation of the developers from systemd you should avoid using it. Maybe writing to /dev/hidg0 comes to early?
– Ingo
Dec 15 at 19:09




Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. Following the recommendation of the developers from systemd you should avoid using it. Maybe writing to /dev/hidg0 comes to early?
– Ingo
Dec 15 at 19:09












@Ingo Thanks for the suggestion. How would you recommend I do it instead? I was thinking maybe cron, but that might also come too early.
– eeze
Dec 15 at 19:23




@Ingo Thanks for the suggestion. How would you recommend I do it instead? I was thinking maybe cron, but that might also come too early.
– eeze
Dec 15 at 19:23












I have made an answer.
– Ingo
Dec 15 at 19:45




I have made an answer.
– Ingo
Dec 15 at 19:45










1 Answer
1






active

oldest

votes


















2














I don't know if this helps but it reduces one possible source of error. Doing what the developers from systemd suggest is using a Unit file. Here is a very generic one for your problem. Create a new unit file with:



rpi ~$ sudo systemctl edit --force --full hid-keyboard.service


In the empty editor insert these statements, save them and quit the editor:



[Unit]
Description=HID keyboard emulator
After=multi-user.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c 'echo -ne "x4" > /dev/hidg0'
ExecStart=/bin/bash -c 'echo -ne "" > /dev/hidg0'

[Install]
WantedBy=multi-user.target


Enable the new service with:



rpi ~$ sudo systemctl enable hid-keyboard.service


On boot/startup/poweron it is executed one time. You can manual restart it and show its status with



rpi ~$ sudo systemctl restart hid-keyboard.service
rpi ~$ sudo systemctl status hid-keyboard.service





share|improve this answer






















  • "On reboot it should be executed one time." Does this mean it will only work when I reboot with reboot, or will it also run on startup, if I plug it in to power?
    – eeze
    Dec 15 at 19:53










  • I tried the steps in the answer, and still nothing happens
    – eeze
    Dec 15 at 19:55










  • @eeze I have updated my answer about reboot. I suspected that nothing happens. I had just a quick view at the tutorial you have linked. Just on Step 0 I stopped reading. The tutorial is made for Raspbian Jessie so it seems a bit outdated. Do you use Jessie? I wouldn't like to investigate it anymore.
    – Ingo
    Dec 15 at 20:35










  • Alright, thanks for the help. I will look more into it. Thanks again for the help!
    – eeze
    Dec 15 at 20:42











Your Answer






StackExchange.ifUsing("editor", function ()
return StackExchange.using("schematics", function ()
StackExchange.schematics.init();
);
, "cicuitlab");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "447"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fraspberrypi.stackexchange.com%2fquestions%2f91953%2fheadless-pi-zero-hid-keyboard%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














I don't know if this helps but it reduces one possible source of error. Doing what the developers from systemd suggest is using a Unit file. Here is a very generic one for your problem. Create a new unit file with:



rpi ~$ sudo systemctl edit --force --full hid-keyboard.service


In the empty editor insert these statements, save them and quit the editor:



[Unit]
Description=HID keyboard emulator
After=multi-user.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c 'echo -ne "x4" > /dev/hidg0'
ExecStart=/bin/bash -c 'echo -ne "" > /dev/hidg0'

[Install]
WantedBy=multi-user.target


Enable the new service with:



rpi ~$ sudo systemctl enable hid-keyboard.service


On boot/startup/poweron it is executed one time. You can manual restart it and show its status with



rpi ~$ sudo systemctl restart hid-keyboard.service
rpi ~$ sudo systemctl status hid-keyboard.service





share|improve this answer






















  • "On reboot it should be executed one time." Does this mean it will only work when I reboot with reboot, or will it also run on startup, if I plug it in to power?
    – eeze
    Dec 15 at 19:53










  • I tried the steps in the answer, and still nothing happens
    – eeze
    Dec 15 at 19:55










  • @eeze I have updated my answer about reboot. I suspected that nothing happens. I had just a quick view at the tutorial you have linked. Just on Step 0 I stopped reading. The tutorial is made for Raspbian Jessie so it seems a bit outdated. Do you use Jessie? I wouldn't like to investigate it anymore.
    – Ingo
    Dec 15 at 20:35










  • Alright, thanks for the help. I will look more into it. Thanks again for the help!
    – eeze
    Dec 15 at 20:42
















2














I don't know if this helps but it reduces one possible source of error. Doing what the developers from systemd suggest is using a Unit file. Here is a very generic one for your problem. Create a new unit file with:



rpi ~$ sudo systemctl edit --force --full hid-keyboard.service


In the empty editor insert these statements, save them and quit the editor:



[Unit]
Description=HID keyboard emulator
After=multi-user.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c 'echo -ne "x4" > /dev/hidg0'
ExecStart=/bin/bash -c 'echo -ne "" > /dev/hidg0'

[Install]
WantedBy=multi-user.target


Enable the new service with:



rpi ~$ sudo systemctl enable hid-keyboard.service


On boot/startup/poweron it is executed one time. You can manual restart it and show its status with



rpi ~$ sudo systemctl restart hid-keyboard.service
rpi ~$ sudo systemctl status hid-keyboard.service





share|improve this answer






















  • "On reboot it should be executed one time." Does this mean it will only work when I reboot with reboot, or will it also run on startup, if I plug it in to power?
    – eeze
    Dec 15 at 19:53










  • I tried the steps in the answer, and still nothing happens
    – eeze
    Dec 15 at 19:55










  • @eeze I have updated my answer about reboot. I suspected that nothing happens. I had just a quick view at the tutorial you have linked. Just on Step 0 I stopped reading. The tutorial is made for Raspbian Jessie so it seems a bit outdated. Do you use Jessie? I wouldn't like to investigate it anymore.
    – Ingo
    Dec 15 at 20:35










  • Alright, thanks for the help. I will look more into it. Thanks again for the help!
    – eeze
    Dec 15 at 20:42














2












2








2






I don't know if this helps but it reduces one possible source of error. Doing what the developers from systemd suggest is using a Unit file. Here is a very generic one for your problem. Create a new unit file with:



rpi ~$ sudo systemctl edit --force --full hid-keyboard.service


In the empty editor insert these statements, save them and quit the editor:



[Unit]
Description=HID keyboard emulator
After=multi-user.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c 'echo -ne "x4" > /dev/hidg0'
ExecStart=/bin/bash -c 'echo -ne "" > /dev/hidg0'

[Install]
WantedBy=multi-user.target


Enable the new service with:



rpi ~$ sudo systemctl enable hid-keyboard.service


On boot/startup/poweron it is executed one time. You can manual restart it and show its status with



rpi ~$ sudo systemctl restart hid-keyboard.service
rpi ~$ sudo systemctl status hid-keyboard.service





share|improve this answer














I don't know if this helps but it reduces one possible source of error. Doing what the developers from systemd suggest is using a Unit file. Here is a very generic one for your problem. Create a new unit file with:



rpi ~$ sudo systemctl edit --force --full hid-keyboard.service


In the empty editor insert these statements, save them and quit the editor:



[Unit]
Description=HID keyboard emulator
After=multi-user.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c 'echo -ne "x4" > /dev/hidg0'
ExecStart=/bin/bash -c 'echo -ne "" > /dev/hidg0'

[Install]
WantedBy=multi-user.target


Enable the new service with:



rpi ~$ sudo systemctl enable hid-keyboard.service


On boot/startup/poweron it is executed one time. You can manual restart it and show its status with



rpi ~$ sudo systemctl restart hid-keyboard.service
rpi ~$ sudo systemctl status hid-keyboard.service






share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 15 at 20:11

























answered Dec 15 at 19:44









Ingo

5,5812633




5,5812633











  • "On reboot it should be executed one time." Does this mean it will only work when I reboot with reboot, or will it also run on startup, if I plug it in to power?
    – eeze
    Dec 15 at 19:53










  • I tried the steps in the answer, and still nothing happens
    – eeze
    Dec 15 at 19:55










  • @eeze I have updated my answer about reboot. I suspected that nothing happens. I had just a quick view at the tutorial you have linked. Just on Step 0 I stopped reading. The tutorial is made for Raspbian Jessie so it seems a bit outdated. Do you use Jessie? I wouldn't like to investigate it anymore.
    – Ingo
    Dec 15 at 20:35










  • Alright, thanks for the help. I will look more into it. Thanks again for the help!
    – eeze
    Dec 15 at 20:42

















  • "On reboot it should be executed one time." Does this mean it will only work when I reboot with reboot, or will it also run on startup, if I plug it in to power?
    – eeze
    Dec 15 at 19:53










  • I tried the steps in the answer, and still nothing happens
    – eeze
    Dec 15 at 19:55










  • @eeze I have updated my answer about reboot. I suspected that nothing happens. I had just a quick view at the tutorial you have linked. Just on Step 0 I stopped reading. The tutorial is made for Raspbian Jessie so it seems a bit outdated. Do you use Jessie? I wouldn't like to investigate it anymore.
    – Ingo
    Dec 15 at 20:35










  • Alright, thanks for the help. I will look more into it. Thanks again for the help!
    – eeze
    Dec 15 at 20:42
















"On reboot it should be executed one time." Does this mean it will only work when I reboot with reboot, or will it also run on startup, if I plug it in to power?
– eeze
Dec 15 at 19:53




"On reboot it should be executed one time." Does this mean it will only work when I reboot with reboot, or will it also run on startup, if I plug it in to power?
– eeze
Dec 15 at 19:53












I tried the steps in the answer, and still nothing happens
– eeze
Dec 15 at 19:55




I tried the steps in the answer, and still nothing happens
– eeze
Dec 15 at 19:55












@eeze I have updated my answer about reboot. I suspected that nothing happens. I had just a quick view at the tutorial you have linked. Just on Step 0 I stopped reading. The tutorial is made for Raspbian Jessie so it seems a bit outdated. Do you use Jessie? I wouldn't like to investigate it anymore.
– Ingo
Dec 15 at 20:35




@eeze I have updated my answer about reboot. I suspected that nothing happens. I had just a quick view at the tutorial you have linked. Just on Step 0 I stopped reading. The tutorial is made for Raspbian Jessie so it seems a bit outdated. Do you use Jessie? I wouldn't like to investigate it anymore.
– Ingo
Dec 15 at 20:35












Alright, thanks for the help. I will look more into it. Thanks again for the help!
– eeze
Dec 15 at 20:42





Alright, thanks for the help. I will look more into it. Thanks again for the help!
– eeze
Dec 15 at 20:42


















draft saved

draft discarded
















































Thanks for contributing an answer to Raspberry Pi Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fraspberrypi.stackexchange.com%2fquestions%2f91953%2fheadless-pi-zero-hid-keyboard%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?