CapiBridge
Gateway between WIFI / LoRa / ESPNOW
Install / Use
/learn @PricelessToolkit/CapiBridgeREADME
🤗 Please consider subscribing to my YouTube channel. Your subscription goes a long way in backing my work. If you feel more generous, you can buy me a coffee
CapiBridge is an open-source one-way gateway for low-power devices. It supports various communication technologies, including LoRa, ESP-NOW, and WiFi. The gateway receives JSON strings from LoRa and ESP-NOW DIY devices and publishes them to an MQTT server. It automatically separates the JSON string into dynamic MQTT topics based on keys within the JSON, such as "b" for battery or "m" for motion, making it highly compatible with Home Assistant. This gateway simplifies adding new DIY nodes/sensors to your smart home by standardizing the communication protocol across all your DIY projects, focusing on simplicity and unified protocol handling.
<img src="https://raw.githubusercontent.com/PricelessToolkit/CapiBridge/main/img/video.jpg"/>
🛒 Where to buy http://www.PricelessToolkit.com
🚀 Sensors that work out of the box with CapiBridge.
- PirBOX-LITE LoRa Long-Range Motion Sensor for Mailbox/Garage.....
- PirBOX-MAX LoRa Long-Range 2-Way Motion Sensor with reed switch inputs and relays
- SOILSENS-V5W Soil Moisture Sensor
Specifications
- 1x LoRa Module 868 or 433MHz
- 2x ESP32-C3
- ESP1 Free GPIOs
- IO7, IO10
- ESP2 Free GPIOs
- IO10, IO3, IO1, IO0, IO4, IO5, IO6, IO7
- Power Pins 5V, 3.3V, GND
- USB-C with auto reset
- UART switch for selecting ( ESP1 | ESP2 )
- Buttons for flashing and resetting
- Debug LEDs
- USB - TX, RX
- ESP1 to ESP2 - TX, RX
- One LED for LoRa
- One LED for ESP-NOW
[!IMPORTANT] A high-quality phone charger should be used to ensure a stable 5V power supply.
📣 Updates, Bugfixes, and Breaking Changes
- 28.03.2026
- Added support for "Ra-01S" 433Mhz Module.
#define LORA_MODULE LORA_MODULE_SX1268 // Ra-01S 433Mhz Module "433Mhz Version" Module CapiBridge v2
- 25.08.2025 - Breaking Change (XOR obfuscation "Encryption" for ESP-NOW).
- Possibility to Enable/Disable Encryption separately for LoRa and ESP-NOW
- 2-way communication, For LoRa and ESP-NOW
- 18.08.2025 - Hardware modification, The new LoRa module RA-01SH "SX1262"
- Added option to select LoRA module type via config.
//#define LORA_MODULE LORA_MODULE_SX1276 // SX1276 Module (orders shipped before Aug 2025)
#define LORA_MODULE LORA_MODULE_SX1262 // SX1262 Module CapiBridge v2 (orders shipped after Aug 2025)
- 22.05.2025 - Breaking Change (XOR obfuscation "Encryption" for LoRa).
-
- All LoRa sensors' firmware needs to be updated.
- 14.05.2025 - 2-way communication, for now only "LoRa".
- 02.03.2025 - ESP-NOW "ESP2" Serial outputs incorrect MAC address "00:00:00..."
- 25.11.2024 - Button autodiscovery topic.
- 28.07.2024 - Binary sensors topics and Motion sensor autodiscovery.
- 15.06.2024 - Publishing battery in percent.
[!NOTE] If you're ready to contribute to the project, your support would be greatly appreciated. Due to time constraints, I may not be able to quickly verify new "features" or completely new "code" functionality, so please create a new code/script in the new folder.
Do you want to assemble it yourself?
This project is open-source, allowing you to assemble CapiBridge on your own. To simplify this process, I've provided an "Interactive HTML Boom File" located in the PCB folder. This interactive file helps you identify where to solder each component and polarity, reducing the chances of errors to a minimum. But if you don't feel confident in assembling it yourself, you can always opt to purchase a pre-assembled board from my Shop https://www.pricelesstoolkit.com
Schematic
<details> <summary>View schematic. Click here</summary> <img src="https://raw.githubusercontent.com/PricelessToolkit/CapiBridge/main/PCB/V1_SX1276/capibridge_schematic.jpg"/> <img src="https://raw.githubusercontent.com/PricelessToolkit/CapiBridge/main/PCB/V2_SX1262/capibridge_schematic_v2_SH.jpg"/> </details>Links for antennas and cables.
- 2.4Ghz Antenna + Cable https://s.click.aliexpress.com/e/_DE0sJ7N
- Cable UFL to SMA https://s.click.aliexpress.com/e/_Dnee0tV
- Antenna 433 MHz SMA male https://s.click.aliexpress.com/e/_Dm2X9vv
- Antenna 868 MHz SMA male https://s.click.aliexpress.com/e/_Dczm4y7
Before you start
<img src="https://raw.githubusercontent.com/PricelessToolkit/CapiBridge/main/img/3D_open3.JPG"/>[!WARNING]
🔥Connect all antennas first to prevent damage to the transmitter.🔥
[!IMPORTANT] If you're new to Arduino-related matters, please refrain from asking basic questions like "how to install Arduino IDE". There are already plenty of excellent tutorials available on the internet. If you encounter any issues to which you can't find the answer -> Here , feel free to join our Facebook Group or open a new discussion topic in the dedicated tab. Remember that providing detailed information about the problem will help me offer more effective assistance. More information equals better help!
Arduino IDE Configuration
[!NOTE] Arduino IDE 2.3.2
Used Arduino Libraries
#include <Arduino.h>
#include <SPI.h>
#include <RadioLib.h>
#include <WiFi.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include <esp_now.h>
CapiBridge is based on ESP32-C3, so if you are using ESP32 for the first time, you need to install the ESP32 board and all libraries in your Arduino IDE.
- In your Arduino IDE, go to File> Preferences.
- Enter
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.jsoninto the “Additional Boards Manager URLs” field. Then, click the “OK” button - Open the Boards Manager. Go to Tools > Board > Boards Manager and search for ESP32 and press the install button for the “esp32 by Expressif Systems“
- Open Library Manager, search for PubSubClient and press the install button, do the same for other libraries.
ESP1.ino sketch configuration
[!NOTE] For
ESP1.inoAll configurations are done in the fileconfig.h
Gateway Separation and Encryption Keys
[!IMPORTANT] Unique
GATEWAY_KEYwithin the JSON to differentiate your data from others, andencryption_keyto globally encrypt the payload. Must match the key in Nodes/Sensors.
#define GATEWAY_KEY "xy" // Separation Key "Keep it small" Must match exactly sensors key
#define LoRa_Encryption true // Global LoRa Encryption, true or false
#define ESPNOW_Encryption false // Global ESP-NOW Encryption, true or false
#define encryption_key_length 4 // must match number of bytes in the XOR key array
#define encryption_key { 0x4B, 0xA3, 0x3F, 0x9C } // Multi-byte XOR key (2–16 bytes)
🔐 How to Create Your encryption_key Using a Calculator
-
Choose a few numbers between
1and255
These will be your secret key values.
Example:5,162,77,33 -
Open your calculator:
- Windows: Open the Calculator app → Click the ☰ menu → Choose Programmer
- Or use any online converter (Google: "decimal to hex converter")
-
Convert each number to HEX:
- Type your decimal number (e.g.,
5) - Switch to HEX mode
- You’ll see the result (e.g.,
0x05)
- Type your decimal number (e.g.,
-
Use the converted HEX values in your config:
#define encryption_key { 0x05, ...., ...., .... }
#define encryption_key_length 4
Select the LoRa module that CapiBridge uses.
//#define LORA_MODULE LORA_MODULE_SX1276 // SX1276 Module (orders shipped before Aug 2025)
#define LORA_MODULE LORA_MODULE_SX1262 // SX1262 Module CapiBridge v2 (orders shipped after Aug 2025)
WIFI Configuration
#define WIFI_SSID ""
#define WIFI_PASSWORD ""
MQTT Server Configuration
#define MQTT_USERNAME ""
#define MQTT_PASSWORD ""
#define MQTT_SERVER ""
#define MQTT_PORT 1883
#define DISCOVERY_EVERY_PACKET true // true = publish discovery every time data is received from that sensor
// false = publish discovery once per CapiBridge boot (remembers if that sensor is already published)
// Using false reduces MQTT traffic, but if you delete a sensor in Home Assistant,
// you must reboot CapiBridge to clear the cache so it can rediscover that sensor
LoRa Configuration
[!IMPORTANT] LoRa configuration must match the configuration in Nodes/Sensors.
#define BAND 868.0 // 433.0 / 868.0 / 915.0
#define LORA_TX_POWER 20 // dBm; check regulatory limits in your region (SX1262 supports up to 22) (SX1276 supports up to 20)
/// Bandwidth vs SF support (SX126x):
// 125 kHz: SF5–SF9
// 250 kHz: SF5–SF10
// 500 kHz: SF5–SF11
#define LORA_SIGNAL_BANDWIDTH 250.0 // kHz: 125.0, 250.0, 500.0
#define LORA_SPREADING_FACTOR 10 // "5–11 on SX1262" "6-12 on SX1276"
#define LORA_CODING_RATE 5 // 5–8 → coding rate 4/5 ..
