Tutorial: Setting up a Windows machine for use with Meshtastic-Python

While I think Linux is probably the best OS to use when tinkering around with Meshtastic, not everyone is comfortable with it, and let’s face it – Windows is simply the predominant OS out there. Fortunately, the Meshtastic API tool is written in Python, which can be run on Windows with a little bit of work. Meshtastic is an amazing project and deserves to be enjoyed by everyone, especially given the active, friendly development and explosive growth of the community. Hopefully this guide will help you as Windows user dive into the fascinating world of low power, long range mesh radio communications with an active and very fast-growing project!

Note: This guide was written with the TTGO T-Beam v1.1 in mind as the target hardware, as it is the recommended platform at the time of this writing (and the version I’m starting with just has v1.0.0 firmware). Also, I am located in the US, so I’ll be using 915MHz hardware and the US region settings (which is now the default in 1.2.x versions of Meshtastic firmware builds).

Other note: I documented all of this with a Windows 10 x64 VM, and must admit that I am a total n00b with Python and Meshtastic on Windows – hopefully this guide will be as instructional to readers as writing it was for myself.

So… Let’s install Python! Go to Python Releases for Windows | Python.org and download the most recent installer for your Windows version – in my case, 3.9.2 for Windows 10 (if running Windows 7 or earlier, you will need to use an earlier Python version). Run the installer, and on the very first screen, make sure to check the box for “Add Python 3.9 to PATH” – this will ensure that no matter which folder/directory you might happen to be in in a command prompt, Windows will still know how to find the Python binaries.

mesh1

Click on ‘Install Now’ and let the installer complete.

mesh2

Sweet, Python is now installed on your machine, and you can click the ‘Close’ button. Now, let’s get old school and open a command prompt. Click on the Start menu button, type in ‘cmd’ and launch the ‘Command Prompt’ (if the search doesn’t find it, you can find the Command Prompt in the ‘Windows System’ folder in the Start menu):

Okay, now just type in ‘pip’ in the command prompt and you should see output very similar to this:

Fantastic! Pip is the package installer for Python – kind of like the Microsoft Store, but for Python stuff. Let’s now install Meshtastic itself by running ‘pip install meshtastic’:

Looks like the version of Pip that got installed is a little older, but that’s okay, we now have the Meshtastic Python API installed, which is what we are after! We’ll need one more piece of Python software for later, that being the flash utility itself – type in ‘pip install esptool’:

Okay, let’s see if it works by just typing in ‘meshtastic’ at the command prompt:

Success! Now, this is technically all that you need in order to communicate with your Meshtastic device. However, if you want to upgrade the firmware on your device (which you almost certainly do, given how quickly the project is advancing), you might find the ESPHome-Flasher GUI tool limiting, as it doesn’t update the partition table on the board. This may cause headaches when trying to work with the built-in webserver. So, let’s install one more tool – Git BASH. This will give us a much more powerful command line that lets us use the same flashing method as on Linux. So, go to https://gitforwindows.org/ and click the Download button right on the front page:

Run the installer, proceed through the prompts, and leave the default component options as they are:

mesh9

When you get to selecting an editor, the default choice is to use Vim. If you’re not familiar with Linux/Unix, you probably don’t want this – best to select ‘Use Notepad as Git’s default editor’, unless you know that you have one of the other options available on your system (and are comfortable using it):

mesh10

Honestly, this selection probably won’t matter much if we’re just playing with Meshtastic, as I’m not sure how the editor gets invoked, but Vim will leave an unwary user as bamboozled as a Unix greybeard will be delighted. You can proceed through the rest of the prompts leaving the defaults selected. After the installation is complete, make sure that your Meshtastic device is recognized by Windows – the first time you attach it to your computer, you should get notifications about installing the ‘CP2104 USB to UART Bridge Controller’:

mesh11

However, at least in my case, Windows didn’t install the proper drivers – open up the Device Manager in the Windows Control Panel and look for issues:

Windows doesn’t seem to know how to get the correct drivers on its own, so go to CP210x USB to UART Bridge VCP Drivers - Silicon Labs, click on the ‘Downloads’ tab at the top, and download the CP210x Universal Windows Driver:

Extract the downloaded file and run the “CP210xVCPInstaller_x64.exe” installer (or CP210xVCPInstaller_x86 if you are running 32-bit Windows). There’s no options to set, so just proceed through all the prompts:

mesh14

Once complete, you should see the device show up in Device Manager as a COM port:

If you’ve gotten this far, then your system is now all set! Now we can download the latest Meshtastic firmware – go to Releases · meshtastic/Meshtastic-device · GitHub and see what the latest version is. As of this writing, 1.2.10 just dropped, so we’ll click on the ‘assets’ section of the release notes and download the .zip file (https://github.com/meshtastic/Meshtastic-device/releases/download/1.2.10/firmware-1.2.10.zip). Extract the .zip to a folder, then right-click on that folder and select ‘Git Bash Here’:

This will open up a BASH terminal right in the target folder. Let’s make sure that we can actually run the Python tool, so just type in ‘meshtastic’ right at the dollar sign prompt:

mesh17

Great! So we’re able to run the tool in a BASH prompt. Let’s see if our system can see our board, so type in ‘meshtastic –info’:

Success! Yes, that may look like an error, but the last line tells us the full story – the board has been detected, but it’s running firmware older than v1.2. If the board wasn’t detected at all, the Exception would say “No Meshtastic devices detected”:

mesh19

So, let’s install that firmware! We’ll use the device-install script (which is why we went through all the trouble of installing Git BASH in the first place). Type ‘ls’ (which is the Unix equivalent of ‘dir’) to see all the files in the directory, and then type in ‘./device-install.sh’:

mesh20

Okay, that gives us the format that the script is expecting. Let’s cross our fingers and type in ‘./device-install.sh -f ./firmware-tbeam-1.2.10.bin’:

mesh21
mesh22

Success! We’ve now updated the device firmware to v1.2.10. The device should reboot and show us that version on the splash screen:

mesh23

Now, we should be able to run ‘meshtastic –info’ and see what the board returns:

mesh24

Success! That’s it – you should now be able to proceed with making setting changes, enabling plugins, etc.

21 Likes

I copied the guide made by “HaveBlue” and put it in the pdf file for those who want it in pdf.
The various links within the document are active.

I hope “HaveBlue” doesn’t give me a copyright strike :sweat_smile:

7 Likes

Not at all! Please feel free to copy/update/correct it.

4 Likes

Thanks :blush:

I was thinking if you could add this guide on the GitHub page as well …
It would be a great guide for those who want to use Meshtastic in the PC with Python.
I find it a well done guide with great details

2 Likes

I’d be happy to, but I need to learn how to use GitHub first!

2 Likes

Applies to meshtasttic 1.2.10 only does not work for older firmware running 1.5

I have writtien a python based meshtastic-GUI that will install everything you need, and you wont need git for grabbing the latest frimware. I am adding the ability to set pretty much every config option for users so you wont need a terminal at all if you want to get going on your projects.

Once you have python installed and configured in your PATH

python -m pip install --upgrade meshtastic-pygui

this will install all of these for you

meshtashtic
meshtastic-pygui
requets
esptool
pysimplegui

once installed you can run the program with

python -m meshtastic_pygui

5 Likes

python -m pip install -upgrade meshtastic-pygui

Thanks for this! Just a heads-up, on my Windows device, when I executed the above command, I needed to add a second hyphen in front of upgrade so it looked like this:

python -m pip install --upgrade meshtastic-pygui

2 Likes

@zebus yes, I’ve seen your excellent work - unfortunately I wasn’t able to get it to function myself, so I wrote this guide as a means to get Windows users a full command line setup that hopefully gives all the capability of a Linux system. If I have some more time, I’ll poke some more at meshtastic-pygui and see if I can provide some feedback.

2 Likes

testing is what I really need so thank you for the feedback, I only have T-Beams and Ive only tested on my windows and ubuntu machines.

The program is just one python file so you can copy the contents of main and then run it
in IDLE if you want to test making changes. The GUI just uses meshtastic API commands except for… connect to radio. I just used the example code and it seems to not work right so if anyone would like to make that better that would be super sweet

2 Likes

On a MacOS using T-Beams I was able to get this running using python3 -m meshtastic_pygui (installed using pip3 install --upgrade meshtastic_PyGUI) However I did notice that when I sent a message test with spaces in the Send Message to all area, it returned this error in my terminal

meshtastic: error: unrecognized arguments: with spaces

When I put quotations around it "test with spaces" it was able to send to ^all

3 Likes

Hmm. That sounds like zebus is running the python Api via the command line? @zebus since your app is in python I think you might be happier just using python and then calling the sendText method on interface.

1 Like

Sorry surround the text with " " and it will include space, its a bug I need to fix. The way PySimpleGUI grabs the values of the text box sees white spaces as delimiters so it needs " " in order to pass the entire string.

Ive done some stuff with the python calls but it locks up the app and you have to force close it when I call stuff with python (Im not a programmer by any means just a hobbiest). For instance the connect to radio button. It will connect but once connected it stays connected and you have to force quit.

1 Like

Also thank you for the Mac feedback, I havent been able to test that and I will update the wiki and readme

2 Likes

I’ll test it out more tomorrow for any other quirks. I don’t know python, but I’ll happily learn some to help contribute.

3 Likes

Re: need to force quit.
I think if you call interface.close() before exit it should be fine.

(Or just call sys.exit(0))

1 Like

Ii tried


interface = meshtastic.SerialInterface()

interface.close() 

but it didn’t seem to work

Hmm - is it possible you have another thread keeping your python process alive? It seems to work okay for me:

~/development/meshtastic/meshtastic-python$ python3 -c "import meshtastic; interface = meshtastic.SerialInterface(); interface.close()"
~/development/meshtastic/meshtastic-python$ 

Can you try running just this minimal python script? If it has problems on your machine would you mind opening a bug on meshtastic-python and list the OS you were using? (Also please double check you have the latest version of the meshtastic python lib)

1 Like

I just started looking into how to use threads in python :slight_smile:

1 Like

Hi all,
my first time writing here, but it is a while i’m playing around with meshtastic. I just love it! thank you so much for making it.

I recently upgraded my test network to firmware 1.2.13 wich works very well with the new android app, but I’m in trouble with the meshtastic-python under Windows 10.
with firmware 1.x and the old library all was working well, but now i’m unable to install the new version of meshtastic-python:

i’m getting this error:
“ERROR: Could not find a version that satisfies the requirement easy-table==0.0.4 (from meshtastic) (from versions: none)”
“ERROR: No matching distribution found for easy-table==0.0.4 (from meshtastic)”

python 3.8 istalled in a clean environment and pytap2 (2.1) installed without problem.

I looked everywhere in the documentation and in the forum cannot get rid of this, somebody can help me? maybe I’m not the only one

P.S. if i’m writing in the wrong place give me instructions to correct it please :slightly_smiling_face: