# Python notes

Using the python CLI (command line interface) allows you to directly interact with units via serial (usb) wifi (TCP) or bluetooth (BLE).

Most reliable is of course serial, and this is the best way to configure one or many devices, as you can use the python scripts to load many settings at once.

Below are some of the commands I use frequently:

Installing meshtastic on linux, mac or other terminal:

<span></span>

**Install meshtastic CLI:**

- **sudo apt install pipx -y**
- <span style="font-size: 13px;">pipx install meshtastic</span>
- <span style="font-size: 13px;">pipx ensurepath</span>

Serial connection: e.g. "meshtastic -s" or simply "meshtastic" at the command line:

<span></span>

- <span style="font-size: 13px;">meshtastic --set lora.region US</span>
- <span style="font-size: 13px;">meshtastic --set lora.hop\_limit 7</span>
- <span style="font-size: 13px;">meshtastic --set mqtt.enabled true</span>
- <span style="font-size: 13px;">meshtastic meshtastic --set security.admin\_key base64:&lt;your key here&gt;</span>
- <span style="font-size: 13px;">meshtastic -s --set lora.config\_ok\_to\_mqtt true</span>
- <span style="font-size: 13px;">meshtastic -s --set lora.config\_ok\_to\_mqtt true</span>
- <span style="font-size: 13px;">meshtastic -s --set mqtt.map\_reporting\_enabled true</span>
- <span style="font-size: 13px;">meshtastic -s --set security.admin\_channel\_enabled TRUE</span>
- <span style="font-size: 13px;">meshtastic -s --export-config&gt;rp2040a.yaml</span>
- <span style="font-size: 13px;">meshtastic --info</span>
- <span style="font-size: 13px;">meshtastic --seturl &lt;url of your channel settings here&gt;</span>

<div id="bkmrk-these-can-also-be-us">These can also be used on a meshtasticd unit like a pi with a HAT:</div><div id="bkmrk-meshtasticd-configur"><span>**Meshtasticd configuration: also works with  RP2040 boards in serial mode (-s flag)**

- <span style="font-size: 13px;">meshtastic --host 127.0.0.1 --set lora.region US</span>
- <span style="font-size: 13px;">meshtastic --host 127.0.0.1 --set lora.hop\_limit 7</span>
- <span style="font-size: 13px;">meshtastic --host 127.0.0.1 --set mqtt.enabled true</span>
- <span style="font-size: 13px;">meshtastic --host 127.0.0.1 --set security.admin\_key base64:&lt;your key here&gt;</span>
- <span style="font-size: 13px;">meshtastic --host 127.0.0.1 --set device.role ROUTER</span>
- <span style="font-size: 13px;">meshtastic --host 127.0.0.1 --set store\_forward.enabled true</span>
- <span style="font-size: 13px;">meshtastic --host 127.0.0.1 --set store\_forward.history\_return\_max 1000</span>
- <span style="font-size: 13px;">meshtastic --host 127.0.0.1 --set store\_forward.history\_return\_window 1000</span>
- <span style="font-size: 13px;">meshtastic --host 127.0.0.1 --set store\_forward.is\_server true</span>
- <span style="font-size: 13px;">meshtastic --host 127.0.0.1 --set store\_forward.records 1000</span>

</span><span></span>  
</div><span id="bkmrk--7"></span>My usual config steps with USB connection:<span></span>

1. flash via USB-C
2. set bluetooth to none
3. set lora to us-7-ok MQTT
4. clone channels with set-URL via meshtastic CLI
5. <span style="font-size: 13px;">MQTT enable map, JSON</span>

<div id="bkmrk--10">  
</div><span id="bkmrk--11"></span>  
---

<small>Migrated from Apple Server Wiki. Original page ID: 62H6s3W9</small>