I’ve had several request how I unlock and lock my iPad dashboard remotely. I used an old Pad2 that needed an new connector, so when I opened the iPad, I directly soldered a wire to the smart cover magnetic hall sensor to unlock. But opening an iPad is a real pain, and there are better wireless non-intrusive solutions. One solution is to emulate an Bluetooth keyboard and send lock and unlock key shortcuts to it.
I’ve written an firmware for a cheap ESP32 module, no need for soldering. it uses Homeyduino. I put the source code opensource on Github:
There’s somewhere a bug that (I think) causes an stack overflow if you hammer too much bluetooth commands in a short time to it. I think the bug is somewhere in the Bluetooth or BLE library. If a more experienced developer has some spare time, please review the code on errors.
(It automatically resets the ESP32 and reconnects immediately, so it’s not really a problem but it would be nice to fix it) If you want to collaborate on this project please feel free to contact me, and ill be happy to add you to the Github repository.
EDIT: Tried it with another ESP32, and that seems to work stable, so it might be a dodgy ESP32 that I used
Compatible with Android, Windows, Linux, iOS that support Bluetooth LE. (iPad 4 and higher, iPhone 4S and higher. (These support BLE))
This firmware is aimed to lock and unlock an iPad, but you can change the On / off setting in the firmware to whatever you want.
it uses a Space to unlock and CTRL+CMD+h to lock. (make sure automatic lock is turned of if you want Homey to control the locking and unlocking).
NOTE: keyboard shortcut CTRL+CMD+h to lock seems to be a specific iOS13 thing. Pre-ios 13 installations can use a different approach:
Let’s say you want to have the iPad on when somebody is in the room, and off when nobody’s there:
- Set the automatic lock on the iPad to 10 minutes. (or use a different timing if you want it to react faster)
- Create a Homey flow that fires every 9 minutes (or if you changed the timing in the first step, make it shorter than that)
- in the “AND” add “Motion sensor is on” or something like “It’s between 7:00 and 19:00”
- in the “THEN” add “Homey Bluetooth keyboard” “Turn on” or use a custom keystroke with the SendText action.
(screenshot is in Dutch)
- Compile and upload firmware to an ESP32.
- Connect ESP32 to Wifi network
- Connect iPad to HomeyBLE bluetooth device
- Add Homeyduino on Homey and add “Homey Bluetooth Keyboard”
Switch (on / off) locks and unlocks iOS devices.
You can also use actions in flows with “SendText” to let the ESP32 type a complete string of text.
Or… use “SendKey” to send a single (special) key. see key table below for supported keys. Or a single character.
“SendKey” keeps the key pressed (so you can send things like Alt+Ctrl+delete) So you need to send the SendKey RELEASE after the SendKeys to release the keys (with a second delay).
Otherwise it will automatically releases it after a 2 second timeout. Use only one keystroke per card.
This example first presses CMD+A (Select all text on iOS)
After that DELETE (Delete text)
It includes a wifi manager to connect to an wifi network. Just connect a phone to the “Homey Bluetooth Keyboard” network and fill in the credentials. (No hardcoding of credentials, so you don’t have to find the source code if you change the wifi network after a couple of years ;))
- KEY_RIGHT_GUI (= Apple “CMD” key)
- KEY_F1 to KEY_F24