Guide to install the python cli and configure your device on a raspberry pi 4
Reading messages over USB
Python script to upload node data into InfluxDB
Ooh nice, I've been tempted to do something very similar with the go libraries to create a prometheus exporter but never had the time
More on reddit.comConfiguring Channel Via Python API
Hello folks!
This is just a basic guide on how to install meshtastic on your Raspberry Pi 4 and configure your T-Beam with it. Please note that I am very much a beginner as well, so please feel free to point out any inaccuracies.
Can you interface your meshtastic device with a Rasberry Pi? Yes! There exists the python command line interface. Assuming you have the debian based raspberry pi os on your Raspberry Pi, you should be able to install Meshtastic just fine. Alternatively, there is an interesting project that also uses the meshtastic api called MeshWatch (https://github.com/datagod/meshwatch).
First, make sure that you have a data-transferable micro-usb. in this case, you will not be able to connect the TBeam to an Rpi via bluetooth unfortunately. before plugging the t-beam in, make sure that the antenna on the tbeam is screwed on or you might damage the device. i suggest you use a different laptop to flash the firmware on your meshtastic device, as I recommend you use the web flasher, which does require chrome or internet explorer. trying to flash the tbeam using the cli requires you to have esptool installed, which is a bit more tricky now since python 3.11.
after you flash the firmware on the tbeam, plug the usb to the raspberry pi. Open the terminal.
First, check if you have the necessary drivers by typing:
lsusb
you should see:
ID 1a86:55d4 QinHeng Electronics USB Single Serial for CH9102
if you don't see this, then you will have to install the CH9102 Driver here:
https://www.wch-ic.com/downloads/CH341SER_LINUX_ZIP.html
Next, check if you have python3 and pip3 installed:
python3 --version
pip3 --version
If you don’t have either one of them, you have install them by running these commands:
sudo apt-get update
sudo apt-get install python3
sudo apt-get update
sudo apt-get install python3-pip
After ensuring that both are installed, run these commands to install meshtastic:
pip3 install --upgrade pytap2
pip3 install --upgrade meshtastic
you may get a warning saying that meshtastic is installed in /home/user/.local/bin, and it will suggest for you to add the directory to your PATH. You want to make the PATH change permanent. To do this, we're going to have to edit the .bashrc file through the text editor. the native text editor on the raspberry pi os is nano.
run:
nano ~/.bashrc
scroll to the bottom of the file and paste in:
export PATH="/home/user/.local/bin:$PATH"
(or paste in the directory where meshtastic was installed)
After pasting in this line, write it out (ctrl+o), press enter, after which you'll be returned to the nano interface, where you canl press exit.
By doing this, you can now run meshtastic commands from any directory. You can confirm this by simply running:
meshtastic --help
If it returns the help guide for the meshtastic cli, the installation process is complete!
Next is the configuration process. you will have to know the port the meshtastic device is connected to. you can do that by running dmseg, and piping the results to the filter command 'grep' that looks for tty:
dmesg | grep tty
based on the information on display, you can kind of get a hint whether the port is ttyUSB* or ttyACM*. When I had mine displayed, I got both ttyACM1 and ttyACM0.
to confirm the port, i ran:
ls /dev/ttyACM*
and it returned:
/dev/ttyACM0 , which is going to be my port
finally, go ahead and run this command:
meshtastic --port /dev/ttyACM0 --export-config > file_name.yaml (just replace ttyacm0 with your port)
and to apply the yaml file, use this command:
meshtastic --port /dev/ttyACM0 --configure file_name.yaml
and now, you have your tbeam configured to the raspberry pi!
I am trying to use the Meshtastic Python library to read received messages over the USB connection to my Heltec V3 node. I based it on this example. I am able to see a TELEMETRY message arriving every 60 seconds, but nothing else. Even when I send a regular message from another node 2 feet away.
Do I have to enable something for this to work? The per-channel "uplink enabled" does not seem to be the right thing.
I already had InfluxDB and Grafana running on a VM. Wanted to keep some statistics from my nodes there. This will require a spare node connected to a network that you can access and poll. Should be able to use a node connected to a USB, but will need to change the command string.
Uses Meshtastic's python package to get the data from the node. Cron job runs every 5 minutes.
I use Grafana to graph the statistics from InfluxDB.
Sharing in case anyone is interested.
GitHub
Maybe there is an easier way to do this, but I had fun with the project.