Headless pi zero HID keyboard











up vote
1
down vote

favorite












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







New contributor




eeze is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 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
    3 hours ago










  • @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
    3 hours ago










  • I have made an answer.
    – Ingo
    3 hours ago















up vote
1
down vote

favorite












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







New contributor




eeze is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 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
    3 hours ago










  • @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
    3 hours ago










  • I have made an answer.
    – Ingo
    3 hours ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











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







New contributor




eeze is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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







New contributor




eeze is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




eeze is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




eeze is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 5 hours ago









eeze

1063




1063




New contributor




eeze is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





eeze is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






eeze is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 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
    3 hours ago










  • @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
    3 hours ago










  • I have made an answer.
    – Ingo
    3 hours ago














  • 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
    3 hours ago










  • @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
    3 hours ago










  • I have made an answer.
    – Ingo
    3 hours ago








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
3 hours ago




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
3 hours ago












@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
3 hours ago




@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
3 hours ago












I have made an answer.
– Ingo
3 hours ago




I have made an answer.
– Ingo
3 hours ago










1 Answer
1






active

oldest

votes

















up vote
2
down vote













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
    3 hours ago










  • I tried the steps in the answer, and still nothing happens
    – eeze
    3 hours ago










  • @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
    2 hours ago










  • Alright, thanks for the help. I will look more into it. Thanks again for the help!
    – eeze
    2 hours ago













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',
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
});


}
});






eeze is a new contributor. Be nice, and check out our Code of Conduct.










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








up vote
2
down vote













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
    3 hours ago










  • I tried the steps in the answer, and still nothing happens
    – eeze
    3 hours ago










  • @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
    2 hours ago










  • Alright, thanks for the help. I will look more into it. Thanks again for the help!
    – eeze
    2 hours ago

















up vote
2
down vote













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
    3 hours ago










  • I tried the steps in the answer, and still nothing happens
    – eeze
    3 hours ago










  • @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
    2 hours ago










  • Alright, thanks for the help. I will look more into it. Thanks again for the help!
    – eeze
    2 hours ago















up vote
2
down vote










up vote
2
down vote









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 2 hours ago

























answered 3 hours ago









Ingo

5,3172632




5,3172632












  • "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
    3 hours ago










  • I tried the steps in the answer, and still nothing happens
    – eeze
    3 hours ago










  • @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
    2 hours ago










  • Alright, thanks for the help. I will look more into it. Thanks again for the help!
    – eeze
    2 hours ago




















  • "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
    3 hours ago










  • I tried the steps in the answer, and still nothing happens
    – eeze
    3 hours ago










  • @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
    2 hours ago










  • Alright, thanks for the help. I will look more into it. Thanks again for the help!
    – eeze
    2 hours ago


















"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
3 hours ago




"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
3 hours ago












I tried the steps in the answer, and still nothing happens
– eeze
3 hours ago




I tried the steps in the answer, and still nothing happens
– eeze
3 hours ago












@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
2 hours ago




@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
2 hours ago












Alright, thanks for the help. I will look more into it. Thanks again for the help!
– eeze
2 hours ago






Alright, thanks for the help. I will look more into it. Thanks again for the help!
– eeze
2 hours ago












eeze is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















eeze is a new contributor. Be nice, and check out our Code of Conduct.













eeze is a new contributor. Be nice, and check out our Code of Conduct.












eeze is a new contributor. Be nice, and check out our Code of Conduct.
















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

Quarter-circle Tiles

build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

Mont Emei