Kick off your book project in 2 hours, get started with GhostAI in 2 hours, or do both! Free live workshops, on Zoom. You’ll leave with a real book project and a clear plan to keep going. Saturday, June 27, 2026.

Leanpub Header

Skip to main content

Embedded Firmware with Zephyr RTOS

A Practical Guide from LED to Custom PCB

Most Zephyr tutorials stop at blinking an LED. This one doesn't. In 24 days you'll write a real accelerometer driver, stream CBOR-encoded sensor data over USB, define your own PCB board target, and put the processor into sub-µA sleep. Every day builds something that runs on real hardware.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
About

About

About the Book

Embedded Firmware with Zephyr RTOS is a hands-on, 24-day guide for engineers who want to build real firmware on the nRF52840 — not just blink an LED, but ship production-ready code.

Each day introduces one concept, one working example, and one buildable project. You start with the Zephyr build system and Device Tree basics, then progress through threads, GPIO interrupts, USB communication, CBOR encoding, and BLE advertising. By the end, you will have written a custom I2C accelerometer driver, streamed live sensor data to a PC over USB, defined your own PCB board target, and put the processor into sub-µA sleep — the same techniques used in commercial wearables and IoT products.

What's inside:

  • 24 structured lessons with working Zephyr source code for every day
  • Custom driver development for sensors not supported by upstream Zephyr
  • USB CDC-ACM, CBOR encoding, and a Python decoder tool for live data visualization
  • BLE peripheral advertising, SPI flash, ADC, PWM, NVS storage, and power management
  • A complete custom PCB board definition — ready to adapt to your own hardware
  • Setup guide covering Zephyr 4.x, West, and SDK 1.0.1 on Linux

Who this is for: Embedded engineers with C experience who are new to Zephyr, developers moving from bare-metal or Arduino to an RTOS, and hardware engineers writing firmware for their own nRF52840-based designs.

Hardware required: Nordic nRF52840 DK and a USB cable.

Share this book

Author

About the Author

Jovin Basil

Electronics Design Enginnering Specialist with 10+ years of experience in electronics circuit design

Contents

Table of Contents

Embedded Firmware with Zephyr RTOS

  1. A Practical Guide from LED to Custom PCB

Before You Begin — Workspace Setup

  1. Requirements
  2. Quick setup (copy-paste)
  3. Session setup (run at the start of every terminal session)
  4. Verify the setup

Day 1 — Introduction to Zephyr RTOS

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic
  8. Tomorrow, we will explore Zephyr project structure and the build system in depth.

Day 2 — Zephyr Project Structure and Build System

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic
  8. Tomorrow, we will cover Device Tree basics and how Zephyr maps hardware in software.

Day 3 — Device Tree Basics in Zephyr

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic
  8. Tomorrow, we will study Kconfig and prj.conf configuration in Zephyr.

Day 4 — Kconfig and prj.conf Configuration

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic
  8. Tomorrow, we will write a basic Zephyr application with main loop and device initialization.

Day 5 — Writing a Basic Zephyr Application

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic
  8. Tomorrow, we will learn how to use Zephyr drivers and device binding properly.

Day 6 — Using Zephyr Drivers and Device Binding

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic
  8. Tomorrow, we will cover debugging and testing Zephyr applications.

Day 7 — Debugging and Testing Zephyr Applications

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic
  8. After this, you can continue with advanced Zephyr concepts such as Bluetooth, networking, and power management.

Day 8 — Threads and Synchronization

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 9 — GPIO and Interrupts

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 10 — Custom PCB Board Definition

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 11 — USB CDC-ACM Communication

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 12 — CBOR Encoding over USB

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 13 — Zephyr Shell Subsystem

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 14 — I2C Sensor Integration

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 15 — KXTJ3-1057 Accelerometer with USB Shell

  1. Goal
  2. What you will learn
  3. KXTJ3-1057 Overview
  4. Hardware wiring (nRF52840 DK)
  5. Project structure
  6. prj.conf
  7. Shell commands implemented
  8. Converting raw counts to mg
  9. Why this matters
  10. Practice tasks
  11. Example folder
  12. Next topic

Day 16 — KXTJ3-1057 Accelerometer with CBOR over USB

  1. Goal
  2. What you will learn
  3. CBOR frame format
  4. Shell commands
  5. Python decoder (tools/decode_accel.py)
  6. Why this matters
  7. Practice tasks
  8. Example folder
  9. Next topic

Day 17 — BLE GATT Services

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 18 — BLE Peripheral Advertising

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 19 — SPI Communication

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 20 — ADC Reading

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 21 — PWM LED Dimming

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 22 — NVS Flash Storage

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 23 — Work Queues and Kernel Timers

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Day 24 — Power Management and Sleep

  1. Goal
  2. What you will learn
  3. Overview
  4. Why this matters
  5. Practice tasks
  6. Example folder
  7. Next topic

Capstone Project — Days 25–27: Wireless Sensor Node

  1. Day 25 — Sensor + NVS Integration
  2. Day 26 — BLE GATT Environmental Service
  3. Day 27 — Sleep and Wake-Up Loop
  4. Example folder

Appendix A — Troubleshooting

  1. Build errors
  2. Runtime / flashing errors

Appendix B — Glossary

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub