Skip to the content
PCBKitNew board
2 layers65 × 30 mmLoRaCam, the printed circuit board in 3D

AI camera via LoRa on Raspberry Pi

Size
65 × 30 mm
Copper layers
2
Thickness
1.6 mm
Parts
12
Nets
55
Pads
80
Tracks, vias
32, 0
Pours
2
Routed
Yes
KiCad
KiCad 9.0 (file 20241229)
Created
14 Jan 2026
Updated
9 Oct 2026

Overview

LoRaCam is an open-source printed circuit board by mocchan0221, from the mocchan0221/LoRaCam repository on GitHub. It is a 2-layer board of 65 × 30 mm with 12 parts on 55 nets, routed with 32 tracks and 0 vias.

Its parts include 4 resistors, 2 diodes, 1 IC and 1 connector. It belongs with the radio and wireless boards of this library.

README

README.md

LoRaCam

AI camera via LoRa on Raspberry Pi

Raspberry Pi + カメラで YOLOv8n (TFLite) による人数カウントを行い、結果を CSV に記録しつつ LoRaWAN で送信するデバイス。

動作環境

  • Raspberry Pi Zero 2 W / Raspberry Pi OS Bookworm (Python 3.11)
  • Camera Module 3 (imx708)
  • LoRa モジュール A660-900T22 (UART /dev/ttyS0, 9600bps) — AS923-1 (日本), OTAA, Class A

ディレクトリ構成

パス内容
main.pyエントリポイント (設定読込 → Wi-Fi/ホスト名設定 → LoRa Join → 撮影・検出・送信ループ)
app/各種機能 (カメラ, 検出器, ログ, LoRa通信, 設定, システム初期化)
models/YOLO モデル置き場 (git管理外)
data/images, data/logs最新の検出画像・CSVログ (git管理外)
services/systemd サービス定義
scripts/dev_update.sh開発機用ワンクリック更新スクリプト
LoRaTest.py, SystemTest.pyLoRa 通信 / システム設定の単体テスト
pcb/基板データ (KiCad)

セットアップ (開発機)

サービス定義と更新スクリプトはユーザー jkkb、パス /home/jkkb/LoRaCam 前提。

  1. sudo raspi-config → Interface Options → Serial Port で「Login shell: No」「Serial port hardware: Yes」にして再起動
  2. リポジトリを取得して仮想環境を作成
    bash
    cd ~ && git clone https://github.com/mocchan0221/LoRaCam.git && cd LoRaCam
    sudo apt install -y python3-picamera2 python3-opencv
    python3 -m venv --system-site-packages .venv   # apt の picamera2 を venv から使うため
    .venv/bin/pip install -r requirements.txt
    • tflite-runtime は numpy 2.x では動かないため numpy<2 (requirements では 1.26.4) を使う
    • シリアル通信は pyserial。serial パッケージを入れると module 'serial' has no attribute 'Serial' になる
  3. モデルを用意 (PC 側で変換して models/ にコピー)
    bash
    pip install ultralytics
    yolo export model=yolov8n.pt format=tflite int8
    # → yolov8n_saved_model/yolov8n_full_integer_quant.tflite を models/ へ
  4. 設定ファイルを配置: config_template.json を /boot/firmware/config.json にコピーして編集 (下記)
  5. サービス登録
    bash
    sudo cp services/*.service /etc/systemd/system/
    sudo systemctl daemon-reload
    sudo systemctl enable --now LoRaCam.service WebMonitor.service

設定 (/boot/firmware/config.json)

キー内容
LoRa.DEVEUI / APPEUI / APPKEYOTAA 用のキー
LoRa.IsJoined1 なら起動時の Join をスキップ
Camera.Focusマニュアルフォーカス値 (LensPosition, 0.0 = 無限遠)
Network.wifi_enabled0: Wi-Fi OFF / 1: Wi-Fi ON (SSID, PASSWORD に接続)
Network.HostNameホスト名 (.local は付けない。例: jkkb1 → jkkb1.local でアクセス)
Network.IsLatest0 にすると次回起動時に Wi-Fi・ホスト名を適用し、1 に書き換えて再起動
Detection.Interval検出・送信の間隔 [秒]
Detection.CONF_THRESHOLD検出の信頼度しきい値

動作確認

bash
journalctl -u LoRaCam.service -f          # 本体のログ
sudo .venv/bin/python LoRaTest.py         # 対話式 LoRa テスト (join / send / recv / at)
sudo .venv/bin/python SystemTest.py       # Wi-Fi・ホスト名設定のテスト (IsLatest=0 のとき再起動する)

LoRaTest を使う前に sudo systemctl stop LoRaCam.service でシリアルポートを空けておく。

出力:

  • data/logs/logPerson.csv (人数), logAll.csv (全クラス), logLoRa.csv (送受信履歴)
  • data/images/latest_result.jpg (最新の検出画像)
  • WebMonitor により http://<ホスト名>.local:8000/data/ から閲覧可能
  • LoRa 送信ペイロード: "YYYY-mm-dd HH:MM:SS <人数>" の ASCII 文字列

ステータスLED

緑 (GPIO17)赤 (GPIO27)状態
点滅消灯初期化中 (設定読込・カメラ・LoRa Join)
点灯消灯正常動作中
消灯点灯異常終了 (エラー終了・クラッシュ・120秒応答なし)。10秒後に自動再起動
点滅点灯異常終了後の再起動中。正常動作に入ると赤は消える
消灯消灯サービス停止中

赤点灯の原因は journalctl -u LoRaCam.service と /run/loracam-error で確認できる。

開発フロー

PC で編集して push → 開発機で bash scripts/dev_update.sh (sudo は付けない)。pull・サービス更新・再起動を一括で行い、pip は requirements.txt が変わったときだけ実行 (--force-pip で強制)。

デバイスの複製

  1. 開発機の SD カードを Win32 Disk Imager でイメージ化 (必要なら WSL2/Linux の pishrink で圧縮)
  2. Raspberry Pi Imager 等で新しい SD カードに書き込み
  3. PC から bootfs パーティションの config.json を個体ごとに編集 (キー、ホスト名など。IsLatest: 0, IsJoined: 0)
  4. 電源投入で初回にネットワーク設定を適用して再起動し、以降は自動で動作開始

Parts

12
QtyValueFootprintReferences
4MountingHole_2.7mm_M2.5MountingHole:MountingHole_2.7mm_M2.5MH1, MH2, MH3, MH4
4RResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR1, R2, R3, R4
2LEDLED_THT:LED_D5.0mmD1, D2
1A660-900T22-EV61MyParts:A660-900T22-EV61U2
1GPIOConnector_PinSocket_2.54mm:PinSocket_2x20_P2.54mm_VerticalJ1

Questions

How big is the LoRaCam PCB?

It measures 65 × 30 mm and has 2 copper layers, 1.6 mm thick.

What parts does the LoRaCam use?

12 parts. 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 LoRaCam KiCad files?

From the mocchan0221/LoRaCam repository on GitHub, at the commit this page was made from: the board is pcb/LoRaCam.kicad_pcb and its schematic pcb/LoRaCam.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the LoRaCam design in my own project?

Its repository states no licence, so its author keeps all rights: ask mocchan0221 before reusing the design.

Similar boards

  • 2 layersNrf bga, the printed circuit board in 3D

    Nrf bga

    github-linguist/linguist

    Language Savant. If your repository's language is being reported incorrectly, send us a pull request!

    12 parts14kMIT
  • 2 layers66.9 × 74.5 mmDeskHop, the printed circuit board in 3D

    DeskHop

    hrvach/deskhop

    Fast Desktop Switching Device

    12 parts7.9kGPL-3.0
  • 2 layers40 × 15 mmSensors, the printed circuit board in 3D

    Sensors

    google/mozc-devices

    Circuit diagrams and firmware source code for Gboard DIY keyboards

    12 parts3kApache-2.0
  • 2 layers42.7 × 56.5 mmTle6240 driver, the printed circuit board in 3D

    Tle6240 driver

    rusefi/rusefi

    rusefi - GPL internal combustion engine control unit

    12 parts1.2k
  • 2 layers49 × 25 mm5v boost regulator, the printed circuit board in 3D

    5v boost regulator

    hackclub/OnBoard

    💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

    12 parts915
  • 2 layers28.3 × 10.3 mmTap Photosensor PCB, the printed circuit board in 3D

    Tap Photosensor PCB

    VoronDesign/Voron-Tap

    Tap is a nozzle-based z-probe for the V2 and Trident printer designs. The entire toolhead moves to trigger an optical switch. Tap offers many advantages:

    12 parts716GPL-3.0
  • 2 layers25.4 × 70.4 mmTpmsniffer, the printed circuit board in 3D

    Tpmsniffer

    stacksmashing/pico-tpmsniffer

    A simple, very experimental TPM sniffer for LPC bus

    12 parts696