A custom ESP32 firmware that bridges Meshtastic mesh networks with Telegram, enabling remote monitoring and control of your mesh network via Telegram bot.
- Full Meshtastic Mesh Node β Complete routing, node database, packet history
- ROUTER Mode Optimized β Configured as stationary repeater (no device telemetry broadcasts)
- Telegram Bot Integration β Bidirectional message forwarding between mesh and Telegram
- WiFi + SSL/TLS β Secure connection to Telegram API
- LoRa TX/RX β Full mesh repeater functionality
- Optimized RAM Usage β ~155KB free RAM (BLE and OLED disabled)
- OTA Swap Bootloader β Custom Arduino user bootloader (OTA_0) shows splash, launches Gateway (OTA_1)
- Interactive Commands β
/nodes,/map,/status,/configvia Telegram - NVS Configuration β WiFi, Telegram, and LoRa settings stored in Non-Volatile Storage
- Hardware: ESP32 (no PSRAM) + SX1276/RFM95 LoRa module
- RAM: ~110KB used, ~155KB free (sufficient for SSL/TLS)
- Flash: 4MB (Gateway ~1.68MB + User Bootloader ~790KB)
- Network: 2.4GHz WiFi, Internet for Telegram
Two firmware components:
user_bootloader/(OTA_0) - Arduino-based bootloader with config portal built-inMeshtastic_original/firmware/(OTA_1) - Full Gateway firmware
That's it! No boot selector, no separate config firmware - everything is consolidated.
git clone <your-repo-url> meshtastic-telegram-gateway
cd meshtastic-telegram-gatewayImportant: The original Meshtastic firmware is not included in this repository. Clone it separately:
git clone https://github.com/meshtastic/firmware Meshtastic_original/firmware
cd Meshtastic_original/firmware
git checkout v2.7.13 # Or latest stable version
cd ../..pip install platformio esptoolCopy the modified Meshtastic files (see SETUP.md for detailed instructions):
# Quick copy command
for file in modified_meshtastic_files/src/*.example; do
cp "$file" "Meshtastic_original/firmware/src/$(basename ${file%.example})"
done./flash_complete_system.sh /dev/tty.usbserial-0001This script:
- Builds the User Bootloader (
OTA_0 @ 0x10000) - with splash + config AP - Builds the Gateway firmware (
OTA_1 @ 0x100000) - Meshtastic + Telegram - Generates the OTA-swap partition table
- Flashes everything (bootloader, partitions, OTA_0, OTA_1)
- Opens serial monitor
# Build user bootloader
cd user_bootloader
pio run -e user_bootloader
# Build gateway
cd ../Meshtastic_original/firmware
pio run -e custom-sx1276-telegram-gateway || true
python3 ~/.platformio/packages/tool-esptoolpy/esptool.py --chip esp32 \
elf2image --flash_mode dio --flash_freq 40m --flash_size 4MB \
-o .pio/build/custom-sx1276-telegram-gateway/firmware.bin \
.pio/build/custom-sx1276-telegram-gateway/firmware.elf
# Generate partition table
python3 ~/.platformio/packages/framework-arduinoespressif32/tools/gen_esp32part.py \
Meshtastic_original/firmware/variants/esp32/diy/custom_sx1276_oled_telegram/partitions_ota_swap.csv \
partitions_ota_swap.bin
# Flash (adjust port)
esptool.py --chip esp32 --port /dev/tty.usbserial-0001 --baud 460800 \
write_flash -z --flash_mode dio --flash_freq 40m --flash_size detect \
0x1000 user_bootloader/.pio/build/user_bootloader/bootloader.bin \
0x8000 partitions_ota_swap.bin \
0x10000 user_bootloader/.pio/build/user_bootloader/firmware.bin \
0x100000 Meshtastic_original/firmware/.pio/build/custom-sx1276-telegram-gateway/firmware.binAfter flashing, configure the gateway:
Required settings:
- WiFi SSID/Password
- Telegram Bot Token (from @BotFather)
- Telegram Chat ID
- LoRa Region (e.g.
EU_868,US) - LoRa Modem Preset (e.g.
LONG_FAST)
/helpβ Show available commands/configβ View current configuration and setup instructions/nodesβ List visible mesh nodes/mapβ Show GPS nodes on an interactive map/statusβ Gateway status and diagnostics- Any text message β Broadcast to the mesh network
Power On β ESP32 ROM bootloader β OTA_0 (User Bootloader)
β Shows splash + diagnostics
β Checks BOOT button (hold 3s for config mode)
β Boots OTA_1 (Gateway) via esp_ota_set_boot_partition
β Gateway runs (Meshtastic + Telegram)
β Gateway sets boot partition back to OTA_0 for next reboot
Partition Layout:
- OTA_0 (
0x10000, 960KB): Arduino-based User Bootloader (splash screen, config AP mode) - OTA_1 (
0x100000, 3MB): Full Gateway firmware (Meshtastic + Telegram + ROUTER mode) - OTA data (
0xE000, 8KB): Boot partition selector (managed automatically) - SPIFFS (
0x3F0000, 64KB): Configuration storage (WiFi, Telegram, LoRa settings)
- Full Meshtastic mesh routing, node database, packet history
- LoRa TX/RX (full repeater)
- Position & telemetry modules
- Telegram bot with SSL/TLS
- WiFi STA mode
- BLE/Bluetooth: Disabled to save ~30KB RAM for SSL operations
- OLED display: Disabled to save ~15KB RAM for SSL operations
- Audio, store-forward, traceroute, canned message modules, etc.
Note: Initial configuration is done via User Bootloader's WiFi AP + Web Portal (no BLE needed)
- LoRa module: SX1276/RFM95 (433/868/915 MHz)
- Pins: See
variant.hin the custom variant directory- LoRa SPI: SCK=5, MISO=19, MOSI=27, CS=18
- LoRa Control: IRQ=26, RESET=14
- BOOT button (GPIO0) reserved for future AP/Web config trigger
- Gateway loops "LoRa tx disabled: Region unset" β Configure LoRa region/modem in NVS
- Telegram not responding β Check Bot Token/Chat ID, WiFi, RAM (>100KB)
- First boot loops twice β Expected: User Bootloader sets boot partition, then runs Gateway
- WiFi fails β Confirm 2.4GHz network + correct credentials
- "Device Role: 0" (CLIENT) instead of 2 (ROUTER) β Perform factory reset to clear old config:
# Via serial monitor: factoryreset # OR erase SPIFFS partition: python3 ~/.platformio/packages/tool-esptoolpy/esptool.py --chip esp32 \ --port /dev/tty.usbserial-0001 erase_region 0x3F0000 0x10000 - "Packet History - Invalid size -1" warning β Update to latest firmware (fixed in Router.cpp)
- Build error "program size too large" β Ensure
board_upload.maximum_size = 3080192is set in platformio.ini
Check serial output for:
INFO | ??:??:?? 1 Device Role: 2
ROUTER mode indicators:
- β No device telemetry broadcasts at 60-second intervals
- β Full packet relaying and routing
- β Lower mesh traffic from gateway itself
SETUP.mdβ Complete setup and installation guidedocs/USER_BOOTLOADER_README.mdβ Details of the OTA swap user bootloaderdocs/OTA_SWAP_README.mdβ Flash layout, boot flow, troubleshootingdocs/MESHTASTIC_MODIFICATIONS.mdβ Technical details of firmware modificationsdocs/CHANGELOG.mdβ Version history and migration guidesdocs/hardware/pinout.mdβ Hardware pinout and GPIO configuration
modified_meshtastic_files/β All modified Meshtastic firmware files with .example suffixmodified_meshtastic_files/README.mdβ Guide to applying modificationsmodified_meshtastic_files/MODIFICATIONS_SUMMARY.mdβ Complete changelog with line numbers
- OTA swap bootloader support (boot partition management)
- ROUTER mode as default for gateway deployments
- Telegram module WiFi AP name corrections
- Packet history optimization (50 entries, no warnings)
- RAM optimizations (BLE/OLED/sensors disabled)
See modified_meshtastic_files/MODIFICATIONS_SUMMARY.md for detailed technical documentation of all changes.
Help wanted on:
- User Bootloader AP + web config (save WiFi/Telegram/LoRa to NVS)
- Telegram command enhancements
- Additional diagnostics/telemetry
- Testing across board variants
This project extends Meshtastic firmware. See Meshtastic license for details.
- Meshtastic Project
- UniversalTelegramBot
- Arduino-ESP32 maintainers & contributors
Status: β Production Ready - OTA swap bootloader architecture is fully functional and optimized for ROUTER mode gateway deployments.