Close

M5StickC

A project log for RemuterMCS

Remote control for muting and unmuting the microphone, camera, and speakers

wjcarpenterWJCarpenter 03/03/2021 at 03:390 Comments

At this point in my thinking, I was pretty solid on wanting a wireless solution, and using something that acted like a keyboard seemed promising when married with AutoHotKey. The natural DIY solution was an  ESP32 because of its in-built wifi and Bluetooth. One of those in a nice little case with some buttons outside and battery inside sounded about right. But, hey, wait ... I've already got something like that. M5Stack's M5StickC.

It's got a 95 mAh LiPo battery, a USB C charge/serial port, a 160x80 TFT display, a couple of buttons, and some other goodies that might or might not be interesting for this use case. You can get these for US$10-15, and I already have a couple right here. I've done some experimenting with them and found them pretty easy to work with. The M5Stack company's documentation and examples are pretty good.

It's about the size of 2 LEGO bricks stacked on top of each other. If that's too small for your hand, or if you want more battery life, M5Stack also sells the M5StickC 18650C, which is a sort of wand with a LiPo battery into which the M5StickC can be fitted.

Sometimes the simplest-seeming things hide considerable complexity. If you use the USB C port or run the Bluetooth samples from M5Stack, they both act as simple serial communicators. I can remember back in the days before USB and PS/2 connectors when some keyboards just sent characters over an RS232-like connection. You typed a character, and it sent that character. If you held down the Control key and typed a character, it sent a control character (or nothing if the key you pressed was in the wrong place in the ASCII table). If you held down the Alt key and typed a character, it sent the character with the high bit set. Times were simple, indeed.

With the advent of USB standards, or maybe a little before, keyboards and mice were specifically recognized as those kinds of Human Interface Devices (HIDs), and they spoke a more elaborate protocol that allowed for more flexible interactions over a standardized protocol. A keyboard sends what is commonly called a "scan code", which generally represents a particular physical key. Along with that scan code, it also sends the current state of modifier keys like Control, Alt, Shift, charm, spin, damage, health, and ... (wait, that can't be right).

What all this means is that you can't just feed characters over a serial connection and expect things to work on a modern PC. Luckily, there is an Arduino USB keyboard library, and someone called T-vK has taken the trouble to adapt that into an ESP32 BLE Keyboard library. I've tried that BLE keyboard library with the M5StickC for enough to know that it gets recognized as a keyboard and can send characters to the PC it's paired with.

Discussions