This is an interactive Meshtastic bot developed in Python, managed via uv (Ultraviolet). It automatically connects to a Meshtastic device connected via serial/USB port, listens to messages, and responds with detailed network telemetry if it receives specific commands.
The easiest way to run the bot on Windows is by using the standalone portable executable (if available in the repository's Releases section). You don't need to install Python or any dependencies.
- Download: Go to the Releases section of this repository and download the
mtb-windows.zipfile. - Extract: Unzip the downloaded file to extract
mtb.exe. - Connect Device: Plug your Meshtastic device into a USB port on your PC.
- Run via Command Line: Open a Terminal or Command Prompt in the folder where you extracted the
.exeand run it passing your configuration as arguments.
mtb.exe --location "My City, Country" --channel "Test" --cooldown 20--location: (Optional) Text indicating the bot's location. This will be included in the telemetry response. Default:"Unknown Location".--channel: (Optional) The channel name where the bot will listen for the/pingcommand. Default:"Test".--cooldown: (Optional) Time in seconds that a user must wait before using a command again. Default:20.--port: (Optional) Manually specify the Serial COM port (e.g.,COM3). If not provided, the bot will auto-detect the connected device.
Before running the bot, your local Meshtastic node must be configured with a specific channel so the bot can listen and respond. By default, ensure you have set up:
- Channel Name:
Test(This is the default and highly recommended channel for running bots, to avoid spamming the main public channels). - PSK (Pre-Shared Key):
Ag==(Base64)
Note: The channel name can be overridden using the --channel CLI argument, but the key depends entirely on your Meshtastic app configuration.
- uv installed.
- A Meshtastic device connected locally via USB cable to the PC.
- Clone or ensure you are in the directory of this repository.
- Initialize the entire environment and download dependencies automatically using
uv(our package manager). There is no need to manually install packages with pip, aspyproject.tomlmanages everything.
To run the bot from the source code, simply execute the following command in this directory:
uv run main.py --location "My City"The bot will attempt to connect via auto-discovery to the USB-connected device. Upon starting, it will announce its start on the target channel, indicating its original node name.
| Command / Event | Default Channel | Response | Description |
|---|---|---|---|
/ping |
Test |
Complete telemetry and routing report | Verifies that the bot is active and returns a technical analysis of the connection quality |
The bot disassembles the incoming Meshtastic protobuf packet to extract the following statistics:
- Node: Displays the text defined by the
--locationparameter. - RSSI: Extracted from the temporary attribute
packet["rxRssi"]. The base radio associates this data with the packet at the exact moment the antenna catches the signal, indicating the raw received power in dBm. - SNR: Extracted from
packet["rxSnr"]. Injected by the smart radio chip when measuring the electrical cleanliness threshold against the general background noise level of the band (dB). - Hops: Calculated by subtracting routing metadata from the hardware packet. Meshtastic includes
hopStart(maximum hops it left the sender with) andhopLimit(remaining). The bot useshopStart - hopLimitto visually paint how many of these hops were consumed. - Relay: The intermediate node that catapulted the packet to us. Meshtastic (to save bandwidth over LoRa) truncates the license plate of the relay antenna to a very small size of 1 single byte (0-255) and stamps it in
packet["relayNode"]. The bot, to get a clear name, reverse engineers this by crossing that byte against an iterative scan (node_id & 0xFF) of the internal contacts file (interface.nodes) until it finds a "match". If this fails or if the consumed hops were 0 (direct connection with no one repeating), the app removes the mask and maps it directly extracting the original 32-bit ID from the packet:packet["from"].
main.py: The bot engine. Subscribes to device events withpub.subscribe, interceptsTEXT_MESSAGE_APPpackets from theTestindex, and responds toidusingreplyIdin thread form. Contains visual mapping logic and CLI parsing.pyproject.toml: Python environment file managed natively byuv.
If you want to build the mtb portable executable yourself, simply run:
uv run pyinstaller --onefile --name mtb main.pyThe .exe file will be generated inside the dist/ folder.