[M<>M Relay] - We're building a Meshtastic <-> Matrix Relay!

Hello Meshtastic Community!

We are excited to share with you our project, a Meshtastic and Matrix relay (M<>M Relay), which aims to bridge the gap between the Meshtastic mesh network and the Matrix communication platform.

Background

As an avid user of Matrix since 2018, I have always appreciated its open-source, self-hostable nature, and interoperability with existing platforms through the use of bridges, gateways, or relays. After discovering the amazing Meshtastic project, I wanted to find a way to connect these two platforms. Along with @kwmesh , we started working on the M<>M Relay a few weeks ago.

How It Works

The M<>M Relay connects to Matrix using a dedicated bot user account and relays messages between Matrix and a Meshtastic device through the Meshtastic API. To make this possible, a dedicated node on your local meshnet is required to relay messages between the two networks.

All relay settings are managed through a yaml configuration file, which includes details for the Matrix bot user (homeserver, username, access token) and Meshtastic device (serial connection or network connection, serial port or hostname/IP, and Meshnet Name). The relay supports mapping all 8 Meshtastic channels to a Matrix room in a 1:1 connection.

In Action

When messages are sent from Matrix users to Meshtastic, the Matrix display name is truncated to 5 characters + a [M] suffix (e.g., “JohnS[M]: Message”). Messages sent from the local meshnet to Matrix will include the node’s longname, meshnet name (defined in the relay’s config.yaml file), and message (e.g., “[James/OurMeshnet]: Message goes here.”).

When a Meshtastic message is relayed to Matrix, the bot creates a Matrix message event with custom keys for relaying the longname and meshnet to remote meshnets. Remote relays present in the room will use this information to send messages back to the local meshnet with the format "Jam/OurM: Message goes here " (with the longname and meshnet name truncated to save space).

Plugins and Future Development

@kwmesh has developed a plugin framework and written a few plugins, including a !map command for displaying node meshnet locations (with an optional randomized offset) and a !health command for showing battery levels and other telemetry stats. These plugins are optional and can be enabled in the config.yaml file.

Element (and many other clients) support end-to-end encryption (E2EE) optionally in its rooms. We plan to add encrypted room support to the bot, but it’s not yet implemented at the moment.

Expanding Connectivity

With the successful bridging of Meshtastic and Matrix, we have opened the door to many possibilities, as there are many existing bridges available for the Matrix network. Some examples include Discord, WhatsApp, Slack, Telegram, SMS, Twitter, Email, and more (full list available at Bridges | Matrix.org). While we haven’t extensively tested Meshtastic <-> Matrix <-> Secondary bridges, our initial tests with a Discord bridge have shown promising results.

Help Appreciated!

We welcome your contributions to the project, whether it’s helping with testing, submitting bug fixes or feature additions, developing plugins, or even just offering suggestions. We are grateful to the Meshtastic developers and community for making this possible. M<>M Relay has been a fun project to work on, and we look forward to seeing where it goes from here!

Let us know what you think and if you have any questions or suggestions. Happy meshing!

Project website: https://github.com/geoffwhittington/meshtastic-matrix-relay

Our TWIM announcement: This Week in Matrix 2023-04-28 | Matrix.org

Edit: I added a wiki page (Getting Started With Matrix & MM Relay) with instructions on how to get started with Matrix & join our project’s room. Once there it will be easier to help you get up and running with the relay for the first time.

I’ve added a few screenshots here so you can see what it looks like in both the Meshtastic Android & Element apps.

16 Likes

i think your project is greatđź‘ŤIn fact, I think the potential of meshtastic has not been fully realized. If it can be connected with other platforms, more people will be able to use it.
Would you post a picture of the actual use?

4 Likes

Need MQTT support, better if you connect directly to the hub, as a virtual device. Nice, but outdated example is here - GitHub - arankwende/meshtastic-mqtt-client: This is a simple program that accesses an MQTT server in which meshtastic routers publish messages and shows them on a gui.

5 Likes

I’m excited for your project & anything that will help me get others in my community involved as this might. I think meshtastic is great as a closed system for technically inclined people, but I’m trying to get it out to the masses, at least on a local scale, and this is a step in the right direction

It takes me a lot of time and effort that I don’t really have to upgrade firmware, so I don’t do it often but I’ll be glad to do it when your project is up and running.

2 Likes

Thank you for your kind words. I’ve added a few screenshots in a link at the bottom of the post, also a wiki page with instructions on how to get started with Matrix & join our project’s room. We need help testing and would very much like you to join us!

I agree 100%. Meshtastic is really powerful and fun to play with by itself, but connecting it to other platforms will open it to so many other possibilities.

For example, there are hosted Discord & Telegram bridges avaialble (https://t2bot.io/) that anyone can use without any technical knowledge, bridging Matrix ↔ Discord & Matrix ↔ Telegram.

All a person has to do is bridge either platform (or both, if you prefer) to a Matrix room and then run our relay and you will be able to talk to people on Meshtastic, Matrix, Telegram and/or Discord, all at the same time.

This can be set up in minutes without needing to run anything other than a copy of M<>M relay connected to a Meshtastic node on your local PC.

2 Likes

We need more help with testing, but a few nights ago I did get a chance to do some testing with MQTT and it does work with the relay already.

To get it to work all you need to do is set up MQTT in the firmware as you normally do, on the same device that you’re using as a relay. It will relay all messages to/from MQTT-enabled Meshtastic channels to the mapped rooms on Matrix.

The only thing is when viewing the room from Matrix, all packets that originate from MQTT appears as though they originate from the relay’s meshnet_name which is defined in the relay’s config. That makes sense since all MQTT traffic appears to be local on the meshnet.

I’ve attached a screenshot of our first tests. In this example we’re viewing the room as seen in Matrix. My node was connected to both MQTT (in the meshtastic firmware) and Matrix via our relay, and Laura was only connected via MQTT.


(Don’t mind the red text, it’s because my Meshtastic longname contained my Matrix display name and it sent me a notification when my display name was mentioned (by the bot). This can be disabled in Element, but if the names aren’t the same it won’t happen anyway.)

In the future, maybe we will be able to connect directly from the relay to MQTT and display the relayed names as [Longname/MQTT]: in Matrix, but for now at least it works.

Feel free to join us in our project’s room to discuss this further!

3 Likes

wooooooooooooooooo
great stuff :slight_smile: rock it

3 Likes

Relay is working! it made meshtastic extend,.It’s worth the time it takes to install.anyone like meshtastic should try it.




1 Like

Thank you @hikk2003 for helping us test and providing feedback! We welcome everyone else who would like to give it a try!

1 Like

What do people use Matrix for?

1 Like

Matrix similar to Discord or Telegram, but you can host your own server & choose from a wide variety of clients (Element is feature rich and is the most popular). It supports E2EE by default in DMs and optionally in rooms.

Matrix is an open protocol and its decentralized servers are federated so you can communicate with people on other servers. By design, it is extremely censorship resistant.

Matrix was created with interoperability in mind, so even if people don’t want to connect to Matrix directly, they can still make use of Matrix through the use bridges & relays, which are used to connect different platforms, the most recent being our relay which bridges Matrix ↔ Meshtastic.

For example, if a community had a presence on both Telegram & Discord, they could use Matrix to tie the rooms on both platforms together into unified rooms using Matrix, so people on both platforms could chat with each other. That’s a simple example. You can bridge more than two platforms at the same time too.

Personally, I use Matrix to talk to friends and family with encrypted voice/video/text. I’m also in several “Matrix Spaces” (similar to Discord Servers) which are used to organize different groups (Personal, different organizations, etc.) There’s even a Matrix room with Meshtastic users (150+) that has been steadily growing over the past few years.

Now with our bridge, from Meshtastic, I can talk to friends and family who are already on Matrix even if they don’t have a Meshtastic device themselves (and/or live far away).

Here’s a short introduction to Matrix that someone made. The video is a couple of years old so the client screenshots are outdated, but the concept and basic functionality is the same.

Here’s a more in-depth look at Element & Matrix too.

3 Likes

are there any tutorials on this or parts of it anywhere?

Which parts are you wondering about specifically? The bridges & relays? If so, the bridges hosted at t2bot.io & tchncs.de/matrix (I just checked and see they added Signal & Whatsapp recently too!) are by far the easiest to use and don’t require any special setup.

Beyond that, each bridge listed on this page requires self-hosting the bridge and in many cases requires self-hosting a matrix server too and that can get much more complicated. I do host a matrix server & have hosted bridges too. It’s a lot of fun and I think it’s definitely worth it, but it’s not nearly as easy as the other hosted options.

If you do decide you want to self-host any of the bridges, it’s best to check each project’s Github page for instructions on how to deploy them because they’re all built differently. Also, most projects have Matrix rooms where you can ask questions if you get stuck.

Hello,… great stuff to read in your post, so thank-you for that!

Of particular interest, I see you mention a Matrix room Meshtastic users. Despite my efforts, I am unable to find the room on matrix; Perhaps it was moved elsewhere since your post?

In case that Matrix room is sill up, could you DM me, or share a link. Thanks! :pray:

1 Like

Sure! Here’s some links:

Meshtastic space (unofficial) (which includes all of the rooms)

MMRelay Project room

Public Relay room a general chat room where we test MMRelay and link multiple meshnets (please help participate, with or without a relay :smiley: )

Meshtastic (unofficial) general chat room

2 Likes