Now that I have the touch screen fitted in the Kitchen, I needed a convenient way to wake the tablet. I was hoping that just swiping the screen would wake it up, but unfortunately not.
After a little bit of internet searching, I came across a blog entry on dotmana.com. The site goes through the steps to create a motion detector to wake the screen, using a Arduino and PIR sensor. This was almost perfect, except it would not work when the tablet was sleeping.
I picked up the bits I needed from Ebay and Amazon, listed below:
- Arduino Pro Micro Leonardo (I would get a pre soldered one!)
- HC-SR501 Adjust IR Pyroelectric Infrared PIR Motion Sensor Detector Module
- Female to Female Connector Cables
A little more searching, I came across this post on Arduino forum. The post goes into detail on how to update the USBCore.h to enable the HID Keyboard driver, this then supports the 'Allow this device to wake computer' option in Device Manager.
Once this was done it was just a case of updating the code that monitors the PIR sensor, then send the keyboard command to wake the screen/pc. Code is from dotmana.com. I just made a change to include the USBDevice.wakeupHost(), so that it will also wake the pc when sleeping. It was nice to play with a little c++.
int sensorPin = 10;
void setup()
{
pinMode(sensorPin, INPUT);
Serial.begin(9600);
}
void sendWakeUp(void);
void loop()
{
if (digitalRead(sensorPin) == 1)
{
sendWakeUp();
while (digitalRead(sensorPin) == 1)
{
delay(1000);
}
}
delay(1000);
}
void sendWakeUp(void)
{
USBDevice.wakeupHost();
Keyboard.press(KEY_LEFT_CTRL);
delay(1);
Keyboard.release(KEY_LEFT_CTRL);
}
Construction steps below.
Parts all soldered, wired and configured, ready to be assembled
All assembled
Finished unit ready to be installed
Project complete, now whenever you get close to the tablet it wakes the screen, regardless of whether it's sleeping or not.