r/SolarOS • • 14d ago

USB Keyboard Implementation

Hi,

I'm very much a beginner to this type of thing so forgive me if any of these questions are dumb. I'm trying to make a writerdeck with the Waveshare ESP32-S3 RLCD and a Womier Q61 mechanical keyboard. I did have it working with bluetooth but the pairing is frustrating, probably on the Q61's end.

I understand that by default the USB is configured as JTAG, and is unpowered. I've split open a USB C cable and added breadboard pins to each of the wires, then connected them to 3v3, GND, and GPIO 19 and 20 which I understand to be soldered to D+ and D- on the board. If I'm not totally off base I think all I have left is changing the USB mode from JTAG to OTG (Host mode?) which I understand happens at boot. This is where I'm at a loss like I don't even know how to google this question. How do I change that in SolarOS? And can I change it back should I need to flash a firmware update?

Separately, I'm hoping to use the internal batteries of the keyboard as a power supply along with the 18650. I've confirmed that it's nominal 3.7v just like the 18650, is it a bad idea to simply wire it into the power supply + and -? If so, does it matter whether I do so serially or in parallel? There is also a yellow wire (clock or signal?) that I'm not sure what I would do with.

Thanks in advance!

4 Upvotes

24 comments sorted by

3

u/nilseuropa 14d ago

USB is 5V. For the hardware interface you'll need a step up converter from battery to 5V rail and level shifters between the ESP32 and the keyboard.

Then comes the firnware portion, where USB host is disabled and USB HID is not implemented in the SolarOS keyboard service.

At this point I would advise to go with BLE. There will be USB support at some point.

1

u/sustineo 14d ago

is there likely a stepup converter inside the keyboard then for its own 3.7v battery? i was wondering this since it has both wired and bluetooth modes, idk how that works with the voltage

1

u/clackups 14d ago

Doubtful. The TTL logic is 3.3v, so there's no need to get a higher voltage

1

u/nilseuropa 14d ago

?

2

u/clackups 14d ago

The OP asks if a keyboard converts its internal battery to 5v. There's no reason to do so, as the MCU works under 3.3v

2

u/nilseuropa 14d ago

ach so, ja stimmt

1

u/sustineo 14d ago

I'm willing to dig in deeper -- is there something I could salvage from the keyboard I already have and splice into a matrix expander (like the TCA8418 SolarOS suggests in their tutorials) to use through GPIO? or could i do something with an old PS/2 keyboard?

2

u/nilseuropa 14d ago

I'll see if I can find a way to easily enable the USB host at runtime in the next release.

2

u/sustineo 14d ago

Thank you!! very cool. Really grateful for the whole project btw! great work

1

u/nilseuropa 14d ago

PS/2 is fully supported yes, but that requires 5V as well. 🙂

1

u/sustineo 14d ago

PS/2 would just be through GPIO? how does one configure that? I can probably figure out the power supply situation

1

u/nilseuropa 14d ago

https://solar-os.eu/docs/manual/job.ps2-keyboard.html

  1. create a ps/2 bus on two free gpios ( io app helps )

  2. start the ps2 job

Still needs level shifters on the gpios!

1

u/sustineo 14d ago

ohhh that makes sense thank you

1

u/sustineo 10d ago edited 10d ago

got a level shifter, shifted each wire. assigned each GPIO
"job start ps2-keyboard ps2kbd" gives "job start failed: invalid value or syntax"

if i run "expansion attach ps2-keyboard keyboard0 ps2=ps2kbd" it attaches then running "job start ps2-keyboard ps2kbd" gives "job start failed: resource is busy or not ready"

1

u/nilseuropa 10d ago

hah. “Invalid value or syntax” is a firmware bug - i'll address that.

`expansion attach ps2-keyboard keyboard0 ps2=ps2kbd` already starts the keyboard receiver. Once it attaches successfully, try typing—you don’t need to run job start afterward.

1

u/thisaccountbemine 14d ago

It might be quite hard to enable the usb, I might recommend https://www.amazon.com/cablecc-Bluetooth-Converter-Receiver-Keyboard/dp/B0F4QZ2FR7 that lets you use a wired keyboard over bluetooth, I dont know if they would be BLE that solar os needs, but its a place to start.

1

u/sustineo 14d ago

it's already a bluetooth keyboard, i just really would prefer it wired. but maybe it's not worth the effort

1

u/LowFlowIO 14d ago

Heh, it didn't even occur to me these already existed when I built my own.

(Disclosure, I didn't wrap this firmware or shout about it anywhere so it's missing some polish, but it works)

1

u/clackups 14d ago

There's esp32-s31 coming up, it has a native USB Host. Another option would be M5STACK Tab5, which also has a USB host port, but it seems like it's not produced any more, but there are plenty of them in shops.

Both would require porting the SolarOS.

1

u/nilseuropa 14d ago

The S3 has native USB Host too.

1

u/clackups 14d ago

It does, but then you lose the USB device capability. Also, I've only seen one board on AliExpress that actually implements it