Meshtastic is a LoRa-based communication technology that makes it possible to create mesh networks made up of nodes. In these networks, messages often do not travel directly from the source node to the destination node. Instead, they “hop” from one node to another until they reach their final destination.
This operating mode helps extend the range of the network and keeps communication available even when two devices are not within direct radio range of each other. But in addition to relaying messages inside the mesh, some nodes can also perform a special role: they can act as gateways.
A Meshtastic gateway works as a bridge between the LoRa network and the Internet. This makes it possible to connect distant meshes or send data to external services, servers, or monitoring platforms.
In this article, I will show you how to build a gateway using the M5Stack C6L Unit, taking advantage of its dual communication capability: LoRa to connect to the Meshtastic mesh, and Wi-Fi to connect to the Internet.
I will also show you a simple example where a pair of nodes send telemetry data through the mesh. This data is published to an MQTT broker by the gateway and then retrieved from a computer using Node-RED to feed a dashboard.
Meshtastic NodesMeshtastic is an open-source, decentralized communication platform that uses LoRa radio technology. It allows users to send messages and GPS coordinates without relying on traditional infrastructure such as the Internet or cellular networks, operating on license-free frequencies according to each region.
Each device that takes part in the mesh is called a node. These nodes can be fixed, installed on rooftops, poles, or elevated locations to improve coverage and strengthen the network. They can also be portable, like small radios or trackers used to send messages or position data.
Nodes can be purchased ready to use, or they can be built with some basic electronics knowledge. Today, several development boards already integrate most of the required circuitry, so the remaining tasks are usually connecting the battery, adding a solar panel, and mounting everything inside a suitable outdoor enclosure.
Currently, the most commonly used boards are based on either the ESP32 or the nRF52840, with several models available from different manufacturers.
ESP32-based boards have the advantage of combining LoRa, through an external radio module, with built-in Wi-Fi and Bluetooth connectivity. On the other hand, boards based on the Nordic nRF52840 chip do not include Wi-Fi, but they offer lower power consumption, which is very important for battery- or solar-powered nodes.
As mentioned at the beginning, in a Meshtastic network, messages do not necessarily travel directly from one device to another. Instead, they hop from node to node until they reach their destination.
This operating mode makes the network resilient: if one or more nodes stop working, messages can find alternative routes and continue moving through the mesh.
One or more nodes inside the network can be configured to work as gateways. A gateway acts as a bridge between the Meshtastic LoRa network and the Internet, allowing messages or data generated inside the mesh to be sent to other services or platforms.
To do this, the gateway must be able to connect to both networks: on one side, the Meshtastic LoRa network; on the other, the Internet, for example through Wi-Fi or Ethernet.
Once connected, the gateway can take certain messages or data circulating through the LoRa network and publish them to a server using the MQTT protocol. A server that uses this protocol is usually called a broker. From there, the information can be used by different external applications.
For example, a service can read the data published to the broker to process it, store it, or display it on a dashboard. This is especially useful when working with telemetry information such as temperature, location, battery status, or data from remote sensors.
Another possible use for a gateway is connecting meshes that are outside LoRa radio range. A node located in a geographically distant area can receive messages from other nodes through MQTT. In this way, it is possible to extend the reach of the network beyond the physical limitations of LoRa.
However, this extension depends on the Internet, which means giving up part of one of Meshtastic’s main advantages: its ability to work as an autonomous, decentralized network independent of traditional communication infrastructure. For this reason, some user communities prefer to limit gateway use and prioritize radio-only communication.
Now let’s take a look at some of the key features and possible applications of the M5Stack C6L Unit.
Features
The M5Stack C6L Unit is based on Espressif’s ESP32-C6, a powerful multiprotocol SoC that integrates two 32-bit RISC-V processors: a main processor running at 160 MHz and a low-power processor running at 20 MHz, along with 16 MB of Flash memory.
The ESP32-C6’s connectivity capabilities, including 2.4 GHz Wi-Fi 6 and Bluetooth Low Energy, are complemented by an SX1262-based LoRa transceiver capable of operating in the 868 to 923 MHz band.
In addition, the C6L includes a 0.66-inch monochrome OLED display with a resolution of 64 × 48 pixels, a WS2812C RGB LED, a buzzer, and two buttons: one multipurpose user button and another button used for power, reset, and entering BOOT mode.
For connecting external peripherals, the C6L includes a Grove interface through a 4-pin HY2.0 connector. The enclosure also features holes compatible with LEGO-style mounting systems.
The unit is powered with 5 V through a USB-C connector, which is also used for programming the device. The unit does not include an internal battery, so an external power source must be added if you want to keep it running independently.
Applications
Thanks to its ability to work with both Wi-Fi and LoRa networks, together with its two antennas, the C6L Unit can be useful in several types of applications.
- When integrated into a Meshtastic network, it can work as a portable node for messaging and location sharing during outdoor activities or emergency situations. It can also be used as a fixed node within the network infrastructure, or as a gateway that links the LoRa network to the Internet through Wi-Fi.
- In private LoRa networks, it is suitable for remote monitoring applications in areas such as agriculture, industry, or environmental sensing.
- Thanks to its Wi-Fi connectivity, it can also be integrated into home automation, security, or short-range sensing systems, sending data to MQTT servers, web dashboards, or platforms such as Home Assistant.
You can find more information about the C6L on the M5Stack website.
Building the GatewayAfter this introduction to the gateway concept in Meshtastic, and to the features and possible applications of the C6L, let’s go through the step-by-step process of building this gateway.
In the following image, you can see the assembled and working device, with each of its components identified. Let’s take a closer look at them.
Enclosure
The gateway electronics are housed inside a 20 cm × 20 cm IP65-rated plastic waterproof enclosure, which protects the system from harsh weather conditions.
On the bottom of the enclosure, I mounted a 3 mm thick MDF plate, laser-cut to the exact size, to use as a base for the rest of the components. MDF may not be the best choice because it can absorb moisture, but I wanted to test it because it is convenient and easy to have this type of plate cut.
Batteries
To power the gateway, I use three rechargeable 3.7 V 18650 batteries. More specifically, I used Panasonic NCR18650-BD cells, which have given me excellent results. These batteries theoretically have a capacity of 3000 mAh, so the whole pack can store a good amount of energy to keep the node running during the low-sunlight days ahead.
A piece of advice: do not try to save money by using low-quality batteries, unknown brands, or even branded batteries sold at suspiciously low prices. Batteries are a key component in any node, and using good-quality cells will help ensure proper autonomy, long service life, and trouble-free operation. It is worth the investment.
Power Management Controller
This is a key component that performs several functions. It is not only responsible for charging the batteries using the energy from the solar panel, but it must also protect them under different conditions in order to optimize operation and extend their service life.
For this project, I chose a Waveshare board that is quite complete, since it integrates several important functions and provides an all-in-one solution for power management:
- Charges the batteries from a solar panel
- Accepts panels with an output voltage between 6 and 24 V
- Supports MPPT to optimize panel efficiency
- Includes LEDs to indicate battery and panel status
- Charges the batteries from a USB-C input
- Provides a 5 VDC / 3 A output
- Includes different types of connectors and terminal blocks
Protects the batteries against:
- Overcharge
- Overdischarge
- Reverse polarity
Waveshare offers several different board models with similar features. The one I used is the “D” model. You can find more information about this model, as well as a comparison with the other boards, in the Waveshare Wiki.
C6L Unit
The C6L is the heart of the gateway. It is screwed to the bottom of the enclosure and powered from the power management board using a recycled USB-C cable.
It includes both antennas: LoRa and Wi-Fi. In this first version, I preferred to use the original antennas inside the enclosure, but I plan to connect an external LoRa antenna later to achieve higher gain and, therefore, longer range.
Solar Panel
To achieve good autonomy, especially during winter months when solar radiation is lower, I connected a 10 W solar panel, along with its corresponding brackets for mounting it on a pole.
Before configuring the node to work as a gateway, you should make sure that the unit is running the latest version of the Meshtastic firmware.
To do this, you can use the firmware update tool available on the meshtastic.org website.
In my case, I started with version 2.7.15, which is known to be quite stable, but I had issues with the Wi-Fi connection. I later installed version 2.7.20, which worked without problems. Apparently, ESP32-C6 support in the Meshtastic firmware is still under development, so you may find differences between one firmware version and another.
With the firmware updated, you can proceed with the configuration so the node can work as a gateway.
ConfigurationFor a node to work properly inside a mesh, several parameters must be correctly configured. Some of these parameters include the region, the node name, the channels to be used, and so on. I will not go into detail about each of these settings. Instead, I will focus only on the configuration specifically related to gateway operation.
Important: the most common way to configure a node is through the Meshtastic app using Bluetooth. However, when Wi-Fi is enabled, the Bluetooth connection is lost. This is a limitation of the Meshtastic firmware. For this reason, I recommend doing the configuration using a USB cable and the web client at https://client.meshtastic.org
Let’s review two important configurations: Wi-Fi and MQTT. At the end, I will also add a note about the node role.
Wi-Fi Configuration
Wi-Fi must be enabled, and you need to enter the name of the network the unit will connect to, along with its password:
On the C6L OLED display, a new menu becomes available where you can check the connection status:
MQTT Configuration
Next, MQTT must be enabled and configured. This is done in several parts of the configuration.
In the radio configuration:
In the primary channel configuration, enabling at least Uplink:
And in the module configuration, where some values related to the MQTT server or broker are defined.
To test the gateway, I suggest using a public broker. I ran my tests using the EMQX broker with the following configuration:
Host: broker.emqx.io
Port: 1883
TLS: OFF
Username: empty
Password: emptyIn the web client, it looks like this:
The public broker does not require a username or password, but the configuration client still fills in those fields, generating a random password.
It is important to enable the use of the JSON format so that later you can view the information stored in the broker more clearly, instead of seeing it in binary format.
Role Configuration
The role of a node defines how it will behave inside the mesh, both in relation to the messages it originates and the messages it receives from other nodes.
The most commonly used role is probably CLIENT, which is the default role, but there are others such as CLIENT_MUTE, ROUTER, TRACKER, SENSOR, and so on. There is no GATEWAY role.
In this particular case, the node will not be placed in a privileged location and will not perform a strategic wide-coverage function, so there is no real reason to configure it as ROUTER. At the same time, I want it to be able to retransmit the messages it receives over LoRa, so I will discard CLIENT_MUTE. It also does not make sense to use specialized roles such as SENSOR or TRACKER, since the goal is for the device to remain integrated into the mesh as a general-purpose node.
For that reason, the most appropriate configuration is to leave it with the CLIENT role.
Checking the OperationNow it is time to test that all of this works and has some practical use.
For this, I suggest an application that monitors the battery voltage of two nodes in a mesh through a dashboard built with Node-RED. The nodes send telemetry information using LoRa, and the gateway publishes it to the broker, from where it is retrieved by the Node-RED flow.
The first step is to configure the nodes so they send telemetry data:
Next, we will use an MQTT client to subscribe to the broker and see the information sent by those nodes. I recommend MQTTX, which is quite simple to use.
After entering the EMQX broker data and the topic where the gateway publishes, you can see different packets arriving: device information packets (nodeinfo), position packets (position), and telemetry packets (telemetry), which are the ones we are interested in for this demonstration. These packets are published under a subtopic that identifies the gateway node (814ffff8):
This confirms that the gateway is working.
The next step is to do something with this information. We need to create some type of application that subscribes to the same topic and displays some of the received data in a more user-friendly way.
A simple and very educational tool for doing this is Node-RED, which is free and can run on different platforms. For this proof of concept, I created the following flow:
This flow starts with a block subscribed to the topic salsimesh/2/json/# to capture the data sent by the gateway. Its output is converted to JSON, and then the JSON is parsed to obtain the battery voltage using the function 1 block:
The output of function 1 is displayed in debug 1, and also feeds two switch blocks that check the node numbers in order to show the corresponding battery voltage on each gauge. For example, for Bat1:
If the node identifier is 138817e7 in hexadecimal, it sends the voltage value to gauge Bat1. The other block does the same with the second node, which has a different identifier and a different gauge.
The dashboard with the two gauges looks like this:
It is important to note that the nodes do not have MQTT enabled. Instead, they send their telemetry through the mesh, and the gateway captures that information and uploads it to the broker.
The information flow can be summarized graphically as follows:
In this article, we saw what a gateway is and what role it can play inside a Meshtastic mesh. Using the M5Stack C6L Unit, we built a node capable of communicating with the mesh over LoRa while also connecting to the Internet through Wi-Fi.
To verify its operation, we ran a simple but very representative test: two nodes sent their telemetry over LoRa, the gateway published it to an MQTT broker, and then Node-RED retrieved that data and displayed it on a dashboard.
This allowed us to see how a Meshtastic network can keep working locally and autonomously, while also opening a door to external applications for monitoring, logging, and data visualization.
This is just one example, but it clearly shows the possibilities that appear when a Meshtastic network is connected to the Internet, as well as the potential offered by the C6L Unit. From this starting point, many other applications can be imagined.
As always, if you have any questions or suggestions, feel free to leave them below in the comments section.
See you next time! 🚀











Comments