Hey there folks,
I try to use Arduino with ATMega32U4 microcontroller to control minipc behavior based on ON/OFF toggle switch. While in OS I can control computer using script that will shut it down based on keyboard shortcut but I have problem to turn it back on.
By default BIOS allow to wake/power on by using ALT+P shortcut which works like charm using regular USB keyboard. My idea was to use it on Arduino to change switch to ON that will emulate ALT+P press via HID to make PC boot but unfortunately it does not work as planned
I checked my code and it works while being in OS or even in BIOS setup screen - so only when computer is already on. Unfortunately not while it's off. Arduino is powered from USB but it's stuck in some kind of a weird state that RX led is on for the whole time and it does not react. If I power PC on led light disappears and then it works as intended. I even tried to use USBSerPassThruLine but that does not change a thing.
Am I missing something or what might be wrong?
I could imagine that a specific Arduino USB driver is required on the PC, as installed during IDE installation. Such a driver is available only after system boot. Then it's a PC thingy, not an Arduino issue.
DrDiettrich:
I could imagine that a specific Arduino USB driver is required on the PC, as installed during IDE installation. Such a driver is available only after system boot. Then it's a PC thingy, not an Arduino issue.
no. boot keyboard is a different HID profile. it is Arduino library thingy
Juraj:
GitHub - NicoHood/HID: Bring enhanced HID functions to your Arduino!
I added this lib but no change at all.
drunkenpl:
I added this lib but no change at all.
read the doc, see the examples
I checked and tried example with BootKeyboard and ImprovedKeyboard but none of them worked and with TeensyKeyboard example - it doesn't even work... Shows error while compiling xD
drunkenpl:
I checked and tried example with BootKeyboard and ImprovedKeyboard but none of them worked and with TeensyKeyboard example - it doesn't even work... Shows error while compiling xD
what error?
'TeensyKeyboard' was not declared in this scope
Just to be clear - I though I am missing Teensy USB keyboard addon so I installed it but still the same error.
did you try the BootKeyboard example?
I did, no luck I also found this thread where it acts more less the same way:
https://forum.arduino.cc/index.php?topic=386491.0
It seems that I have to get more deep into Teensyduino to make it work.
if it is a Teensy with 32u4 doesn't it work as Arduino Micro?
I have no clue what AVR Teensy uses. I just order one from Aliexpress and keep my fingers crossed to have it working.
I also though about different approach - I could solder an Arduino pin to gnd of Lenovo's power switch and send short signal to turn it on. The problem is that this way I can also turn it off while switching to ON position so I have to somehow distinguish power on-off state of PC. Unfortunately I have no clue how could I inform Arduino whether PC is off or on without using additional hardware
drunkenpl:
I have no clue what AVR Teensy uses. I just order one from Aliexpress and keep my fingers crossed to have it working.
I also though about different approach - I could solder an Arduino pin to gnd of Lenovo's power switch and send short signal to turn it on. The problem is that this way I can also turn it off while switching to ON position so I have to somehow distinguish power on-off state of PC. Unfortunately I have no clue how could I inform Arduino whether PC is off or on without using additional hardware
try to select Arduno Micro as board for the BootKeyboard example
Teensy from Aliexpress?
I just picked Arduino Micro for BootKeyboard and added:
BootKeyboard.press(KEY_LEFT_ALT);
BootKeyboard.press('p');
delay(50);
BootKeyboard.releaseAll();
still nothing.
Those are Teensy cheap clones
What if you release the keys in reverse order:
BootKeyboard.release('p');
BootKeyboard.release(KEY_LEFT_ALT);
Nothing
Just to confirm - it works in system but not in sleep state.
I purchased Teensy clone from AliExpress and wrote simple code to test it.
IT WORKS!!! Plain IDE and Teensyduino add-in without any additional libraries and simple Keyboard.press(); function works for my system.
Thanks for all of your support!