2021-04-28 14:38:14 -07:00
---
id: python-cli
2023-01-19 05:01:57 -08:00
title: Meshtastic Python CLI Guide
2022-11-02 14:50:50 -07:00
slug: /software/python/cli
2022-10-31 10:27:04 -07:00
sidebar_label: Python CLI
2022-11-03 19:54:37 -07:00
sidebar_position: 4
2021-04-28 14:38:14 -07:00
---
2021-12-29 10:49:34 -08:00
The python pip package installs a "meshtastic" command line executable, which displays packets sent over the network as JSON and lets you see serial debugging information from the meshtastic devices. This command is not run inside of python, you run it from your operating system shell prompt directly. If when you type "meshtastic" it doesn't find the command and you are using Windows: Check that the python "scripts" directory is in your path.
2021-04-28 14:38:14 -07:00
2021-12-29 10:49:34 -08:00
## Optional Arguments
### -h or --help
Shows a help message that describes the arguments.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-04-28 14:38:14 -07:00
meshtastic -h
```
2023-07-26 23:33:02 -07:00
### --export-config
Export the configuration of the device. (to be consumed by the '--configure' command).
To create to a file with the connected device's configuration, this command's output must be piped to a yaml file.
```shell title="Usage"
meshtastic --export-config > example_config.yaml
```
```title="Usage"shell
meshtastic --export-config
```
2023-07-28 21:51:18 -07:00
### --configure
Configure radio using a yaml file.
```shell title="Usage"
meshtastic --configure example_config.yaml
```
2021-12-29 10:49:34 -08:00
### --port PORT
2022-01-24 02:25:53 -08:00
The port the Meshtastic device is connected to, i.e. `/dev/ttyUSB0`, `/dev/cu.wchusbserial`, `COM4` etc. if unspecified, meshtastic will try to find it. Important to use when multiple devices are connected to ensure you call the command for the correct device.
2021-12-29 10:49:34 -08:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --port /dev/ttyUSB0 --info
meshtastic --port COM4 --info
```
### --host HOST
The hostname/ipaddr of the device to connect to (over TCP).
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --host HOST
```
### --seriallog SERIALLOG
Logs device serial output to either 'stdout', 'none' or a filename to append to.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --port /dev/ttyUSB0 --seriallog
```
### --info
Read and display the radio config information.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --port /dev/ttyUSB0 --info
```
2023-07-26 23:33:02 -07:00
### --set-canned-message
Set the canned message plugin messages separated by pipes `|` (up to 200 characters).
```shell title="Usage"
meshtastic --set-canned-message "I need an alpinist!|Call Me|Roger Roger|Keep Calm|On my way"
```
### --get-canned-message
Show the canned message plugin message.
```shell title="Usage"
meshtastic --get-canned-message
```
### --set-ringtone RINGTONE
Set the Notification Ringtone (up to 230 characters).
```shell title="Usage"
meshtastic --set-ringtone "LeisureSuit:d=16,o=6,b=56:f.5,f#.5,g.5,g#5,32a#5,f5,g#.5,a#.5,32f5,g#5,32a#5,g#5,8c#.,a#5,32c#,a5,a#.5,c#.,32a5,a#5,32c#,d#,8e,c#.,f.,f.,f.,f.,f,32e,d#,8d,a#.5,e,32f,e,32f,c#,d#.,c#"
```
### --get-ringtone
Show the stored ringtone.
```shell title="Usage"
meshtastic --get-ringtone
```
2021-12-29 10:49:34 -08:00
### --nodes
Prints a node list in a pretty, formatted table.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --nodes
```
### --qr
Displays the QR code that corresponds to the current channel.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --qr
```
2023-07-28 21:51:18 -07:00
### --get [config_section]
2021-12-29 10:49:34 -08:00
Gets a preferences field.
2023-09-28 19:10:42 -07:00
Configuration values are described in: [Configuration](https://meshtastic.org/docs/configuration).
2023-07-26 23:33:02 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2023-07-28 21:51:18 -07:00
meshtastic --get lora
2022-09-11 07:43:52 -07:00
meshtastic --get lora.region
2021-12-29 10:49:34 -08:00
```
2023-07-26 23:33:02 -07:00
### --set [config_section].[option] [value]
2021-12-29 10:49:34 -08:00
Sets a preferences field.
2023-09-28 19:10:42 -07:00
Configuration values are described in: [Configuration](https://meshtastic.org/docs/configuration).
2022-09-11 07:43:52 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2022-09-11 07:43:52 -07:00
meshtastic --set lora.region Unset
2021-12-29 10:49:34 -08:00
```
### --seturl SETURL
Set a channel URL.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --seturl https://www.meshtastic.org/c/GAMiIE67C6zsNmlWQ-KE1tKt0fRKFciHka-DShI6G7ElvGOiKgZzaGFyZWQ=
```
### --ch-index CH_INDEX
2023-07-26 23:33:02 -07:00
Set the specified channel index.
2021-12-29 10:49:34 -08:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --ch-index 1 --ch-disable
```
### --ch-add CH_ADD
Add a secondary channel, you must specify a channel name.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --ch-add testing-channel
```
2022-01-24 02:25:53 -08:00
2021-12-29 10:49:34 -08:00
### --ch-del
Delete the ch-index channel.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --ch-index 1 --ch-del
```
### --ch-enable
Enable the specified channel.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --ch-index 1 --ch-enable
```
### --ch-disable
Disable the specified channel.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --ch-index 1 --ch-disable
```
### --ch-set CH_SET CH_SET
Set a channel parameter.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --ch-set id 1234 --ch-index 0
```
2023-07-26 23:33:02 -07:00
### --ch-vlongslow
2023-07-28 21:51:18 -07:00
Change modem preset to `VERY_LONG_SLOW`.
2023-07-26 23:33:02 -07:00
```shell title="Usage"
meshtastic --ch-vlongslow
```
2021-12-29 10:49:34 -08:00
### --ch-longslow
2023-07-28 21:51:18 -07:00
Change modem preset to `LONG_SLOW`.
2021-12-29 10:49:34 -08:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --ch-longslow
```
2023-07-26 23:33:02 -07:00
### --ch-longfast
2023-07-28 21:51:18 -07:00
Change modem preset to (the default) `LONG_FAST`.
2023-07-26 23:33:02 -07:00
```shell title="Usage"
meshtastic --ch-longfast
```
### --ch-medslow
2023-07-28 21:51:18 -07:00
Change modem preset to `MEDIUM_SLOW`.
2023-07-26 23:33:02 -07:00
```shell title="Usage"
meshtastic --ch-medslow
```
### --ch-medfast
2023-07-28 21:51:18 -07:00
Change modem preset to `MEDIUM_FAST`.
2023-07-26 23:33:02 -07:00
```shell title="Usage"
meshtastic --ch-medfast
```
### --ch-shortslow
2023-07-28 21:51:18 -07:00
Change modem preset to `SHORT_SLOW`.
2023-07-26 23:33:02 -07:00
```shell title="Usage"
meshtastic --ch-shortslow
```
2021-12-29 10:49:34 -08:00
### --ch-shortfast
2023-07-28 21:51:18 -07:00
Change modem preset to `SHORT_FAST`.
2021-12-29 10:49:34 -08:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --ch-shortfast
```
### --set-owner SET_OWNER
Set device owner name.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2023-07-26 23:33:02 -07:00
meshtastic --set-owner "MeshyJohn"
```
### --set-owner-short SET_OWNER_SHORT
2023-07-28 21:51:18 -07:00
Set device owner short name (4 characters max).
2023-07-26 23:33:02 -07:00
```shell title="Usage"
meshtastic --set-owner-short "MJ"
2021-12-29 10:49:34 -08:00
```
### --set-ham SET_HAM
Set licensed Ham ID and turn off encryption.
2021-12-02 11:04:38 -08:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --set-ham KI1345
2021-12-02 11:04:38 -08:00
```
2021-12-29 10:49:34 -08:00
### --dest DEST
2023-07-28 21:51:18 -07:00
The destination node id for any sent commands. Used for [Remote Node Administration](/docs/configuration/remote-admin)
2021-04-28 14:38:14 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2022-01-24 02:25:53 -08:00
meshtastic --dest '!28979058' --set-owner "MeshyJohn"
2021-04-28 14:38:14 -07:00
```
2021-12-29 10:49:34 -08:00
### --sendtext SENDTEXT
2023-07-26 23:33:02 -07:00
Send a text message. Can specify a channel index ('--ch-index') or a destination ('--dest').
2021-04-28 14:38:14 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --sendtext "Hello Mesh!"
2021-04-28 14:38:14 -07:00
```
2021-12-29 10:49:34 -08:00
### --sendping
Send a ping message (which requests a reply).
2021-04-28 14:38:14 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --sendping
2021-04-28 14:38:14 -07:00
```
2023-07-26 23:33:02 -07:00
### --traceroute TRACEROUTE
2023-07-28 21:51:18 -07:00
Traceroute from connected node to a destination. You need pass the destination ID as an argument. Only nodes that have the encryption key can be traced.
2023-07-26 23:33:02 -07:00
```shell title="Usage"
2023-08-21 21:21:07 -07:00
meshtastic --traceroute '!ba4bf9d0'
```
### --request-telemetry
Request telemetry from a node. You need to pass the destination ID as an argument with '--dest'. For repeaters, the nodeNum is required.
```shell title="Usage"
meshtastic --request-telemetry --dest '!ba4bf9d0'
meshtastic --request-telemetry --dest 1828779180
2023-07-26 23:33:02 -07:00
```
### --ack
2023-07-28 21:51:18 -07:00
Used in combination with --sendtext to wait for an acknowledgment.
2023-07-26 23:33:02 -07:00
```shell title="Usage"
meshtastic --sendtext "Hello Mesh!" --ack
```
2021-12-29 10:49:34 -08:00
### --reboot
2023-07-28 21:51:18 -07:00
Tell the node to reboot.
2021-12-29 10:49:34 -08:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2023-07-28 21:51:18 -07:00
meshtastic --reboot
2021-04-28 14:38:14 -07:00
```
2023-07-26 23:33:02 -07:00
### --shutdown
2023-07-28 21:51:18 -07:00
Tell the node to shutdown.
2023-07-26 23:33:02 -07:00
```shell title="Usage"
2023-07-28 21:51:18 -07:00
meshtastic --shutdown
2023-07-26 23:33:02 -07:00
```
### --factory-reset
2023-07-28 21:51:18 -07:00
Tell the node to install the default config.
2023-07-26 23:33:02 -07:00
```shell title="Usage"
2023-07-28 21:51:18 -07:00
meshtastic --factory-reset
2023-07-26 23:33:02 -07:00
```
### --reset-nodedb
2023-07-28 21:51:18 -07:00
Tell the node to clear its list of nodes.
2023-07-26 23:33:02 -07:00
```shell title="Usage"
2023-07-28 21:51:18 -07:00
meshtastic --reset-nodedb
2023-07-26 23:33:02 -07:00
```
2021-12-29 10:49:34 -08:00
### --reply
Reply to received messages.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --reply
```
### --gpio-wrb GPIO_WRB GPIO_WRB
2021-04-28 14:38:14 -07:00
2021-12-29 10:49:34 -08:00
Set a particular GPIO # to 1 or 0.
2021-04-28 14:38:14 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2022-01-24 02:25:53 -08:00
meshtastic --port /dev/ttyUSB0 --gpio-wrb 4 1 --dest '!28979058'
2021-04-28 14:38:14 -07:00
```
2021-12-29 10:49:34 -08:00
### --gpio-rd GPIO_RD
Read from a GPIO mask.
2021-04-28 14:38:14 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2022-01-24 02:25:53 -08:00
meshtastic --port /dev/ttyUSB0 --gpio-rd 0x10 --dest '!28979058'
2021-04-28 14:38:14 -07:00
```
2021-12-29 10:49:34 -08:00
### --gpio-watch GPIO_WATCH
Start watching a GPIO mask for changes.
2021-04-28 14:38:14 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2022-01-24 02:25:53 -08:00
meshtastic --port /dev/ttyUSB0 --gpio-watch 0x10 --dest '!28979058'
2021-12-29 10:49:34 -08:00
```
### --no-time
Suppress sending the current time to the mesh.
2021-05-03 14:42:41 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --port /dev/ttyUSB0 --no-time
2021-05-03 14:42:41 -07:00
```
2021-04-28 14:38:14 -07:00
2021-12-29 10:49:34 -08:00
### --setalt SETALT
2021-04-28 14:38:14 -07:00
2021-12-29 10:49:34 -08:00
Set device altitude (allows use without GPS).
2021-04-28 14:38:14 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --setalt 120
2021-04-28 14:38:14 -07:00
```
2021-12-29 10:49:34 -08:00
### --setlat SETLAT
Set device latitude (allows use without GPS).
2021-04-28 14:38:14 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --setlat 25.2
```
### --setlon SETLON
2021-04-28 15:03:23 -07:00
2021-12-29 10:49:34 -08:00
Set device longitude (allows use without GPS).
2021-04-28 14:38:14 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --setlon -16.8
2021-04-28 14:38:14 -07:00
```
2021-12-29 10:49:34 -08:00
### --debug
Show API library debug log messages.
2021-04-28 14:38:14 -07:00
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --debug --info
2021-04-28 14:38:14 -07:00
```
2021-12-29 10:49:34 -08:00
### --test
Run stress test against all connected Meshtastic devices.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --test
```
### --ble BLE
BLE mac address to connect to (BLE is not yet supported for this tool).
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --ble "83:38:92:32:37:48"
```
### --noproto
Don't start the API, just function as a dumb serial terminal. Probably not very helpful from the command line. Used more for testing/internal needs.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --noproto
```
### --version
Show program's version number and exit.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --version
```
### --support
Print out info that would be helpful supporting any issues.
2023-01-19 05:01:57 -08:00
```shell title="Usage"
2021-12-29 10:49:34 -08:00
meshtastic --support
2023-07-26 23:33:02 -07:00
```