Files
meshtastic_firmware/variants/nrf52840/diy/moonshine_NRF52_ebyte
kevin 325bc2b2c4 feat: add moonshine_NRF52_ebyte variant (Ebyte nRF52840 + E22-400M33S)
DIY Meshtastic node using an Ebyte nRF52840 MCU module with LFXO crystal
and E22-400M33S LoRa module (SX1268, 433MHz, 33dBm).

Pin assignments:
- LED (LED_PAIRING): P0.15, LED_LORA DIO1: P1.10, BUSY: P0.28 (AIN4)
- LORA_CS: P0.17, RESET: P1.13, RXEN: P1.09, SPI: P0.20/P0.22/P1.00
- VBAT_ADC: P0.03 (0.5 divider), CHAG_DET: P0.13, BUZZER: P1.11
- BUTTON: P0.24, I2C: SDA=P0.08/SCL=P0.04 (wired, no devices)

PA parameters derived from E22-M UserManual V1.2 power curve (not from
E22-900M33S which uses a different PA with 25dB gain):
- SX126X_MAX_POWER=21, TX_GAIN_LORA=12 (chip 21dBm -> module ~33.5dBm)
- DIO2_AS_RF_SWITCH with MCU-controlled RXEN, TCXO 1.8V (TCXO_OPTIONAL)

USB CDC serial enabled by default (nRF52840 built-in). No GPS/screen/
I2C devices. Uses S140 v6 SoftDevice (matches nice!nano bootloader).
Flashable via USB (1200bps touch DFU) or UF2 drag-and-drop.
2026-07-27 17:48:01 +08:00
..

Moonshine NRF52 ebyte

DIY Meshtastic node variant based on an Ebyte nRF52840 MCU module and E22-400M33S LoRa module.

Hardware

  • MCU module: Ebyte nRF52840 (512 KB flash / 128 KB RAM)
  • LF clock: 32.768 kHz crystal (USE_LFXO)
  • LoRa: E22-400M33S (SX1268 + 33dBm PA, 2W, 433MHz) - SX126X_MAX_POWER=8, TX_GAIN_LORA=25. SX126X_RXEN (P1.09) is MCU-controlled by RadioLib; TXEN is driven by DIO2 (SX126X_DIO2_AS_RF_SWITCH). TCXO voltage 1.8V with TCXO_OPTIONAL fallback to XTAL.
  • LED: Bluetooth pairing status on P0.15 (LED_PAIRING). Solid on = BLE connected, slow blink = unpaired, fast blink = pairing, off after 30s idle.
  • Battery ADC: 0.5 voltage divider (equal resistors)
  • USB CDC serial: enabled by default (nRF52840 built-in USB-ACM). Debug output and Meshtastic CLI communication go through the USB serial port.
  • I2C: SDA/SCL pins wired (P0.08/P0.04) but no I2C devices connected.

Pin map

Function Pin Notes
LED P0.15 Bluetooth pairing status
CHARGE_DET P0.13 Active high (charging)
BUTTON P0.24 User button
BUZZER P1.11 PWM buzzer
BATTERY_ADC P0.03 AIN1, 0.5 divider
IIC_SDA P0.08 Wired, no device
IIC_SCL P0.04 Wired, no device
SPI_MISO P1.00
SPI_MOSI P0.22
SPI_SCK P0.20
LORA_CS P0.17
LORA_DIO1 P1.10 IRQ
LORA_BUSY P0.28 AIN4 (AI4)
LORA_RESET P1.13
LORA_RXEN P1.09 MCU-controlled RXEN; TXEN via DIO2

Build & Flash

Build

pio run -e moonshine_NRF52_ebyte

Uses PRIVATE_HW (HardwareModel 255) - no protobuf or architecture.h changes required.

The build links against nrf52840_s140_v6.ld, so the application is linked to start at 0x26000 and requires the S140 SoftDevice v6.x to be present on the chip at 0x0-0x25FFF. The build output (firmware-*.hex / .uf2) contains only the application, not the SoftDevice.

Flash via USB (nice!nano)

The nice!nano comes pre-flashed with the S140 v6 SoftDevice and the Adafruit UF2 bootloader. No SWD probe is needed - firmware can be uploaded over USB.

Method 1: PlatformIO serial DFU (recommended)

pio run -e moonshine_NRF52_ebyte -t upload

PlatformIO opens the USB CDC serial port at 1200 baud to trigger the DFU bootloader, then uploads via nrfutil serial DFU. The board automatically resets into the application after upload.

Method 2: UF2 drag-and-drop

  1. Double-tap the Reset button to enter UF2 bootloader mode. A USB mass storage volume will appear (e.g. NRF52BOOT).
  2. Copy the .uf2 file from .pio/build/moonshine_NRF52_ebyte/firmware-*.uf2 to the USB volume.
  3. The board automatically resets into the application after the file transfer completes.

Flash via SWD (alternative)

If the SoftDevice or bootloader is missing or corrupted, flash via SWD with OpenOCD (CMSIS-DAP / J-Link / ST-Link):

# Full flow: recover (erase all + unlock) -> SoftDevice -> app -> reset
openocd -f interface/cmsis-dap.cfg -f target/nrf52.cfg \
  -c "init; nrf52_recover; \
      program bin/s140_nrf52_7.3.0_softdevice.hex verify; \
      program .pio/build/moonshine_NRF52_ebyte/firmware-*.hex verify; \
      reset run; exit"

When the SoftDevice is already on the chip and only the application changed, skip nrf52_recover and the SoftDevice line:

openocd -f interface/cmsis-dap.cfg -f target/nrf52.cfg \
  -c "init; \
      program .pio/build/moonshine_NRF52_ebyte/firmware-*.hex verify; \
      reset run; exit"

Notes

  • The firmware hex filename contains a commit hash (e.g. 2.8.0.421838f); use the actual file produced by pio run or a shell glob.
  • USB CDC serial is available immediately after boot for debug output and the Meshtastic Python CLI (meshtastic --noproto / meshtastic --info).
  • MESHTASTIC_EXCLUDE_I2C=1 is set because no I2C devices are connected. Remove this flag from platformio.ini if an I2C display or sensor is added later.
  • No GPS, screen, accelerometer, or magnetometer is configured. Remove the corresponding MESHTASTIC_EXCLUDE_* flags from platformio.ini if hardware is added.