MageGee Wireless Keyboard (TS92)

In the interest of improving ergonomics, I’ve been experimenting with different keyboard placements. I have some ideas about attaching keyboard to my chair instead of my desk, and a wireless keyboard would eliminate concerns about routing wires. Especially wires that could get pinched or rolled over when I move my chair. Since this is just a starting point for experimentation, I wanted something I could feel free to modify as ideas may strike. I looked for the cheapest and smallest wireless keyboard and found the MageGee TS92 Wireless Keyboard (Pink). (*)

This is a “60% keyboard” which is a phrase I’ve seen used two different ways. The first refers to physical size of individual keys, if they were smaller than those on a standard keyboard. The second way refers to the overall keyboard with fewer keys than the standard keyboard, but individual keys are still the same size as those on a standard keyboard. This is the latter: elimination of numeric keypad, arrow keys, etc. means this keyboard only has 61 keys, roughly 60% of standard keyboards which typically have 101 keys. But each key is still the normal size.

The lettering on these keys are… sufficient. Edges are blurry and not very crisp, and consistency varies. But the labels are readable so it’s fine. The length of travel on these keys are pretty good, much longer than a typical laptop keyboard, but the tactile feedback is poor. Consistent with cheap membrane keyboards, which of course this is.

Back side of the keyboard shows a nice touch: a slot to store the wireless USB dongle so it doesn’t get lost. There is also an on/off switch and, next to it, a USB Type-C port (not visible in picture, facing away from camera) for charging the onboard battery.

Looks pretty simple and straightforward, let’s open it up to see what’s inside.

I peeled off everything held with adhesives expecting some fasteners to be hidden underneath. I was surprised to find nothing. Is this thing glued together? Or held with clips?

I found my answer when I discovered that this thing had RGB LEDs. I did not intend to buy a light-up keyboard, but I have one now. The illumination showed screws hiding under keys.

There are six Philips-head self-tapping plastic screws hidden under keys distributed around the keyboard.

Once they were removed, keys assembly easily lifted away to expose the membrane underneath.

Underneath the membrane is the light-up subassembly. Looks like a row of LEDs across the top that shines onto a clear plastic sheet acting to diffuse and direct their light.

I count five LEDs, and the bumps molded into clear plastic sheet worked well to direct light where the keys are.

I had expected to see a single data wire consistent with NeoPixel a.k.a. WS2812 style of individually addressable RGB LEDs. But label of SCL and SDA implies this LED strip is controlled via I2C. If it were a larger array I would be interested in digging deeper with a logic analyzer, but a strip of just five LEDs isn’t interesting enough to me so I moved on.

Underneath the LED we see the battery, connected to a power control board (which has both the on/off switch and the Type-C charging port) feeding power to the mainboard.

Single cell lithium-polymer battery with claimed 2000mAh capacity.

The power control board is fascinating, because somebody managed to lay everything out on a single layer. Of course, they’re helped by the fact that this particular Type-C connector doesn’t break out all of the pins. Probably just a simple voltage divider requesting 5V, or maybe not even that! I hope that little chip at U1 labeled B5TE (or 85TE) is a real lithium-ion battery manage system (BMS) because I don’t see any other candidates and I don’t want a fiery battery.

The main board has fewer components but more traces, most of which led to the keyboard membrane. There appears to be two chips under blobs of epoxy, and a PCB antenna similar to others I’ve seen designed to work on 2.4GHz.

With easy disassembly and modular construction, I think it’ll be easy to modify this keyboard if ideas should strike. Or if I decide I don’t need a keyboard after all, that power subsystem would be easy (and useful!) for other projects.

(*) Disclosure: As an Amazon Associate I earn from qualifying purchases.

Resistors Negotiate 5V Power in USB Type C

Thanks to prompting by a comment, I am picking up where I left off trying to supply power over a USB-C cable. I love the idea of USB Power Delivery, the latest version covers transferring up to 240W over a USB Type-C cable. But that power also comes with complexity, and I didn’t want to figure out how to establish a power delivery contract when my project really just wanted five volts. Fortunately, the specification also describes a low-complexity way to manage 5V power over USB Type-C. But I had to be confident I was dealing with the correct wires, so I probed wiring with a small breakout board. (*) I confirmed that the four red wires were VBUS, the green and white wires were indeed the differential data pairs, and the mystery yellow wire is the VCONN or CC (cable configuration) wire on the same side.

Ah, yes, that “same side” was an interesting find. USB Type-C is physically shaped so there’s no “upside-down” way to insert the plug, with symmetric wires. However, that also means each side has a set of D+/D-/CC wires, and a USB Type-A to Type-C adapter only connects to one side. It is up to the Type-C device to check both sides.

In my previous experiment I learned that just connecting +5V to red and ground to black was enough to be recognized as a power source by some Type-C device but not my Pixel 3a phone. I found multiple guides that said to connect a 56kΩ pull-up resistor between CC and VBUS, but I wanted to know a little bit more without diving into the deep end of USB specifications. I found a very accessible post on Digi-Key forums describing the details of 5V @ 3A = 15W power over Type-C. Which is itself a simplified version of a much more complex Digi-Key overview of USB power.

Like several other guides, it mentioned the resistors on both ends of the Type-C cable, but it also had this phrase: “Together they form a voltage divider” which was my “A-ha!” moment. It allowed components to negotiate 5V power delivery without a digital communication protocol. We just need a resistor on either side: one for the provider to indicate the amount available, and the other by the consumer to indicate its desired consumption. Then we just need an ADC to measure voltage value of the resulting voltage divider, and we’ll know the safe power level.

When I added the 56kΩ pull-up resistor to my circuit, my Pixel 3a lit up with “Charging slowly”. I thought it was successfully charging at 500mA, but it wasn’t. Over the next half hour, its battery level actually dropped! I put the circuit under a USB power meter(*) and found it was only drawing a feeble 40mA. That meter also told me why: my circuit had supplied only 4.3V because I had a transistor in the circuit for power control and it dropped 0.7V from collector to emitter. This was why the power level was so low: a pull-up resistor to 4.3V was below the voltage threshold for 500mA power.

In order to create a microcontroller-switchable 5V (not 4.3V) power supply, I went with my most expedient option of using another voltage regulator with an enable pin connected to what used to be the transistor base. This raised the divided voltage within 500mA range, and finally the Pixel 3a started charging at that rate as confirmed by the USB power meter. And as an experiment to confirm my understanding, I dropped pull-up resistance down to 22kΩ. This raised the resulting voltage at the divider, and USB power meter reported that my Pixel 3a started drawing 1.5A. My buck converter is rated to handle this output and this way the phone charges faster.

[UPDATE: Hackaday has post describing USB-C power for the electronic hobbyist audience.]

(*) Disclosure: As an Amazon Associate I earn from qualifying purchases.

Successful Quick ESPHome Test: M5Stack ESP32 Camera

I don’t really have the proper gear to test and verify my modifications to an USB cable with type C connectors. Flying blind, I knew there was a good chance I would fry something. I dug through my pile of electronics for the cheapest thing I have with an USB-C socket, which turned out to be a M5Stack ESP32 Camera.

I got this particular module as an add-on to the conference badge for Layer One 2019 as documented on Hackaday. It’s been gathering dust ever since, waiting for a project that needed a little camera driven by an ESP32. For conference badge purposes it ran code from this repository, which also pointed to resources that helped me find the M5Stack ESP32Cam product documentation page.

The camera module is an OV2640, which is a very popular for electronics hobbyists and found in various boards like this one from ArduCam. If I want to do more work with ESP32+OV2640 I can find variations on this concept for less than $10 each. But M5Stack is at least a relatively name-brand item here, enough for this module to be explicitly described in ESPHome documentation. (Along with a warning about insufficient cooling in this design!)

Two notes about this ESP32Cam module that might not be present on other ESP32+OV2640 modules:

  1. There is a battery power management IC (IP5306) on board, making this an interesting candidate for projects if I want to run on a single lithium-ion battery cell and if I don’t want to tear apart another USB power bank. I think it handles both charge safety and boost conversion for higher voltage. I don’t know for sure because the only datasheets I’ve found so far are in Simplified Chinese and my reading comprehension isn’t great.
  2. The circuit board included footprints for a few other optional IC components. (BMP280 temperature/pressure/humidity environmental sensor, MPU6050 3-axis accelerometer + 3-axis gyroscope, SPQ2410 microphone.) They are all absent from my particular module, but worth considering if they are ICs that would be useful for a particular project.
  3. There is a red LED next to the camera connected to pin 16. I used it as an ESPHome status light.
    number: 16

My first attempt to put ESPHome on this module was to compile a *.bin file for installation via Unfortunately, it doesn’t seem to properly set up the flash memory for booting as the module gets stuck in an endless loop repeating this error:

flash read err, 1000
ets_main.c 371 
ets Jun  8 2016 00:22:57

To work around this problem, I fired up an Ubuntu laptop and ran ESPHome docker container to access a hardware USB port for flashing. This method flashed successfully and the ESP32 was able to get online where I could make future updates over wireless.

A web search indicates an OV2640 has a native sensor resolution of 1632×1232. But the ESPHome camera component running on this module could only handle a maximum of 800×600 resolution. The picture quality was acceptable, but only about 2-3 frames per second gets pushed to Home Assistant. As expected, it is possible to trade resolution for framerate. The lowest resolution of 160×120 is very blurry but at least motion is smooth. If I try resolutions higher than 800×600, at bootup time I would see this error message in debug log:

[E][esp32_camera:095]:   Setup Failed: ESP_ERR_NO_MEM

This isn’t great. But considering its price point of roughly ten bucks for a WiFi-enabled camera module, it’s not terrible. This experiment was a fun detour before I return to my project of automated charging for a Pixel 3a phone.

Power for USB C is More Complicated Than Red Wire/Black Wire

My power output board had a USB-A socket because the first thing I wanted to automate was charging a Pixel 3a phone. It is not my primary phone, so it usually sits and slowly drains its battery until I remember to charge it up again. Draining a battery to empty isn’t good for longevity but I also don’t want to leave it on the charger all the time either. (The latter is liable to accelerate battery problems like swelling.) So I want to use Home Assistant+ESPHome and automate charging the phone for a few hours a day.

The initial test using an USB-A socket wired directly to the +5V plane of the board that also fed the on-board ESP32. Using a USB-A to USB-C adapter cable, I could charge the phone slowly at the baseline 2.5W (5V at 500mA) of USB power. A good start! But I didn’t want to use a bulky USB-A socket and tie up a perfectly good USB-A to USB-C cable for this purpose. I thought I could use one of my retired USB-C cables. Its insulation has hardened with age and broken up right at the plug due to insufficient strain relief.

We can see the outer protective sheath is broken, exposing the wires within. I no longer trust this cable for tasks like data transfer or USB-C high power delivery, but I thought maybe it can still be used for low power USB charging if I wired it up like it was a USB-A to USB-C cable. Since this is a USB2 cable with type C connectors, I had expected to find the usual wires of an USB2 cable: red for +5V, black for GND, green for D+ and white for D-. I cut it open and this is what I found instead:

Wrapped inside the outer metal mesh and foil I found:

  • Wires without insulation, presumably GND.
  • Not one but FOUR red wires. Two of them a slightly thicker gauge than the other two.
  • Green and white wires as expected for D+/D-
  • Yellow wire for…?

On the Wikipedia page for USB-C I found this color-coded chart. It does show four pins for Vbus which probably corresponds to the four red wires. Uninsulated wires are likely GND. Green and white are probably D+/D- as originally anticipated. And it shows yellow as the recommended color for Vconn, power supply for powered cables.

This is a cheap USB2 cable with Type-C ends, so I doubted it was a powered cable. Elsewhere on the same page was this chart describing what’s expected for USB-C cables in USB2 mode. It didn’t list anything that would explain the yellow cable. There’s an option for CC (configuration channel) but that’s supposed to be blue. Perhaps this yellow wire is CC? I need a way to probe the pins on my Type-C connector to know exactly what the yellow wire is connected to, but I don’t have a breakout board for that purpose on hand. Perhaps something like this item? (*) I’ll put that on my shopping list.

In the meantime I’m going to leave those wires alone and do the basic USB2 thing: tie all red wires together and put +5V on them, with all the uninsulated at ground. This was enough for basic USB power on my USB tester, an older USB-C phone (Moto X4), and an ESP32 camera board with USB-C. But it didn’t work for the Pixel 3a. What else is that phone expecting?

On the page for USB Power Delivery, I saw a section that said a dedicated charging port should have a resistance not exceeding 200Ω across the D+/D- line. I soldered a resistor across green and white wires and… still no response from the Pixel 3a.

In hindsight that was a risk: what if the green and white wires weren’t D+/D-? I had no way to verify that assumption and I could have destroyed my phone trying to cheap out on a cable. So I stopped my experimentation until I have a better handle on type C connectors. Experiments like adding termination resistors or following pinout guides will have to wait. Maybe in the future I can determine why a Pixel 3a is unsatisfied with simple red +5V/black GND scheme, but at least I know M5Stack’s ESP32Cam was fine with it.

[UPDATE: I bought the USB-C breakout board linked above for the next round of experiments. Includes more information about how 5V power over USB-C is managed by a pair of voltage dividing resistors. I can now control Pixel 3a charging rate between 0.5A and 1.5A.]

(*) Disclosure: As an Amazon Associate I earn from qualifying purchases.

Converting Power Input of USB-C Car Charger

The first introduction of USB-C into my life was my Nexus 5X cell phone. Intrigued by the promise of faster charging possible with USB-C, I bought a few additional chargers including this car charger sold by Monoprice.

MP USBC conversion 00 user end

This particular model is no longer carried by Monoprice, probably because there’s a flaw in the design. After several months, it became difficult for it to make good electrical contact with the standard car power socket that originally started as a cigarette lighter.

MP USBC conversion 01 plug end

My hypothesis is that there’s poor electrical conduction in the system, causing energy to be lost as heat that started melting the surrounding plastic. Eventually seizing up the spring-loaded mechanism so it is stuck.

MP USBC conversion 02 melty closeup

I first tried cutting the metal free from melted plastic and had no luck. This plastic is extremely durable.

MP USBC conversion 03 tough to cut

I then tried attacking the problem from the other end, and felt sheepish because the face plate is only held by friction and popped off easily.

MP USBC conversion 04 faceplate pops open

Looking inside, I could see two screws for further disassembly.

MP USBC conversion 05 two screws visible

Once they were removed, it was easy to pull the guts and lay them out.

MP USBC conversion 06 components laid out

There is a thin spring behind the contact showed heat darkening, consistent with hypothesis of too much power carried within that thin metal causing heating. My experiment of the day would be to replace that connector system, and the easiest type on hand is a commodity JST-RCY connector which is good for at least 3 amps and very commonly handling peak power higher than 3A in remote-control aircraft.

MP USBC conversion 07 JST-RCY soldered on

The first soldering effort was bad. The positive wire easily soldered to where the spring used to be, but the original ground contact is a huge piece of metal my soldering iron could not bring up to proper temperature for a good solder joint. For the second attempt I found another ground on the PCB to solder to, keeping the two wires tight enough so I could thread it through the partially melted hole where the spring-loaded positive contact used to be.

MP USBC conversion 08 JST-RCY threaded through

I reassembled the device without the original spring or its contact. I won’t be able to use it with a car power socket anymore but I should be able to keep using it to charge USB-C devices from other ~12V DC power sources.

MP USBC conversion 09 reassembled