Skip to the content
4 layers42.2 × 42.2 mmAFO lite, the printed circuit board in 3D

A simple air quality measurement system

Size
42.2 × 42.2 mm
Copper layers
4
Thickness
4.69 mm
Parts
44
Nets
47
Pads
232
Tracks, vias
382, 63
Pours
3
Routed
Yes
KiCad
KiCad 6 (file 20211014)
Created
3 Oct 2021
Updated
11 Feb 2024

Overview

AFO lite is an open-source printed circuit board by matoushybl, from the matoushybl/air-force-one repository on GitHub, published under the MIT licence. It is a 4-layer board of 42.2 × 42.2 mm with 44 parts on 47 nets, routed with 382 tracks and 63 vias.

It is built around the ACN52840. Its parts include 12 resistors, 8 capacitors, 5 ICs, 5 switches and 4 connectors. It belongs with the sensors and measurement boards and the nRF52 and nRF5x boards of this library.

Main components

1

README

README.md

Air Force One - a simple air quality measurement system

Air Force One is a simple air quality measurement systems primarily designed to measure CO2 concentration in multiple rooms of a small apartment. It consists of nodes responsible for measuring the data and broadcasting them using BLE advertisements and a bridge which periodically receives the data and publishes them over MQTT for further processing - in this case displaying them in dashboards of Home Assistant. There are two types of nodes which differ in used hardware and therefore communication protocol. The project was originally developed with the Bluetooth ones in mind, while the ESP32/WiFi one was added only as an experiment.

An overview of the system can be seen in the following image. overview

Project structure

  • node-fw - firmware for the Bluetooth node
  • node-c3 - firmware for the ESP32/WiFi node
  • bridge-fw - firmware for the Bluetooth bridge
  • shared - shared library for node and bridge firmware
  • pcb - design files for the electronics
  • case - design files for the case

Hardware

The hardware for this project is based on Nordic's nRF52840 bluetooth enabled MCU. CO2 concentration, temperature and humidity are measured by a Sensirion SCD41 sensor. The hardware was developed to allow for more features in the future so apart from the SCD41, there are more on-board parts:

  • QSPI flash for measurements logging
  • 4 buttons
  • a connector and a hardware switch for connecting external battery (the circuitry however was not optimized for low-power even though it is well supported with embassy on nRF52)
  • SHT4x sensor for more precise temperature and humidity measurements (the sensors were either badly wired or damaged on prototype boards, so no support for them was added)
  • broken out pins allowing for some extensibility

The nodes and the bridge do not differ hardware wise, but the prototype bridge didn't have assembled anything other than the nRF52 module, LDO and USB circuitry to save parts, so no measurement support is available in the bridge firmware. The difference between them can be seen in the following image. hardware

For firmware flashing a SWD probe is required. The programming connector on-board is the 10-pin Cortex-M debug connector with 1.27 mm pitch. An example of a usable probe with the same connector is the hs-probe.

There is also a case available fitting the PCB shape. case

Firmware

The firmware for both the node and the bridge is written in Rust and utilizes embassy async framework as well as nrf-softdevice for bluetooth support. As such it is assumed that you have standard embedded Rust development tools installed - such as probe-rs.

To use the firmware, Nordic's softdevice must first be flashed to the MCU.

  1. First download the Softdevice from here
  2. Mass erase the MCU probe-rs erase --chip nrf52840_xxAA
  3. Flash the softdevice probe-rs download --verify --format hex --chip nRF52840_xxAA s140_nrf52_7.X.X_softdevice.hex

Mass erasing the MCU has an unfortunate side effect of disabling reset pin. The firmwares in this repository reenable this functionality on startup.

Both of the firmware have their panic behavior configured to automatic reset, for development purposes however, it is better to switch to panic-probe panic handler using the 'dev' feature that can be passed to cargo.

Node Firmware

Firmware for the node periodically reads data from the SCD41 sensor and updates Manufacturer Specific Data that are part of BLE advertisement. For accessing the SCD41 sensor, the firmware uses the sensirion-async library.

Flashing the firmware can be done in the node-fw directory by running cargo run --release.

Bridge Firmware

Firmware for the bridge scans for available nodes and reads the Manufacturer Specific data part of the node's advertisement. A CDC-NCM bridge is utilized to establish a connection to a MQTT broker. Data read from the scans are then published via the broker. Static IP addresses are utilized in this configuration.

Flashing the firmware can be done in the bridge-fw directory by running cargo run --release.

Experimental ESP32/WiFi node

As an experiment a node based on ESP32-C3 was developed. The firmware for this node is written using a similar technological stack as the nRf52 firmware - Rust and embassy. The firmware is located in the node-c3 directory. A defining difference is that this node directly accesses the MQTT broker, making it much more simpler and hopefully more reliable.

This node also utilizes off-the-shelf hardware, so no custom PCB is requried. In this case this ESP32-C3 board this SCD41 breakout board were used, but any development kits should work the same (apart from assigning pins for the I2C).

When building the firmware SSID, password and MQTT broker address must be set as environent variables. Refer to the respective main.rs for environment variable names.

As of time of publishing, the firmware uses unreleased esp-rs crates - esp-backtrace and esp-println alongside with espflash tool. These were used to add support for defmt.

Accessing the measured data

Configuring the network interface

The network interface can either be configured one-time using the ip command or using netplan on Ubuntu using a similar config to the one below. Using netplan has an advantage of the configuration being persistent over reboots and bridge reconnects.

The following config sets a static IP on the USB CDC-NCM interface.

text
network:
  version: 2
  renderer: networkd
  ethernets:
      enx888888888888:
          optional: true
          dhcp4: no
          addresses: [10.42.0.1/24]

MQTT

The bridge firmware expects an MQTT broker running on the computer it is connected to. A simple way to spin up the broker is to use docker.

text
docker run -it -p 1883:1883 -v $(pwd)/mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto

The bridge expects the broker to run without authentication, which can be achieved by the following mosquitto.conf:

text
listener 1883
allow_anonymous true

Home Assistant

Once the measured data are published to the broker, MQTT integration in Home Assistant can be used to access the measured data. A sample Home Assistant configuration can be found below.

yaml
mqtt:
  sensor:
    - name: "Bedroom - co2"
      state_topic: "afo-1"
      unit_of_measurement: "PPM"
      value_template: "{{ value_json.co2 }}"
      device_class: "carbon_dioxide"
    - name: "Bedroom - humidity"
      state_topic: "afo-1"
      unit_of_measurement: "%"
      value_template: "{{ value_json.humidity }}"
      device_class: "humidity"
    - name: "Bedroom - temperature"
      state_topic: "afo-1"
      unit_of_measurement: "°C"
      suggested_display_precision: 1
      value_template: "{{ value_json.temperature }}"
      device_class: "temperature"
    - name: "Living room - co2"
      state_topic: "afo-0"
      unit_of_measurement: "PPM"
      value_template: "{{ value_json.co2 }}"
      device_class: "carbon_dioxide"
    - name: "Living room - humidity"

Parts

44
QtyValueFootprintReferences
51uFCapacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolderC1, C4, C5, C7, C8
410kResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR9, R10, R11, R12
4MHMountingHole:MountingHole_2.5mm_Pad_ViaH1, H2, H3, H4
3100nFCapacitor_SMD:C_0603_1608Metric_Pad1.08x0.95mm_HandSolderC2, C3, C6
3FBInductor_SMD:L_0805_2012Metric_Pad1.15x1.40mm_HandSolderFB1, FB2, FB3
21kResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR5, R6
222RResistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR3, R4
22k2Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR7, R8
25k1Resistor_SMD:R_0603_1608Metric_Pad0.98x0.95mm_HandSolderR1, R2
1ACN52840moonforge-pcb:ANC52840U1
1BUTT1Button_Switch_SMD:SW_SPST_B3U-3000PSW1
1BUTT2Button_Switch_SMD:SW_SPST_B3U-3000PSW2
1BUTT3Button_Switch_SMD:SW_SPST_B3U-3000PSW3
1BUTT4Button_Switch_SMD:SW_SPST_B3U-3000PSW4
1Battery_CellConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_HorizontalBT1
1Conn_01x04_FemaleConnector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ4
1Conn_01x10_FemaleConnector_PinHeader_2.54mm:PinHeader_1x10_P2.54mm_VerticalJ3
1GD25QxxPackage_SO:SOP-8_5.28x5.23mm_P1.27mmU3
1GreenLED_SMD:LED_0805_2012Metric_Pad1.15x1.40mm_HandSolderD2
1NCV8165MLPackage_DFN_QFN:DFN-8-1EP_3x3mm_P0.65mm_EP1.55x2.4mmU4
1RedLED_SMD:LED_0805_2012Metric_Pad1.15x1.40mm_HandSolderD1
1SCD4xmoonforge-pcb:SCD4xU5
1SHT4xmoonforge-pcb:SHT4xU2
1SWButton_Switch_SMD:SW_SPDT_PCM12SW5
1SWDConnector_PinHeader_1.27mm:PinHeader_2x05_P1.27mm_Vertical_SMDJ2
1USB-CConnector_USB:USB_C_Receptacle_XKB_U262-16XN-4BVC11J1

Similar boards

  • 4 layers52 × 42 mmHa coap pcb, the printed circuit board in 3D

    Ha coap pcb

    yanntalhouarne/ha-coap-pcb

    104 parts
  • 4 layers49 × 30 mmGcvideo lite, the printed circuit board in 3D

    Gcvideo lite

    ikorb/gcvideo

    GameCube Digital AV converter

    44 parts766
  • 4 layers36.4 × 15 mmOvrdrive, the printed circuit board in 3D

    Ovrdrive

    o7-machinehum/ovrdrive

    Security focused USB drive.

    44 parts365MIT
  • 4 layers36 × 48 mmApollo3 module, the printed circuit board in 3D

    Apollo3 module

    TUDSSL/ENGAGE

    Source code repository for ENGAGE: Battery-Free Game Boy

    44 parts286MIT
  • 4 layers37.1 × 37.2 mmDoorman, the printed circuit board in 3D

    Doorman

    AzonInc/Doorman

    ESP32-S3 based Intercom Gateway (TCS / Koch / Niko / Scantron / Analogue Systems)

    44 parts252GPL-3.0
  • 4 layers90 × 47 mmPicohome relay, the printed circuit board in 3D

    Picohome relay

    racerxdl/picohome

    Raspberry Pi Pico Home Automation using CAN Bus

    44 parts90Apache-2.0
  • 4 layers62 × 49 mmUnijoysticle2plus, the printed circuit board in 3D

    Unijoysticle2plus

    ricardoquesada/unijoysticle2

    Bluetooth gamepad support for the Commodore 64 / Atari / Amiga, etc.

    44 parts62
  • 4 layers33 × 54.3 mmBusinessCard OG, the printed circuit board in 3D

    BusinessCard OG

    StuckAtPrototype/PCB_business_card_original

    A custom PCB based "business" card that lets you play a version of Flappy Bird.

    44 parts53Apache-2.0

Questions

How big is the AFO lite PCB?

It measures 42.2 × 42.2 mm and has 4 copper layers, 4.69 mm thick.

What parts does the AFO lite use?

44 parts, built around the ACN52840. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the AFO lite KiCad files?

From the matoushybl/air-force-one repository on GitHub, at the commit this page was made from: the board is pcb/AFO-lite.kicad_pcb and its schematic pcb/AFO-lite.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the AFO lite design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).