Driver for M5Stack CardKB (I2C mini keyboard) on Raspberry Pi
Project description
Raspberry Pi Card Keyboard
A script for using the M5Stack CardKB with Raspberry Pi
Setting your pi to us layout
In order for buttons to return the correct symbols, the keyboard layout will need to be set to us on your Pi. You can do this by running:
sudo nano /etc/default/keyboard
and changing XKBLAYOUT to us:
# KEYBOARD CONFIGURATION FILE
# Consult the keyboard(5) manual page.
XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""
BACKSPACE="guess"
Enable I²C
The cardKB communicates over I²C, make sure this is enabled on your raspberry pi. You can find a tutorial on how to do so here.
Connect CardKB to Raspberry Pi
Connect the wires on the CardKB JST connector to the appropriate pin on the Raspberry Pi.
You may need to improvise a connection solution with breadboard wires like so:
Load the uinput module
You will need to load the uinput module to allow python-uinput to input key presses. You can check if it is loaded with:
lsmod | grep uinput
If nothing is displayed, then the module is not loaded. To load the module, run:
modprobe uinput
To load the module automatically on startup, run:
sudo nano /etc/modules
add uinput at the bottom of the file. Save and then reboot.
Install CardKB via PyPI
sudo apt update
sudo apt install python3-smbus python3-uinput python3-pip
sudo pip install --break-system-packages cardkb
Test CardKB
sudo cardkb &
[!IMPORTANT]
By default, the python script listens to/dev/i2c-1. Some displays (like the Pimoroni Hyperpixel) expose a different interface. You can specify which interface to use by adding an argument to the start command.sudo cardkb 11 &
Running CardKB when Raspberry Pi starts
We can use systemd to run the CardKB script as a service. To do so, you can use the cardkb.service from source code:
sudo curl -L -o /etc/systemd/system/cardkb.service https://raw.githubusercontent.com/ian-antking/cardkb/main/cardkb.service
[!IMPORTANT]
If you are running cardkb on a i2c bus other than 1, then you will need to edit thecardkb.servicefile to add the bus number to the end of theExecStartline like so:ExecStart=/usr/local/bin/cardkb 11
sudo systemctl daemon-reload
sudo systemctl enable cardkb.service
sudo reboot
When your Pi restarts, your cardkb should be working, allowing you to log in.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cardkb-1.0.0.tar.gz.
File metadata
- Download URL: cardkb-1.0.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e21e5779e8f7d018541363f7aa6078f244aebdb748515f6878fe9b83af269323
|
|
| MD5 |
d452076919b817a578e468d929cad166
|
|
| BLAKE2b-256 |
6e81310ab88d12ab3b61e0c4289c6c120ea5787da3c0e2e72b6b2519c7768386
|
Provenance
The following attestation bundles were made for cardkb-1.0.0.tar.gz:
Publisher:
build_and_push.yaml on ian-antking/cardkb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cardkb-1.0.0.tar.gz -
Subject digest:
e21e5779e8f7d018541363f7aa6078f244aebdb748515f6878fe9b83af269323 - Sigstore transparency entry: 519151574
- Sigstore integration time:
-
Permalink:
ian-antking/cardkb@d7dea17045ee8a2e286ec6f10338be3687714503 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/ian-antking
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_and_push.yaml@d7dea17045ee8a2e286ec6f10338be3687714503 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cardkb-1.0.0-py3-none-any.whl.
File metadata
- Download URL: cardkb-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64ba4d0b39c5044749aa39e72f28eb7063fe99bbf1b3378c71fb66a1cdc5ab90
|
|
| MD5 |
e0d2aee0e09e9a0c8962a3b167a8bd23
|
|
| BLAKE2b-256 |
445f89b44f180286dc819045f4f5efb3dd8c20885046239bfb60b2e142bd443f
|
Provenance
The following attestation bundles were made for cardkb-1.0.0-py3-none-any.whl:
Publisher:
build_and_push.yaml on ian-antking/cardkb
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cardkb-1.0.0-py3-none-any.whl -
Subject digest:
64ba4d0b39c5044749aa39e72f28eb7063fe99bbf1b3378c71fb66a1cdc5ab90 - Sigstore transparency entry: 519151659
- Sigstore integration time:
-
Permalink:
ian-antking/cardkb@d7dea17045ee8a2e286ec6f10338be3687714503 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/ian-antking
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build_and_push.yaml@d7dea17045ee8a2e286ec6f10338be3687714503 -
Trigger Event:
push
-
Statement type: