🍒 XIAO nRF54LM20A + nRF Connect SDK v3.2.1 Bring-Up Log

Hi there,

So here is the steps I used to Begin the journey of discovery…
:grin:

Using the nRF54L15 DK as an External J-Link Programmer

Date: June 2026

Status: SUCCESS :white_check_mark:

I attached the included Flag antenna to the Newly opened Xiao and added it to the expansion board.



After some experimentation, I have the Seeed XIAO nRF54LM20A building and flashing under Nordic nRF Connect SDK v3.2.1.

This is a summary of the complete process that got me there.

Hardware Used

  • Seeed XIAO nRF54LM20A
  • Seeed Expansion Board (SWD)
  • Nordic nRF54L15 DK (P19)
  • USB-C cable to both boards (not at the same time)
  • Windows 11
  • nRF Connect SDK v3.2.1

Step 1 - Connect the Hardware

The XIAO was plugged into the Expansion Board.

The Expansion Board SWD connector was wired directly to the External Debug (P19) connector on the nRF54L15 DK.

Connections:

SWDIO
SWCLK
RESET
3.3V
GND

Power was supplied normally through USB.

Step 2 - Verify J-Link Can See the Target

Open J-Link Commander.

connect

Device:

NRF54LM20A_M33

Expected output:

Found SW-DP
Found Cortex-M33
Secure debug enabled

This confirms:

  • SWD wiring good
  • Target powered
  • Debug unlocked

Step 3 - Halt CPU

halt

Expected:

PC = xxxxxxxx

Registers should be readable.

Step 4 - Verify Flash

mem32 0x00000000,16

Expected:

20000C60
000002CD...

If the vector table is readable,

the connection is working.


Step 5 - Backup Factory Firmware

Backup first 64 KB

savebin d:\ncs\tmp\nrf54lm20a_factory_stub_64k.bin,0x00000000,0x10000

Expected

Reading 65536 bytes...O.K.

Convert to HEX

arm-zephyr-eabi-objcopy-I binary-O ihex

Result

factory_stub_64k.hex

Now factory firmware is preserved. :backhand_index_pointing_left: :smiling_face_with_sunglasses:

Step 6 - Install Seeed Board Files

Clone

platform-seeedboards

Extract only

boards/soc/

to

D:\ncs\seeed-lm20a-only

Avoid copying xiao_nrf54l15 because it conflicts with NCS 3.2.1.


Step 7 - Verify Board Exists

west boards --board-root D:\ncs\seeed-lm20a-only

Expected

xiao_nrf54lm20a

Step 8 - Build Hello World

west build

Board

xiao_nrf54lm20a/nrf54lm20a/cpuapp

Extra CMake

-DBOARD_ROOT=D:/ncs/seeed-lm20a-only

Expected

FLASH:RAM:Generating merged.hex

No errors.


Step 9 - J-Link Flash Failure

Attempting

west flash

or

loadfile merged.hex

failed with

Timeout while preparing targetRAMCode did not respond

This turned out NOT to be an SWD problem.

It was the flash loader.


Step 10 - Install nrfutil

Found inside

C:\ncs\toolchains\936afb6332\nrfutil\bin

Version

7.12.0

Step 11 - Verify Debugger

nrfutil device list

Expected

1057729516ProductJ-LinkBoardPCA10156

Perfect.


Step 12 - Flash Successfully

nrfutil device program

Firmware

merged.hex

Output

Programmed

Success!


Step 13 - Reset

nrfutil device reset

Step 14 - Open Serial Port

Immediately after reset

COM port begins printing

XIAO nRF54LM20A Demo, LED ONaccel data:...gyro data:...

Then

LED OFFaccel...gyro...

Repeated continuously.


Final Result

The following are now verified:

:white_check_mark: NCS v3.2.1 builds successfully

:white_check_mark: Custom XIAO board support works

:white_check_mark: nRF54L15 DK external SWD works

:white_check_mark: J-Link debugging works

:white_check_mark: Flash backup completed

:white_check_mark: Factory firmware preserved

:white_check_mark: nrfutil flashing works

:white_check_mark: Serial output works

:white_check_mark: IMU working

:white_check_mark: LED working

SEGGER J-Link Commander V8.94 (Compiled Dec 10 2025 14:46:23)
DLL version V8.94, compiled Dec 10 2025 14:45:18

Connecting to J-Link via USB...O.K.
Firmware: J-Link OB-nRF5340-NordicSemi compiled Jul  8 2025 10:15:34
Hardware version: V1.00
J-Link uptime (since boot): 0d 00h 01m 49s
S/N: 1057729516
License(s): RDI, FlashBP, FlashDL, JFlash, GDB
USB speed mode: Full speed (12 MBit/s)
VTref=3.300V


Type "connect" to establish a target connection, '?' for help

J-Link>connect
Device "NRF54LM20A_M33" selected.


Connecting to target via SWD
ConfigTargetSettings() start
ConfigTargetSettings() end - Took 2us
InitTarget() start
InitTarget() end - Took 1.83ms
Found SW-DP with ID 0x6BA02477
DPIDR: 0x6BA02477
CoreSight SoC-400 or earlier
AP map detection skipped. Manually configured AP map found.
AP[0]: AHB-AP (IDR: Not set, ADDR: 0x00000000)
AP[1]: APB-AP (IDR: Not set, ADDR: 0x00000000)
AP[2]: MEM-AP (IDR: Not set, ADDR: 0x00000000)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FE000
CPUID register: 0x411FD210. Implementer code: 0x41 (ARM)
Feature set: Mainline
Cache: No cache
Found Cortex-M33 r1p0, Little endian.
FPUnit: 8 code (BP) slots and 0 literal slots
Security extension: implemented
Secure debug: enabled
CoreSight components:
ROMTbl[0] @ E00FE000
[0][0]: E00FF000 CID B105100D PID 000BB4C9 ROM Table
ROMTbl[1] @ E00FF000
[1][0]: E000E000 CID B105900D PID 000BBD21 DEVARCH 47702A04 DEVTYPE 00 Cortex-M33
[1][1]: E0001000 CID B105900D PID 000BBD21 DEVARCH 47701A02 DEVTYPE 00 DWT
[1][2]: E0002000 CID B105900D PID 000BBD21 DEVARCH 47701A03 DEVTYPE 00 FPB
[1][3]: E0000000 CID B105900D PID 000BBD21 DEVARCH 47701A01 DEVTYPE 43 ITM
[1][5]: E0041000 CID B105900D PID 002BBD21 DEVARCH 47724A13 DEVTYPE 13 ETM
[0][1]: E0040000 CID B105900D PID 000BBD21 DEVARCH 00000000 DEVTYPE 11 TPIU
Memory zones:
  Zone: "Default" Description: Default access mode
Cortex-M33 identified.
J-Link>ShowHWStatus
VTref=3.300V
ITarget=0mA
TCK=0 TDI=1 TDO=1 TMS=1 TRES=1 TRST=?
Supported target interface speeds:
 - 128 MHz/n, (n>=64). => 2000kHz, 1969kHz, 1939kHz, ...

Build with West command

PS C:\ncs\v3.2.1> west build -p always `
>>   -b xiao_nrf54lm20a/nrf54lm20a/cpuapp `
>>   zephyr\samples\hello_world `
>>   -- "-DBOARD_ROOT=D:/ncs/seeed-lm20a-only"
-- west build: generating a build system
Loading Zephyr module(s) (Zephyr base): sysbuild_default
-- Found Python3: C:/Users/Dude/AppData/Local/Microsoft/WindowsApps/PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0/python.exe (found suitable version "3.11.9", minimum required is "3.10") found components: Interpreter
-- Cache files will be written to: C:/ncs/v3.2.1/zephyr/.cache
-- Found west (found suitable version "1.3.0", minimum required is "0.14.0")
-- Board: xiao_nrf54lm20a, qualifiers: nrf54lm20a/cpuapp
Parsing C:/ncs/v3.2.1/zephyr/share/sysbuild/Kconfig
Loaded configuration 'C:/ncs/v3.2.1/build/_sysbuild/empty.conf'
Merged configuration 'C:/ncs/v3.2.1/build/_sysbuild/empty.conf'
Configuration saved to 'C:/ncs/v3.2.1/build/zephyr/.config'
Kconfig header saved to 'C:/ncs/v3.2.1/build/_sysbuild/autoconf.h'
--
   *********************************
   * Running CMake for hello_world *
   *********************************
yada,yada,yada,

[10/10] Generating ../merged.hex

Flash & Reset

PS C:\ncs\v3.2.1> nrfutil device list
C865297E600C
Product         nRF52 Connectivity
Ports           COM7
Traits          nordicUsb, nordicDfu, serialPorts, usb

1057729516
Product         J-Link
Board version   PCA10156
Ports           COM3, vcom: 0
                COM4, vcom: 1
Traits          jlink, seggerUsb, serialPorts, usb, devkit, boardController

Supported devices found: 2

PS C:\ncs\v3.2.1> nrfutil device program --firmware C:\ncs\v3.2.1\build\merged.hex --serial-number 1057729516
[00:00:00] ###### 100% [2/3 1057729516] Programmed
PS C:\ncs\v3.2.1> nrfutil device reset --serial-number 1057729516
v Reset was applied to 1057729516
PS C:\ncs\v3.2.1> nrfutil device reset --serial-number 1057729516
v Reset was applied to 1057729516
PS C:\ncs\v3.2.1>

Serial output

UART20_BOOT_PROBE
Hello, XIAO nRF54LM20A
accel data:0.134596,0.485144,11.073384gyro data: -0.131717,-0.000305,-0.023671
XIAO nRF54LM20A Demo, LED ON
accel data:-0.098703,0.303888,10.412965gyro data: -0.009162,-0.057726,0.060628
XIAO nRF54LM20A Demo, LED OFF
accel data:-0.018544,0.308075,10.399207gyro data: -0.008704,-0.054290,0.063224
XIAO nRF54LM20A Demo, LED ON
accel data:-0.046660,0.331405,10.368698gyro data: -0.010766,-0.054672,0.064217
XIAO nRF54LM20A Demo, LED OFF
accel data:-0.070588,0.270388,10.378269gyro data: -0.008628,-0.054748,0.061086
XIAO nRF54LM20A Demo, LED ON
accel data:-0.083748,0.315852,10.387242gyro data: -0.007406,-0.054519,0.063835
XIAO nRF54LM20A Demo, LED OFF
accel data:-0.042472,0.329013,10.401001gyro data: -0.005345,-0.049785,0.063988
XIAO nRF54LM20A Demo, LED ON

code is in the system

zephyr\samples\hello_world `

More discoveries to be made and more testing…

Lessons Learned

The biggest discoveries:

  • The board files from Seeed work with NCS 3.2.1 after removing duplicate board definitions.
  • The nRF54L15 DK makes an excellent external debugger for the LM20A.
  • Raw J-Link Commander can debug the LM20A but cannot reliably program flash because of the RAMCode/flash algorithm issue.
  • nrfutil is currently the reliable flashing method.
  • Once this workflow is established, development becomes straightforward.
  • Bleeding edge , expect some cuts…LOL

Stay tuned for more from this tiny firehorse

HTH
GL :slight_smile: PJ :v:

GitHub - lolren/open-nrf-ocd: Native C CMSIS-DAP flash programmer for nRF54 — zero-Python pyOCD replacement. Cross-platform Linux/macOS/Windows. · GitHub easier method:)

Also, easier method to run code: GitHub - lolren/nrf54-arduino-core: nRF54 Arduino core for XIAO nRF54L15 and other nRF54 boards using a register-level runtime · GitHub

Hi there,

So to UPDATE… The segger folks released an update for the ON-BOARD J-Link on the nrf54L15DK, prior to the update it was NOT able to Erase , or Write (loadfile) properly without errors.

FYI, PSA…

Updated to V9.54 for the on-board J-Link on the nRF54L15_DK , restores the ERASE and LOADFILE for the Xiao nRF54LM20A . After updating ALL Jlink functions are working again. :+1: The RAMCode errors are gone.
Here is the Flow:
device nRF54LM20A_M33
si SWD
speed 500
connect
r
h
erase
r
h
loadfile D:\Nordic\myapps\workspace\hello_world_2\build\merged.hex
r
g
__ Proves to work reliably__

Now if only my Code wasn’t garbage. :grin:

HTH
GL :slight_smile: PJ :v:

Also moved to th Version 3.2.4 for the Nrf_SDK and Toolchain. SOFar AOK :+1:

Hi there,

And Major Props… for the Arduino Core work. Brilliant really to use the AI to build what we needed, some here would complain but to Make a fast prototype possible without breaking many brain cells and AI prompts… LOL :grin: it’s Perfect! :+1:

As it matures and more parts work, like debugging it will help the community. I’m thankful, you resuscitated the Nordic new stuff in the arduino realm. You proved they are just LAZY in both camps, IMO :sweat_smile:

Thank You. :wink: :index_pointing_at_the_viewer:

I’ll keep testing with it and post any issues, I feel a LM20A “Rolo” with round display coming up.

HTH
GL :slight_smile: PJ :v:

I actually think this is the first vibe-coded Arduino core :slight_smile:
I hope all things will be on par with Zephyr. One thing I don’t think can be solver is CRACEN, which Nordic uses a proprietary micro-code. I’ve asked them for help, but their response was a generic corporate talk for “piss-off“.

This would make Thread and Matter under perform on this core.

I was thinking that for the next project , I might finish the ESP32 open WIFI stack :slight_smile:

It looks like LM20A will be officially released tomorrow. I sure hope a lot of testers will join in on the debugging of the actual device.

Hi there,

Absolutely agree, Once it is official and available I bet more do test it and switch, as it offers so much over the Previous Xiao’s. So much yet to be explored. PHAT flash and Starting with the Crashproof DFU possabilities , ship mode, RiscV Flipper, Find my device compatibility, NFC Wake/Sleep and some of the newer BLE 6.0 features, and that is just a run up to the “B” variant more suited to Inferencing and AI tasks. :exploding_head:

I saw a demo of the IMU doing “anti-tamper” drilling and grinding model training that was seriously cool. what is coming and what is possible is amazing. :fight_cloud:
I want to test it ALL!

GL :slight_smile: PJ :v:

As always though the Lag in Software updates , for newer silicon features will always sadly be a thing. I Imagine just what @Loren_Bufanu has done in extending the life of some Arduino projects to this newer more powerful silicon, which otherwise would have no choice but to be abandon or redesign. :+1:

Hi there,


So, if you received the Breakout for the nRF54LM20A ahead of the release, I stretched the grove pad to work here, enjoy. the STL is in the ZIP.

HTH
GL :slight_smile: PJ :v:
Xiao_LM20A_dK-Body.zip (612.2 KB)

Hi there,

So re-enforcements Arrived, and not a moment too late.
:grin:

The BLE is Outstanding IMO! coupled with the Deep Sleep and some extra capabilities coming Up.

Do NOT sleep on the nRF54LM20A Sense…

Best in Class of this type device. Period!

so I saw this project , Cool enough..

and then I thought, Hmm…too many parts.
WE can do Better… :wink: SD card for recording and A camera if you want to go FULL terminator Mode! Seeed Round Display Takes it Away, one device many options.

Video , forth coming… the trick is to get the Display FPS high enough (SPI)as to not miss any IMU , or BE or anything else you got up your sleeve. I switched from Jeep to F150 PickUp
No SquareLine Studio, LVGL’s prebuilt widgets, GUI Guider, and or similar visual design environments were used or Harmed in this video… :smile:

They’re useful tools, particularly for menus, buttons, and complex touchscreen interfaces. But they encourage a different development philosophy.

SquareLine approach: Design the appearance of an instrument, export the graphics and UI code, then connect the hardware to it.

My & Our organic approach: Read the hardware, calculate the instrument’s behavior, and draw exactly what the instrument needs to communicate.

The distinction isn’t whether we use a graphics library. This radar uses Adafruit GFX, after all. It’s whether the library supplies the instrument’s identity or simply helps us draw it.

And there’s the real beauty of our radar: the display isn’t playing an animation of a radar. The radar’s behavior generates the animation.

Same philosophy for the inclinometer.

My mantra works well:

“I don’t want a picture of an instrument running on my microcontroller. I want my microcontroller to become the instrument.”

SquareLine isn’t the enemy. It’s simply a different tool for a different job. the Jeep art looks very nice though…

We’re building instruments, not screen mockups.:fight_cloud: :smiling_face_with_sunglasses: :v:

Here is the code (it’s a WIP) if you have a Xiao "fire horse":fire::horse: Nrf54LM20A
and Round Display :+1:


/***************************************************************************
 * PROJECT: LM20A Round Inclinometer - White F-150 4WD
 * FILE:    LM20A_Inclinometer_v0.4.4.ino
 *
 * VERSION: 0.4.4
 * BUILD:   20261115-07
 * STATUS:  TEST / EXPERIMENTAL
 * AUTHOR:  PJ Glasso & AG_nRF AI
 * BOARD:   Seeed XIAO nRF54LM20A Sense
 * CORE:    Loren's Clean Arduino Core 1.0.23
 * LCD:     GC9A01 240x240 - Hardware SPI
 * IMU:     LSM6-family via Wire1
 *
 * FEATURES:
 *   - Connected semicircular scales
 *   - Large inner tick marks and centered degree labels
 *   - White pickup front view for roll
 *   - White pickup side view for pitch
 *   - Moving green horizon
 *   - Two stationary yellow carets
 *   - Independent pitch/roll scale pointers
 *   - Centered signed numeric readouts
 *
 * SERIAL:
 *   z = Zero current position
 *   r = Reset calibration
 *   h = Help
 *
 * CHANGELOG:
 *   v0.4.4 - Typography and numeric alignment improvements
 *   v0.4.3 - Working connected gauge and moving horizon
 *
 * NOTE:
 *   Start with the display face-up and approximately level.
 *   v0.4.3 remains the KNOWN-GOOD fallback.
 ***************************************************************************/

#include <Arduino.h>
#include <Wire.h>
#include <SPI.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <Adafruit_GFX.h>
#include <Adafruit_GC9A01A.h>

// ============================================================
// DISPLAY CONFIGURATION
// ============================================================

#define TFT_CS   PIN_D1
#define TFT_DC   PIN_D3
#define TFT_RST  -1
#define TFT_BL   PIN_D6

Adafruit_GC9A01A tft(
  &SPI,
  TFT_DC,
  TFT_CS,
  TFT_RST
);

#define BLACK     0x0000
#define WHITE     0xFFFF
#define RED       0xF800
#define GREEN     0x07E0
#define YELLOW    0xFFE0
#define CYAN      0x07FF
#define GRAY      0x8410
#define DARKGRAY  0x4208
#define SILVER    0xC618

#define CX 120
#define CY 120

// ============================================================
// IMU CONFIGURATION
// ============================================================

#define REG_WHO_AM_I   0x0F
#define REG_CTRL1_XL   0x10
#define REG_CTRL3_C    0x12
#define REG_OUTX_L_XL  0x28

uint8_t imuAddress = 0;

bool imuReady = false;
bool orientationCaptured = false;
bool filterReady = false;

int8_t faceUpZSign = 1;

float filteredPitch = 0;
float filteredRoll = 0;

float pitchZero = 0;
float rollZero = 0;

float pitch = 0;
float roll = 0;

const float FILTER_ALPHA = 0.10f;
const float DEADBAND = 0.30f;

uint32_t lastDraw = 0;
uint32_t lastSerial = 0;

float lastPitch = 999;
float lastRoll = 999;

// ============================================================
// IMU I2C HELPERS
// ============================================================

bool imuWrite(uint8_t reg, uint8_t value)
{
  Wire1.beginTransmission(imuAddress);
  Wire1.write(reg);
  Wire1.write(value);

  return Wire1.endTransmission() == 0;
}

bool imuRead(uint8_t reg, uint8_t *data, size_t length)
{
  Wire1.beginTransmission(imuAddress);
  Wire1.write(reg);

  if (Wire1.endTransmission(false) != 0)
    return false;

  if (Wire1.requestFrom(
        (uint8_t)imuAddress,
        (uint8_t)length
      ) != length)
    return false;

  for (size_t i = 0; i < length; i++)
    data[i] = Wire1.read();

  return true;
}

// ============================================================
// IMU INITIALIZATION
// ============================================================

bool beginIMU()
{
  Serial.println("[IMU] Starting");

  pinMode(PIN_IMU_CS, OUTPUT);
  digitalWrite(PIN_IMU_CS, HIGH);

  delay(20);

  Wire1.begin();
  delay(100);

  const uint8_t addresses[] = {0x6A, 0x6B};

  for (uint8_t i = 0; i < 2; i++)
  {
    imuAddress = addresses[i];

    uint8_t who = 0;

    if (!imuRead(REG_WHO_AM_I, &who, 1))
      continue;

    Serial.print("[IMU] Address: 0x");
    Serial.println(imuAddress, HEX);

    Serial.print("[IMU] WHO_AM_I: 0x");
    Serial.println(who, HEX);

    if (who != 0x69 &&
        who != 0x6A &&
        who != 0x6C)
      continue;

    if (!imuWrite(REG_CTRL3_C, 0x44))
      return false;

    if (!imuWrite(REG_CTRL1_XL, 0x40))
      return false;

    delay(100);

    Serial.println("[IMU] Ready");
    return true;
  }

  Serial.println("[IMU] Not detected");
  return false;
}

// ============================================================
// ACCELEROMETER ANGLES
// ============================================================

bool readAngles(float &p, float &r)
{
  uint8_t b[6];

  if (!imuRead(REG_OUTX_L_XL, b, 6))
    return false;

  int16_t xi = (int16_t)(
    ((uint16_t)b[1] << 8) | b[0]
  );

  int16_t yi = (int16_t)(
    ((uint16_t)b[3] << 8) | b[2]
  );

  int16_t zi = (int16_t)(
    ((uint16_t)b[5] << 8) | b[4]
  );

  float ax = xi;
  float ay = yi;
  float az = zi;

  if (!orientationCaptured && fabsf(az) > 8000)
  {
    faceUpZSign = (az >= 0) ? 1 : -1;
    orientationCaptured = true;

    Serial.print("[IMU] Z sign: ");
    Serial.println((int)faceUpZSign);
  }

  p = atan2f(
    -ax,
    sqrtf(ay * ay + az * az)
  ) * 57.2957795f;

  r = atan2f(
    ay,
    az * (float)faceUpZSign
  ) * 57.2957795f;

  return true;
}

// ============================================================
// ROTATED DRAWING HELPERS
// ============================================================

void rotatePoint(
  int cx, int cy,
  float degrees,
  float x, float y,
  int &ox, int &oy
)
{
  float a = degrees * 0.01745329252f;
  float c = cosf(a);
  float s = sinf(a);

  ox = cx + (int)lroundf(x*c - y*s);
  oy = cy + (int)lroundf(x*s + y*c);
}

void rLine(
  int cx, int cy, float angle,
  int x1, int y1, int x2, int y2,
  uint16_t color
)
{
  int ax, ay, bx, by;

  rotatePoint(cx,cy,angle,x1,y1,ax,ay);
  rotatePoint(cx,cy,angle,x2,y2,bx,by);

  tft.drawLine(ax,ay,bx,by,color);
}

void rRect(
  int cx, int cy, float angle,
  int x1, int y1, int x2, int y2,
  uint16_t color
)
{
  rLine(cx,cy,angle,x1,y1,x2,y1,color);
  rLine(cx,cy,angle,x2,y1,x2,y2,color);
  rLine(cx,cy,angle,x2,y2,x1,y2,color);
  rLine(cx,cy,angle,x1,y2,x1,y1,color);
}

void rCircle(
  int cx, int cy, float angle,
  int x, int y, int radius,
  uint16_t color
)
{
  int ox, oy;

  rotatePoint(cx,cy,angle,x,y,ox,oy);
  tft.drawCircle(ox,oy,radius,color);
}

// ============================================================
// WHITE F-150 STYLE FRONT VIEW
// ============================================================

void drawFrontTruck(int cx, int cy, float angle)
{
  rLine(cx,cy,angle,-19,-9,-15,-20,WHITE);
  rLine(cx,cy,angle,-15,-20,15,-20,WHITE);
  rLine(cx,cy,angle,15,-20,19,-9,WHITE);

  rRect(cx,cy,angle,-21,-9,21,9,WHITE);
  rRect(cx,cy,angle,-15,-17,15,-10,CYAN);

  rRect(cx,cy,angle,-14,0,14,6,SILVER);

  rLine(cx,cy,angle,-12,2,12,2,SILVER);
  rLine(cx,cy,angle,-12,5,12,5,SILVER);

  rRect(cx,cy,angle,-20,-5,-13,-1,YELLOW);
  rRect(cx,cy,angle,13,-5,20,-1,YELLOW);

  rLine(cx,cy,angle,-18,10,18,10,WHITE);

  rLine(cx,cy,angle,-24,5,-24,12,WHITE);
  rLine(cx,cy,angle,24,5,24,12,WHITE);
}

// ============================================================
// WHITE F-150 STYLE SIDE VIEW
// ============================================================

void drawSideTruck(int cx, int cy, float angle)
{
  rLine(cx,cy,angle,-34,6,34,6,WHITE);
  rLine(cx,cy,angle,-34,6,-34,-4,WHITE);

  rLine(cx,cy,angle,-34,-4,-8,-4,WHITE);

  rLine(cx,cy,angle,-8,-4,-8,-17,WHITE);
  rLine(cx,cy,angle,-8,-17,9,-17,WHITE);
  rLine(cx,cy,angle,9,-17,20,-5,WHITE);

  rLine(cx,cy,angle,20,-5,31,-5,WHITE);
  rLine(cx,cy,angle,31,-5,34,0,WHITE);
  rLine(cx,cy,angle,34,0,34,6,WHITE);

  rLine(cx,cy,angle,1,-15,1,-5,CYAN);
  rLine(cx,cy,angle,9,-15,17,-5,CYAN);
  rLine(cx,cy,angle,-6,-14,-6,-5,CYAN);

  rLine(cx,cy,angle,0,-5,0,6,SILVER);
  rLine(cx,cy,angle,-10,-3,-10,6,SILVER);

  rLine(cx,cy,angle,4,-1,8,-1,WHITE);

  rCircle(cx,cy,angle,-22,8,6,WHITE);
  rCircle(cx,cy,angle,22,8,6,WHITE);

  rCircle(cx,cy,angle,-22,8,2,SILVER);
  rCircle(cx,cy,angle,22,8,2,SILVER);
}

// ============================================================
// CONNECTED SEMICIRCULAR GAUGE
// ============================================================

void drawGauge()
{
  tft.fillScreen(BLACK);

  tft.drawCircle(CX,CY,117,WHITE);
  tft.drawCircle(CX,CY,113,GRAY);

  for (int side=-1; side<=1; side+=2)
  {
    int previousX=0, previousY=0;
    bool first=true;

    for (int deg=-40; deg<=40; deg++)
    {
      float a=deg*1.35f*0.01745329252f;

      int x=CX+(int)lroundf(side*101*cosf(a));
      int y=CY+(int)lroundf(101*sinf(a));

      if (!first)
        tft.drawLine(previousX,previousY,x,y,GRAY);

      previousX=x;
      previousY=y;
      first=false;
    }
  }

  for (int side=-1; side<=1; side+=2)
  {
    for (int deg=-40; deg<=40; deg+=10)
    {
      float a=deg*1.35f*0.01745329252f;

      float cs=cosf(a);
      float sn=sinf(a);

      int outerR=101;
      int innerR=(deg%20==0)?87:93;

      int x1=CX+(int)lroundf(side*innerR*cs);
      int y1=CY+(int)lroundf(innerR*sn);

      int x2=CX+(int)lroundf(side*outerR*cs);
      int y2=CY+(int)lroundf(outerR*sn);

      uint16_t color=(abs(deg)>=30)?RED:WHITE;

      tft.drawLine(x1,y1,x2,y2,color);

      // Centered major labels
      if (deg%20==0)
      {
        int value=abs(deg);

        int tx=CX+(int)lroundf(side*72*cs);
        int ty=CY+(int)lroundf(72*sn);

        tft.setTextSize(2);
        tft.setTextColor(color,BLACK);
        tft.setTextWrap(false);

        int textWidth=(value>=10)?24:12;

        tft.setCursor(
          tx-textWidth/2,
          ty-8
        );

        tft.print(value);
      }
    }
  }

  tft.drawFastHLine(108,10,24,GRAY);
  tft.drawFastHLine(108,230,24,GRAY);

  tft.setTextSize(1);
  tft.setTextColor(CYAN,BLACK);
  tft.setCursor(92,14);
  tft.print("F-150 4WD");
}

// ============================================================
// INDEPENDENT MOVING SCALE POINTERS
// ============================================================

void drawPointer(int side,float degrees,uint16_t color)
{
  float d=constrain(degrees,-40.0f,40.0f);
  float a=d*1.35f*0.01745329252f;

  float cs=cosf(a);
  float sn=sinf(a);

  int x1=CX+(int)lroundf(side*79*cs);
  int y1=CY+(int)lroundf(79*sn);

  int x2=CX+(int)lroundf(side*84*cs);
  int y2=CY+(int)lroundf(84*sn);

  tft.drawLine(x1,y1,x2,y2,color);
  tft.fillCircle(x2,y2,2,color);
}

bool pointersDrawn=false;

float oldPointerRoll=0;
float oldPointerPitch=0;

// ============================================================
// FIXED YELLOW CARETS
// ============================================================

void drawCarets()
{
  tft.drawLine(78,114,84,120,YELLOW);
  tft.drawLine(78,126,84,120,YELLOW);

  tft.drawLine(162,114,156,120,YELLOW);
  tft.drawLine(162,126,156,120,YELLOW);

  tft.fillCircle(120,120,2,RED);
}

// ============================================================
// MOVING GREEN HORIZON
// ============================================================

const int HORIZON_LEFT=85;
const int HORIZON_TOP=104;
const int HORIZON_W=70;
const int HORIZON_H=33;

void drawHorizon(float p,float r)
{
  tft.fillRect(
    HORIZON_LEFT,
    HORIZON_TOP,
    HORIZON_W,
    HORIZON_H,
    BLACK
  );

  float visualRoll=constrain(r,-12.0f,12.0f);
  float visualPitch=constrain(p,-20.0f,20.0f);

  float a=visualRoll*0.01745329252f;

  float dx=30.0f*cosf(a);
  float dy=30.0f*sinf(a);

  int offset=(int)lroundf(visualPitch*0.35f);

  int x1=CX-(int)lroundf(dx);
  int y1=CY-(int)lroundf(dy)+offset;

  int x2=CX+(int)lroundf(dx);
  int y2=CY+(int)lroundf(dy)+offset;

  tft.drawLine(x1,y1,x2,y2,GREEN);

  drawCarets();
}

// ============================================================
// DYNAMIC GRAPHICS
// ============================================================

void drawDynamic(float p,float r)
{
  if (pointersDrawn)
  {
    drawPointer(-1,oldPointerRoll,BLACK);
    drawPointer(+1,-oldPointerPitch,BLACK);
  }

  drawPointer(-1,r,GREEN);
  drawPointer(+1,-p,GREEN);

  oldPointerRoll=r;
  oldPointerPitch=p;
  pointersDrawn=true;

  // Upper truck window
  tft.fillRect(85,39,70,68,BLACK);

  drawFrontTruck(
    120,
    76,
    constrain(r,-40.0f,40.0f)
  );

  // Lower truck window
  tft.fillRect(78,139,84,64,BLACK);

  drawSideTruck(
    120,
    169,
    constrain(p,-40.0f,40.0f)
  );

  drawHorizon(p,r);

  // ==========================================================
  // CLEAN, CENTERED NUMERIC READOUTS
  // ==========================================================

  // Roll readout above upper truck
  tft.fillRect(96,34,48,17,BLACK);

  int rollValue=(int)lroundf(r);

  tft.setTextSize(1);
  tft.setTextColor(WHITE,BLACK);
  tft.setTextWrap(false);

  char rollText[12];

  snprintf(
    rollText,
    sizeof(rollText),
    "R %+d",
    rollValue
  );

  int rollWidth=strlen(rollText)*6;

  tft.setCursor(
    120-rollWidth/2,
    38
  );

  tft.print(rollText);

  // Pitch readout below lower truck
  tft.fillRect(86,205,68,22,BLACK);

  int pitchValue=(int)lroundf(p);

  char pitchText[12];

  snprintf(
    pitchText,
    sizeof(pitchText),
    "%+d",
    pitchValue
  );

  tft.setTextSize(2);

  int pitchWidth=strlen(pitchText)*12;

  tft.setCursor(
    120-pitchWidth/2,
    207
  );

  tft.print(pitchText);
}

// ============================================================
// SERIAL COMMANDS
// ============================================================

void handleSerial()
{
  while (Serial.available())
  {
    char c=Serial.read();

    if (c=='z' || c=='Z')
    {
      pitchZero=filteredPitch;
      rollZero=filteredRoll;

      lastPitch=999;
      lastRoll=999;

      Serial.println("[CAL] Zero saved");
    }
    else if (c=='r' || c=='R')
    {
      pitchZero=0;
      rollZero=0;

      lastPitch=999;
      lastRoll=999;

      Serial.println("[CAL] Zero reset");
    }
    else if (c=='h' || c=='H')
    {
      Serial.println("z = zero");
      Serial.println("r = reset");
      Serial.println("h = help");
    }
  }
}

// ============================================================
// SETUP
// ============================================================

void setup()
{
  Serial.begin(115200);
  delay(1500);

  Serial.println();
  Serial.println("==================================");
  Serial.println(" LM20A F-150 4WD INCLINOMETER");
  Serial.println(" VERSION: 0.4.4");
  Serial.println(" BUILD:   20261115-07");
  Serial.println(" STATUS:  TEST / EXPERIMENTAL");
  Serial.println("==================================");

  pinMode(TFT_BL,OUTPUT);
  digitalWrite(TFT_BL,HIGH);

  delay(200);

  SPI.begin();

  tft.begin();
  tft.setRotation(0);

  drawGauge();

  imuReady=beginIMU();

  Serial.println(
    imuReady ?
    "[BOOT] IMU ready" :
    "[BOOT] IMU unavailable"
  );

  if (imuReady)
    drawDynamic(0,0);
}

// ============================================================
// MAIN LOOP
// ============================================================

void loop()
{
  handleSerial();

  if (!imuReady)
  {
    delay(100);
    return;
  }

  float p=0;
  float r=0;

  if (readAngles(p,r))
  {
    if (!filterReady)
    {
      filteredPitch=p;
      filteredRoll=r;
      filterReady=true;
    }
    else
    {
      filteredPitch += FILTER_ALPHA *
        (p-filteredPitch);

      float delta=r-filteredRoll;

      while (delta>180) delta-=360;
      while (delta< -180) delta+=360;

      filteredRoll += FILTER_ALPHA*delta;

      while (filteredRoll>180) filteredRoll-=360;
      while (filteredRoll< -180) filteredRoll+=360;
    }

    pitch=filteredPitch-pitchZero;
    roll=filteredRoll-rollZero;

    while (roll>180) roll-=360;
    while (roll< -180) roll+=360;
  }

  uint32_t now=millis();

  if (
    now-lastDraw>=100 &&
    (
      fabsf(pitch-lastPitch)>DEADBAND ||
      fabsf(roll-lastRoll)>DEADBAND
    )
  )
  {
    lastDraw=now;

    lastPitch=pitch;
    lastRoll=roll;

    drawDynamic(pitch,roll);
  }

  if (now-lastSerial>=1000)
  {
    lastSerial=now;

    Serial.print("[IMU] Pitch: ");
    Serial.print(pitch,2);

    Serial.print(" Roll: ");
    Serial.println(roll,2);
  }

  delay(20);
}

nRF54LM20A_inclinometer.zip (566.8 KB)
or if you just want to, Extract the Hex file, Flash it and go…

nrf_ocd -p COMx -t nrf54lm20a -e chip -R --no-verify load Inclinometer_v4.4.4.hex

BLE Radar..code and video Next.

As You Were..:saluting_face:

GL :slight_smile: PJ :v:

I’ll add touch , record to SD in the next units..