The project · Bluetooth LE · Zephyr · nRF52840

BLE, Project Zero

The free beginner BLE course, and it starts the way every course here starts: with a product. Build a real Bluetooth macro pad: four buttons that type, pairing and bonding done properly, a hand-wired switch matrix with scanning firmware you write yourself, keymaps and media keys, and an optional battery finale. You learn BLE by shipping the pad.

8 chapters + appendix 18 to 22½ hours Beginner Free
Start the free course Read chapter 1

Free means free: every chapter, no card, no trial clock.

Photo of the nRF52840 DK (PCA10056). The board this course develops on
The nRF52840 DK (PCA10056), the board this course develops on. Photo: Zephyr Project documentation (CC BY 4.0).
The problem

BLE vocabulary is not a BLE product

The usual way

  • Advertising, GATT and pairing explained as vocabulary, then a demo that stops at "connected"
  • A vendor sample you flash once and learn nothing from taking apart
  • Bonding, debounce and ghosting left as mysteries for your first real project to solve painfully
  • Nothing on your desk at the end that you would show anyone

This course

  • Every concept arrives when the pad needs it: the report map when the buttons must type, bonding when the host demands an encrypted link
  • You write the scanning and debounce firmware yourself, and hit the six-key rollover wall on purpose to learn why diodes exist
  • Pairing and bonding done the way shipped keyboards do them, with the two shell commands every product needs
  • You finish with a working macro pad, and the optional finale turns it into a battery product on a XIAO
What you build

One pad, built in stages

On the nRF52840 DK: four buttons that type real letters over HID over GATT, then pairing and bonding, then a hand-wired 3 by 4 switch matrix (12 switches, 12 diodes, seven wires) scanned by firmware you wrote, then keymaps, a momentary layer and media keys on a second report. Chapter 8 is the optional finale: the same firmware ported to a Seeed XIAO nRF52840 with a LiPo cell, reporting its battery to the host.

Be seen, then connect

Advertising, connection events, and the restart nobody tells you about. (Chapter 3)

Phone (central)Pad (peripheral)Phone (central)Pad (peripheral)Chapter 4 starts sending keys inside this connectionadvertisement: "Project Zero", connectableadvertisement (repeats, ~200 ms apart)scanner app lists "Project Zero"connect requestconnected event (both sides)

The report map is the contract

HID over GATT, byte by byte. (Chapter 4)

HostPad firmwareButton 1 (SW1)HostPad firmwareButton 1 (SW1)interrupt: pressedwork handler builds report: slot 1 = 0x04notify: [00 00 04 00 00 00 00 00]set changed: 'a' appearsinterrupt: releasednotify: [00 00 00 00 00 00 00 00]set empty: key up

Twelve keys on seven wires

The switch matrix: scanning, debounce, ghosting. (Chapter 6)

yes

no

scan tick (every 5 ms)

drive row 0 high

read col 0..3

drive row 0 low, row 1 high

read col 0..3

drive row 2 high, read cols

update candidates: same twice in a row = a real change

any key state changed?

Chapter 6 step 2: rebuild and send the HID report

Start chapter 1, free
Watch it move

Real animations from inside the lessons

The flows that matter in BLE (advertising that restarts itself, one keystroke becoming two reports, a grid being scanned) are taught as animations you control. These three are lifted straight out of the chapters, untouched.

Animated diagram

Advertise, connect, advertise again

on the air: Project Zero, every 100 to 150 msMacro padadvertisingadvertising packetname: Project Zeroa poster, repeated: anyone in range can read it
the scanner lists what it hearsMacro padadvertisingnRF Connectscanninglisting: Project Zero, its address, its RSSI
connected: the poster comes downMacro padconnectedHostlink is upLED0 is on, and the pad is gone from the scanner list
disconnected: reason 0x13Macro padlink endedHostremote leftLED0 is off. The remote left politely, code 0x13.
a work item posts the poster againDisconnectcallback ranWork itemrestart requestedMacro padfindable againno reset needed: the loop closes itself

Animated diagram

One keystroke, two reports

button 1 down: slot 1 holds the usage for athe input report, being built0000040000000000byte 0: modifier byte 1: reserved bytes 2 to 7: six key slotsusage 0x04 is a. One slot, one key.
notify: the full report goes to the hostthe host subscribed, so the pad may speak0000040000000000byte 0: modifier byte 1: reserved bytes 2 to 7: six key slotsthe host sees the set change: a is now down
the host does the typingMacro padstill holding aHosttypes a, repeatsa a a a, while the set keeps saying a is down
release: the empty set is a message toothe input report, after release0000000000000000byte 0: modifier byte 1: reserved bytes 2 to 7: six key slotsall zeros: no key is down, so the typing stops

Animated diagram

Scanning the grid

row 0 goes high: read the four columnscol 0col 1col 2col 3row 01234row 15678row 29101112one switch ties its row to its column: that column reads high
rows 1 and 2 follow: 12 keys on 7 wirescol 0col 1col 2col 3row 01234row 15678row 29101112a full pass every 5 ms: 3 rows plus 4 columns is 7 wires
a press counts when two scans agreecol 0col 1col 2col 3row 01234row 15678row 29101112reading 1 equals reading 2: the press is accepted
three corners held, and no phantom fourthcol 0col 1col 2col 3row 01234row 15678row 291011X149a diode in every switch blocks the sneak path

Curriculum

Chapter by chapter

Eight chapters and a troubleshooting appendix, 18 to 22½ hours of follow-along building. The course completes on Chapters 1 to 7 plus the appendix; Chapter 8 is the optional finale for readers who want the standalone battery product.

1

Setup the pinned way, and your first debug session

Install the pinned toolchain, build and flash your first apps, and drive the board from its own shell.

~2½ to 3½ h
2

Buttons that behave: interrupts, work, and debounce

Interrupts announce, threads work, and a timestamp filter tells a real press from switch bounce.

~2 to 2½ h
3

Be seen: advertising, connections, and the two roles

The board advertises, a phone finds it, a connection forms, and advertising learns to restart itself.

~1½ to 2 h
4

The board becomes a keyboard

HID over GATT end to end: the report map byte by byte, and the DK’s four buttons type real letters.

~2½ to 3 h
5

Pairing and bonding: the keyboard grows up

Encrypted links required, bonds stored in flash, and the two shell commands every shipped keyboard needs.

~2 to 2½ h
6

Twelve keys on seven wires: the switch matrix

Hand-wire a 3 by 4 switch matrix with diodes, scan and debounce the grid, and hit the six-key wall on purpose.

~3 to 3½ h
7

Make it yours: keymaps, layers, and media keys

Keymaps as data, a momentary layer, media keys on a second report, and a name the host can read.

~2 to 2½ h
8

Chapter 8 (finale): Off the dev kit: the XIAO pad Optional finale

Optional finale: port the pad to a Seeed XIAO with a LiPo cell, a battery gauge the host can see, and honest runtime arithmetic.

~2½ to 3 h
What's inside

Everything is a deliverable

  • 8 chapters of labs: every lab a numbered procedure with checkpoints and expected outputs, each step build-verified on the pinned stack (NCS v3.4.1, Zephyr 4.4.2)
  • 40 quiz questions with full answer keys: a self-check in every chapter
  • 17 diagrams, plus an animated diagram in every chapter: the build loop, the interrupt rule, the pairing sequence, the scan
  • The complete companion repo, public on GitHub: 11 step-by-step applications, each building on the last (github.com/learnbittoboard/ble-project-zero)
  • Two exercises per chapter: a core exercise and a labeled stretch
  • The troubleshooting appendix: When it breaks, 15 symptoms from this exact project, cause and fix
  • Deliberately scoped: custom GATT profile design, connection privacy in depth, throughput tuning, OTA updates and sniffing are the advanced ladder's syllabus, and the course says so. Project Zero teaches exactly what a keyboard needs, at full depth
BLE, Project Zero
Free
  • All 8 chapters, labs, quizzes and diagrams
  • The optional XIAO battery finale included
  • The full companion repo on GitHub
  • Read anywhere in the online player
  • Free updates to the course
Start the free course

Free means free: no card, no trial, no expiry.

Before you start

You need basic C and a first microcontroller behind you; no Bluetooth experience is assumed. The board path needs an nRF52840 DK. Chapter 6 adds 12 keyboard switches, 12 1N4148 diodes, a breadboard and wire (a few dollars). The optional finale adds a Seeed XIAO nRF52840 and a small LiPo cell. Or read along with no hardware at all: the next section explains how that works.

What's included

Free, in full

This is the complete course, not a teaser for one. The same format, the same standard, the same desk as the paid shelf.

Free

The whole course, no card

Every chapter, every lab, every quiz and the appendix. Nothing is held back behind a paywall, and there is no trial clock. If it teaches you BLE the way it is meant to, the paid shelf is there when you want the advanced ladder.

Animated diagrams

The flows (the build and flash loop, announce-in-the-interrupt, advertising that restarts itself, the pairing sequence), taught as animations you play, pause and step through at your own pace.

40 quiz questions, with answer keys

Every chapter ends in a self-check quiz with full answers, so you find the gaps while they're still cheap to fix.

The troubleshooting appendix

When it breaks. Fifteen symptoms from this exact project: the advertising that never restarts, the phantom key, the bond the host forgot. Symptom, cause, fix.

Exercise-by-exercise code

The pad grows one verified step at a time in a public repo, every exercise a buildable checkpoint, nothing dropped on you all at once.

A product on your desk

A working macro pad you wired and programmed yourself, and with the optional finale, a battery product that reports its own charge. That is the artifact this course leaves you with.

Your choice

Two ways to take this course

Hardware is the recommended route, not an admission ticket. Start with the path that fits your desk today, and you can return to the bench later without starting over.

With hardware: build it for real

Use an nRF52840 DK, then the switches and diodes from Chapter 6, and the XIAO plus LiPo if you take the finale. You wire the matrix, scan it, pair the pad with your own computer and finish with a macro pad that works on your desk.

Read-along: no board required

Follow every chapter with the full code and the expected output at each checkpoint: every step's code and results are in the lessons, so the course can be followed with no hardware purchase. The chapter quizzes work the same.

What does not transfer is the bench feel: wiring a matrix that ghosts, watching a scanner find your pad, fixing a setup that misbehaves only in the room. That part stays worth coming back for.

Course FAQ

Before you ask

Is it really free?

Yes. Every chapter, lab, quiz and the appendix, with nothing held back and no card or trial involved. It is the beginner rung of the BLE ladder here, and it is free because a first project should be.

Do I need Bluetooth experience?

No. Basic C and having seen a microcontroller is the floor. Advertising, connections, GATT and pairing are all taught from zero, in the order the pad needs them.

Do I need the XIAO board?

No. The course completes on the nRF52840 DK alone (Chapters 1 to 7 plus the appendix). The XIAO appears only in Chapter 8, the optional finale that turns the pad into a standalone battery product.

What comes after Project Zero?

The advanced rung: LE Audio, Engineered, on this same shelf, builds a private LE Audio link and an Auracast broadcast on two nRF5340 Audio DKs. The topics Project Zero deliberately skips (custom profiles in depth, privacy, throughput, OTA, sniffing) are the advanced ladder's syllabus.