A user on a Cardputer Zero could not connect his Cap. MeshTerm stopped at "nothing answers at 0x43 on /dev/i2c-1". His Cap is the Cap LoRa868, which M5Stack made before the Cap LoRa-1262. The two boards carry the same SX1262 on the same pins of the same header, and the same GNSS at the same speed. The newer board adds an antenna switch, and the chip at 0x43 that turns the switch on. The older board has no switch, so it has no such chip. MeshTerm asked for one on every Cardputer Zero. A wiring now says whether its expander is required. pi4io_required is true by default, so every other board keeps the rule that an expander which does not answer is an absent board. The Cap sets it to false. An absent expander is then the other revision of the board, and the node must prove that before it accepts it. After the radio starts, the node reads the version register of the chip and requires the name of an SX126x. A bus with nothing on it reads as all ones or all zeros, and the library can start on such a bus, so a Cap that is absent or badly seated still reports that no radio answered. The read of the expander also tells its failures apart now. Only the errors that mean "nobody is at this address" count as absent. A bus error or a refused read is a failure of its own, and never becomes the older board quietly. The two boards come from M5Stack's own pages, and from two other Cardputer Zero applications that drive both. The pins, the TCXO, and DIO2 are the same everywhere, and they agree with the wiring MeshTerm already had. One thing is open. The device screen names the row "Cap LoRa-1262" before anything is connected, because nothing can know which Cap is attached until the node runs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
13 KiB
MeshTerm on the Cardputer Zero
M5Stack makes three Cardputers. This page is about the Cardputer Zero. It has a Raspberry Pi Compute Module 0 inside, and it runs Linux. The original Cardputer and the Cardputer-Adv are ESP32 microcontroller boards. They cannot run MeshTerm, and nothing on this page applies to them.
MeshTerm is an app in M5Stack's app store for the Cardputer Zero. It starts from the launcher of the handheld and draws on its display. It can drive M5Stack's Cap LoRa-1262 radio directly, or it can use a MeshCore companion. MeshTerm supports both models of the handheld: the Cardputer Zero and the Cardputer Zero Lite.
The device
| Models | Cardputer Zero (C154) and Cardputer Zero Lite (C155). MeshTerm supports both |
| Computer | Raspberry Pi Compute Module 0: four 1 GHz cores, 512 MB of memory |
| Screen | 1.9 inches, 320×170 pixels |
| Keyboard | 46 keys, with Shift, Fn and Sym layers |
| System | Raspberry Pi OS "Trixie", with M5Stack's own app launcher |
The two models have the same computer, display, keyboard, battery, and expansion header. The Cardputer Zero also has a camera, motion sensors, and a 32 GB microSD card. MeshTerm uses none of these three parts, thus it works in the same way on both models. The Lite comes without a microSD card. It needs a card with M5Stack's system on it before it can start (refer to M5Stack's documentation).
MeshTerm draws the display in 53 columns by 14 rows. The width is the same as on the PicoCalc, but the height is approximately half. Thus many screens have a more compact layout here.
The launcher gives an app the whole display and the keyboard, but it gives no text console to run in. Thus MeshTerm has its own console. This is a small program inside MeshTerm. It draws each character on the display itself and reads the keys directly.
What works
All of these were tried on a real Cardputer Zero:
- MeshTerm starts from M5Stack's app launcher and draws on the display itself.
- MeshTerm has a layout for the display of 14 rows. The title bar also shows the unread count and the battery. The tab strips have one row. The dialogs fit the short display.
- The battery in the title bar is the Cardputer Zero's own battery.
- The row of function-key labels is along the bottom of the display. Fn+4 to Fn+8 drive it. These keys are directly under the display. Shift with them gives a second set.
- M5Stack's Cap LoRa-1262 radio add-on (refer to Radios).
- Hold Esc to quit. This is how the launcher closes each app. After one second, MeshTerm shows a box that says so. The box has a bar that fills over the next two seconds. While the box is visible, MeshTerm sends nothing new over the radio. If you release Esc before the bar is full, you return to the screen that you were on. If you keep holding it, MeshTerm saves everything and closes in good time, before the launcher forces it. A short press of Esc still goes back one screen, as on all other handhelds.
Installing it on the device
From the app store
- On the Cardputer Zero, open M5Stack's app store.
- Find MeshTerm. It is in the Radio & Comms category. Its share code is
MTRM. - Install it.
MeshTerm now has an icon in the launcher. The package has all that MeshTerm needs: its Python libraries, the radio library for the Cap, and the font of the display. Each new version of MeshTerm also goes to the store.
The store gets a new version a short time after its release, when the check of the store passes. If you want a new version before the store has it, install the same package from GitHub.
From GitHub
Each release of MeshTerm has the
package that the store has, meshterm_<version>-1_arm64.deb. Copy it to the Cardputer
Zero, for example with scp. Then install it from a command line on the handheld:
sudo apt install ./meshterm_*_arm64.deb
To remove it, run sudo apt remove meshterm.
From the source code
This way is for developers who know a Linux command line. The Cardputer Zero must be on Wi-Fi. You also need a way to type commands on it. SSH from another computer is the easiest way.
- Get MeshTerm and the radio library, and download the font that the display uses:
git clone https://github.com/jpmartineau/MeshTerm.git
cd MeshTerm
python3 -m venv .venv
.venv/bin/pip install -e '.[spi]'
.venv/bin/meshterm emulate --fetch-fonts
- Put MeshTerm in the launcher. The command asks for your password one time, because the list of apps of the launcher belongs to the system:
scripts/cardputer-zero/launcher-entry.sh
MeshTerm now has an icon in the launcher. The icon is a negative of the MeshTerm logo. Thus
it is different from the icon of MeshTerm from the app store, and you can have both. To
remove the icon, run scripts/cardputer-zero/launcher-entry.sh remove.
Typing long text from your computer
A long password or key is hard to type on a keyboard this small. Use another computer that
can reach the Cardputer over SSH. The tool scripts/cardputer-zero/type-text.py types the
text for you, into the app that has the display:
python scripts/cardputer-zero/type-text.py --host pi@cardputer.local
- On the Cardputer, open the field that you want to fill.
- Run the command above on your computer.
- Paste the text when the tool asks for it, and press Enter. The tool does not show your typing. The text goes to the Cardputer over SSH, thus it does not show on either display.
- Do not touch the Cardputer's keyboard until the tool says that it is done.
Trying it in the emulator
The emulator opens a window that shows the display of the Cardputer Zero. The window scales the display up so that you can read it. If you run it with a simulated radio, you can try the layout without the handheld and without a radio.
The emulator is not a strict emulator. It does not copy the computer of the Cardputer Zero. MeshTerm runs on your own computer, at the speed of your computer. The emulator copies the constraints of the display and the keyboard: the size of the display in pixels, the font, the colours, and the keys that drive the labels along the bottom. This shows what fits on the display and what does not. That is the purpose of the emulator.
The emulator needs MeshTerm installed with pip or pipx (refer to the README). The one-file downloads do not have the part of Python that opens windows.
- Download the font that the display uses. Do this one time:
meshterm emulate --fetch-fonts
- Start the emulator:
meshterm emulate cardputer-zero --mock
--mock is the simulated radio. Before you start, set MESHTERM_HOME to an empty folder.
Then the made-up nodes of the simulation stay out of your real history. --scale 4 makes
the window bigger.
In the window, the F4 to F8 keys of your keyboard replace Fn+4 to Fn+8. Hold Shift to show the second set. You can also click the keys. Click the keys that are drawn under the display, or the coloured keys along its bottom row. Hold Shift while you click for the second set. Ctrl+Shift+S saves a screenshot at the real size of the display. When you close the window, MeshTerm quits. It also quits when you hold Esc for three seconds, as it does on the handheld.
Radios
The Cardputer Zero has no LoRa radio built in. You can add one in three ways:
| Radio | Status |
|---|---|
| Cap LoRa-1262 add-on board from M5Stack | Works, with no setup. MeshTerm runs the mesh node itself while it is open, as it does on a uConsole. |
| Cap LoRa868, the earlier add-on board | Works, with no setup. It is the same radio with no antenna switch (refer to The older Cap LoRa868). |
| A MeshCore companion on USB | Expected to work as on any Linux computer. |
| A MeshCore companion over Bluetooth | Expected to work as on any Linux computer. |
The Cap LoRa-1262
CAUTION: Turn off the Cardputer Zero before you install or remove a Cap, also the Cap LoRa-1262. M5Stack does not support hot swapping of a Cap on the Cardputer Zero. In M5Stack's words, "hot-swapping may cause the device to malfunction" (refer to M5Stack's documentation).
CAUTION: Install the antenna on the Cap before you turn on the Cardputer Zero. M5Stack says that power without the antenna can permanently damage the radio.
- Turn off the Cardputer Zero.
- Install the antenna on the Cap.
- Push the Cap onto the expansion header at the back.
- Turn on the Cardputer Zero, and start MeshTerm.
The device screen lists the Cap as Cap LoRa-1262. meshterm --spi also reaches it from the
command line.
The Cap has no MeshCore firmware of its own. It is only a radio chip. Thus, while MeshTerm is open, MeshTerm is the node, as it is on the AIO board of a uConsole. MeshTerm needs the radio library. The package from the store has it. If you install MeshTerm with pip, install the library next to it:
pip install 'mesh-term[spi] @ git+https://github.com/jpmartineau/MeshTerm'
When MeshTerm connects, it does three things that the Cardputer Zero needs before the radio answers:
- It switches on the power to the expansion header. The power is off until a program asks for it.
- It makes sure that two pins of the header connect to the radio and not to the USB port that shares them.
- It switches on the antenna path of the Cap.
When MeshTerm quits, it switches the power of the header off. Thus the Cap does not drain the battery while nothing uses it. But this does not make it safe to remove the Cap. Turn off the Cardputer Zero first.
A new node starts with the US/Canada settings of MeshCore (910.525 MHz). In other regions,
change the settings on Device config before you send anything. MeshTerm keeps the key,
the contacts, and the channels of the node in ~/.meshterm/radio/spidev0.1/.
The older Cap LoRa868
M5Stack made an earlier LoRa Cap, the Cap LoRa868. MeshTerm works with it as well, and you do nothing to make it work.
The two Caps are almost the same board. Each one has an SX1262 radio and a GNSS
receiver, on the same pins of the same 14-pin header. The newer Cap LoRa-1262 adds an
antenna switch, and a small chip at I2C address 0x43 that turns that switch on. The
older Cap has no antenna switch, so it has no such chip.
MeshTerm finds out which Cap you have each time it connects:
- It powers the header.
- It looks for the switch chip at
0x43, for one second. - If the chip answers, the Cap is a Cap LoRa-1262, and MeshTerm turns the antenna switch on.
- If nothing answers, MeshTerm starts the radio and asks the radio what it is. An SX1262 that gives its name is the older Cap, and MeshTerm continues.
Step 4 is the reason why a Cap that is absent, or that is not pushed fully onto the header, is still reported as absent. Only a radio that answers for itself is accepted.
If MeshTerm says that it cannot find the radio
Two messages are possible, and they mean different things.
"Nothing answers at 0x43 on /dev/i2c-1" comes from a profile of your own that
requires the switch chip. MeshTerm's own wiring for the Cap does not require it. Set
pi4io_required = false in your profile, or remove the pi4io_bus line from it (refer
to Board wiring).
"No SX126x answered on the SPI bus" means that no radio answered. Turn the Cardputer Zero off, push the Cap fully onto the header at the back, and check that no row of pins is left over at either end. Then turn it on again. Never add or remove a Cap while the device is on.
The node writes what it did to ~/.meshterm/radio/spidev0.1/node.log. That file names
the wiring it used and the answer it got from the bus. Send it with a problem report.
The Cap's GPS
The Cap also has a GPS. MeshTerm can use it to keep the position of your node current. The GPS is off until you switch it on, as on MeshCore firmware. To switch it on:
- Open Device config.
- Under Custom variables, set GPS to on.
- Apply.
When the GPS has a fix, the fix becomes the position of your node. In the open air, the first fix usually takes approximately one minute. Indoors, the fix may never come.
Two things do not change:
- You decide if your adverts include your position. This is the Share location setting on Device config. If it is off, the GPS still moves your node on MeshTerm's own map, but nobody else sees where you are.
- A hand move of your node on the map does not stay while the GPS is on. The next fix puts the node back where the GPS says you are. Switch the GPS off first.
GPS interval sets how often the position changes, in seconds. The default is 0. This means each fix, approximately one each second. MeshTerm remembers your last fix when it quits. Thus the next start begins where you were.
The GPS talks to the Cardputer over a serial port, as a companion on a USB cable does. But it is not a companion, thus the device screen does not list it.