Detects when mailbox flap is opened using a PIR motion sensor and sends a notification via LoRa.
TODO: Update this section
The first build copies files fromsrc/user_settings-examples/tosrc/user_settings/if they are missing.Update the files insrc/user_settings/with your information.src/user_settings/is intentionally a nested local Git repository used to keep private machine-specific settings and secrets out of the main project repository.Keepsrc/user_settings-examples/andsrc/user_settings/structurally aligned, but never copy secrets fromsrc/user_settings/into the example directory.Copyuser_settings-example.initouser_settings.iniand update the serial port details for your machine.
-
XIAO ESP32S3 & Wio-SX1262 Kit
-
XIAO nRF52840 & Wio-SX1262 Kit
- https://github.com/meshtastic/firmware/blob/master/variants/nrf52840/seeed_xiao_nrf52840_kit/variant.h
- https://files.seeedstudio.com/products/SenseCAP/Wio_SX1262/Wio-SX1262%20for%20XIAO%20V1.0_SCH.pdf
- Wio-SX1262 for XIAO standalone SKU
113010003 - XIAO nRF52840 kit SKU
102010710
-
PIR AM312
- https://fr.aliexpress.com/item/1005008067324301.html
- https://www.image.micros.com.pl/_dane_techniczne_auto/cz%20am312.pdf?utm_source=chatgpt.com
- ./docs/AM312-1.pdf
- ./docs/AM312-2.pdf
-
3.7 V Lipo Battery
-
PlatformIO on VSCode
-
Python tools dependencies
python3 -m pip install -r requirements.txt
This project follows the readability-identifier-naming conventions enforced by clang-tidy (see scripts/tools/.clang-tidy).
To check: ./scripts/tools/run_clang_tidy.sh [rx|tx|all]
The TX firmware (src/TX_nRF52) sleeps between transmissions using the
nRF52 System-ON Low Power mode driven directly by RTC2 and __WFE
(see sleepSecondsOrPin() in TX_nRF52_main.cpp). This keeps the
heartbeat alive while drawing only a few µA.
Two alternatives were considered:
| Mode | Idle current | Heartbeat | Wake on pin | Notes |
|---|---|---|---|---|
| ✔ SystemOnRtc | ~5 µA | yes | yes | Selected. RTC2 + __WFE, no FreeRTOS. |
| ✗ SystemOff | ~0.4 µA | no | yes | Reset on wake; RTC cannot wake the chip from System-OFF. |
A FreeRTOS-based variant (xSemaphoreTake / delay) was tried and
rejected: with SOFTDEVICE_PRESENT and USE_TINYUSB enabled by the
board file, the usbd and SoftDevice tasks defeat tickless idle, raising
the idle current by roughly three orders of magnitude.
The LoRa settings are defined in:
src/user_settings/user_settings.hsrc/user_settings-examples/user_settings.h
-
FREQCarrier frequency in MHz. SX1262 capability:150.0to960.0MHz. Legal and usable frequencies depend on the target region and local regulations. Impact: changing this mainly changes regulatory compliance, propagation characteristics, and interference exposure. Default inSX1262.h:434.0. -
BWLoRa bandwidth in kHz. Typical values:10.4,15.6,20.8,31.25,41.7,62.5,125,250,500.BW ↑ => throughput ↑, airtime ↓, sensitivity ↓, robustness in difficult environments ↓BW ↓ => throughput ↓, airtime ↑, sensitivity ↑, robustness in difficult environments ↑Default inSX1262.h:125.0. -
SFLoRa spreading factor. Valid range:6to12.SF ↑ => throughput ↓, airtime ↑, sensitivity ↑, range/penetration ↑, battery cost per message ↑SF ↓ => throughput ↑, airtime ↓, sensitivity ↓, range/penetration ↓, battery cost per message ↓Default inSX1262.h:9. -
CRLoRa coding rate denominator. Valid range:5to8.CR ↑ => redundancy ↑, airtime ↑, throughput ↓, resilience to errors/interference ↑CR ↓ => redundancy ↓, airtime ↓, throughput ↑, resilience to errors/interference ↓Default inSX1262.h:7. -
SYNCWORDLoRa sync word used to distinguish networks.0x34is reserved for LoRaWAN. Impact: changes network separation only; it does not directly improve range, speed, or power use. Default inSX1262.h:RADIOLIB_SX126X_SYNC_WORD_PRIVATE. -
POWERTX output power in dBm. Typical SX1262 range:2to17dBm.POWER ↑ => link budget ↑, range margin ↑, battery usage ↑, legal-risk/EMI risk ↑POWER ↓ => link budget ↓, range margin ↓, battery usage ↓Default inSX1262.h:10. -
PREAMBLE_LENGTHPreamble length in symbols. The effective transmitted preamble is4.25symbols longer.PREAMBLE_LENGTH ↑ => sync reliability ↑, airtime ↑, throughput ↓PREAMBLE_LENGTH ↓ => sync reliability ↓, airtime ↓, throughput ↑Default inSX1262.h:8. -
TCXO_VOLTAGETCXO control voltage in V. Used byradio.begin()on boards that drive the SX1262 TCXO. Impact: this is a hardware-matching parameter, not a tuning knob for speed or range. Wrong value can cause startup failure, unstable RF behavior, or no radio link. Default inSX1262.h:1.6. -
USE_REGULATOR_LDOUse the SX1262 LDO regulator instead of DC-DC.USE_REGULATOR_LDO = true => simplicity/compatibility may ↑, efficiency usually ↓USE_REGULATOR_LDO = false => efficiency usually ↑, but depends on board design and stabilityDefault inSX1262.h:false.
# The ESP32S3 is blocked very often.
alias esptool.py='$HOME/.platformio/packages/tool-esptoolpy/esptool.py'
esptool.py --chip esp32s3 --port $PORT erase_flash
Mac with ARM architecture can face the following error:
Adafruit_TinyUSB_Arduino arm-none-eabi-g++: Bad CPU type in executable
This can be solved by installing Rosetta:
softwareupdate --install-rosetta --agree-to-license
If the VS Code linter does not recognize project include paths or board constants such as LED_RED:
- Open
user_settings.ini. - Check
default_envs. - Make sure
seeed_xiao_nrf52840-txis the first entry indefault_envs.
Copyright (C) 2025, GPL-3.0-or-later, Nicolas Jeanmonod, ouilogique.com