[G1-Sync] Manual knowledge update

This commit is contained in:
Antigravity Agent
2026-05-10 22:08:15 +09:00
parent 21ac3ed255
commit 504fd5fb42
3011 changed files with 380280 additions and 206977 deletions
@@ -2,88 +2,177 @@
id: wiki-2026-0508-iot-and-ai-integration
title: IoT and AI Integration
category: 10_Wiki/Topics
status: needs_review
status: verified
canonical_id: self
aliases: [IOT-AI-001]
aliases: [Edge AI, TinyML, IoT AI, AIoT]
duplicate_of: none
source_trust_level: A
confidence_score: 1.0
tags: [iot, ai, aiot, Edge-Computing, smart-systems, sensor-networks]
confidence_score: 0.9
verification_status: applied
tags: [iot, edge-ai, tinyml, embedded, mqtt, sensor-fusion]
raw_sources: []
last_reinforced: 2026-04-26
last_reinforced: 2026-05-10
github_commit: pending
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
tech_stack:
language: unspecified
framework: unspecified
language: cpp
framework: tflite-micro
---
# IoT and AI Integration (IoT와 AI 통합)
# IoT and AI Integration
## 📌 한 줄 통찰 (The Karpathy Summary)
> "사물에 감각(IoT)을 달고 지능(AI)을 심어, 현실 세계와 디지털 세계를 유기적으로 연결하라" — 수많은 센서로부터 유입되는 방대한 시계열 데이터를 AI가 실시간으로 처리하여 자율적 판단과 예측을 수행하는 AIoT(AI of Things) 아키텍처.
## 한 줄
> **"매 센서 옆에서 즉시 추론"**. 수 KB-수 MB 모델을 ESP32/Cortex-M/Coral 같은 edge 기기에 올려 latency, privacy, bandwidth 를 동시에 잡는다. 2026 현재 TinyML + MQTT 가 표준.
## 📖 구조화된 지식 (Synthesized Content)
- **추출된 패턴:** "Edge-to-Cloud Intelligence" — 지연 시간(Latency)이 중요한 작업은 현장의 엣지 기기에서 즉시 처리하고, 거대 데이터 분석 및 장기 학습은 클라우드에서 수행하는 계층적 지능 연산 패턴.
- **주요 가치:**
- **[[Predictive_Maintenance|Predictive Maintenance]]:** 장비의 미세한 진동/소음 변화를 감지하여 고장 전 사전 정비.
- **Context Awareness:** 사용자의 위치, 조도, 온도 등을 종합하여 최적의 환경 자동 제공.
- **Energy [[Efficiency|Efficiency]]:** 전력 소비 패턴을 학습하여 낭비 요소를 실시간 차단.
- **의의:** AI가 모니터 속의 가상 데이터를 넘어 실제 물리 세계의 문제를 해결하고 제어하는 실질적인 힘을 갖게 함.
## 매 핵심
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
- **과거 데이터와의 충돌:** 단순히 데이터를 클라우드로 전송(Cloud-only)하던 방식에서, 보안과 속도를 위해 기기 자체에서 AI를 구동하는 '온디바이스 AI'와 '엣지 컴퓨팅' 중심으로 패러다임 전환.
- **정책 변화:** Antigravity 프로젝트는 로컬 하드웨어 센서 데이터를 처리할 때, 데이터의 프라이버시 보호를 위해 엣지 단계에서의 1차 필터링 및 익명화 처리를 필수 원칙으로 함.
### 매 3 layer 아키텍처
1. **Edge (sensor)**: TinyML 추론, 이상 감지, 게이팅.
2. **Fog (gateway)**: 다중 센서 통합, heavier 모델, 로컬 의사결정.
3. **Cloud**: 학습, fleet 모니터링, OTA 모델 업데이트.
## 🔗 지식 연결 (Graph)
- [[Edge-AI-and-Computing|Edge-AI-and-Computing]], Cloud-Security-[[Mastery|Mastery]], Real-time-Data-[[Processing|Processing]], Hybrid-Cloud-Architectures
- **Raw Source:** 10_Wiki/Topics/AI/IoT-and-AI-Integration.md
### 매 모델 압축
- **Quantization**: float32 → int8/int4, 4-8x 작아짐.
- **Pruning**: weight magnitude 기준 sparsify.
- **Knowledge distillation**: large teacher → tiny student.
- **NAS for edge**: MCUNet, MobileNet.
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
### 매 통신
- **MQTT**: pub/sub, QoS 0/1/2.
- **CoAP**: REST-over-UDP, 더 가벼움.
- **LoRaWAN**: km 단위, 수백 byte/min.
- **BLE**: 근거리, 저전력.
**언제 이 지식을 쓰는가:**
- *(TODO)*
### 매 응용
1. Predictive maintenance (vibration anomaly).
2. Vision: door cam person detection, defect inspection.
3. Voice wakeword (Alexa, "OK Google").
4. Smart agriculture (soil moisture + weather).
5. Health wearable (HRV, fall detection).
**언제 쓰면 안 되는가:**
- *(TODO)*
## 💻 패턴
## 🧪 검증 상태 (Validation)
### TFLite Micro 추론 (ESP32, C++)
```cpp
#include "tensorflow/lite/micro/micro_interpreter.h"
- **정보 상태:** needs_review
- **출처 신뢰도:** A
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
const tflite::Model* model = tflite::GetModel(g_model_data);
static tflite::MicroMutableOpResolver<5> resolver;
resolver.AddConv2D(); resolver.AddMaxPool2D();
resolver.AddReshape(); resolver.AddFullyConnected(); resolver.AddSoftmax();
## 🧬 중복 검사 (Duplicate Check)
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
- **처리 방식:** UPDATE (자동 정규화)
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
## 🕓 변경 이력 (Changelog)
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|------|-----------|-----------|--------|
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
## 💻 코드 패턴 (Code Patterns)
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
```text
# TODO
constexpr int kArena = 60 * 1024;
uint8_t arena[kArena];
tflite::MicroInterpreter interp(model, resolver, arena, kArena);
interp.AllocateTensors();
TfLiteTensor* in = interp.input(0);
memcpy(in->data.int8, sensor_buf, in->bytes);
interp.Invoke();
int8_t* out = interp.output(0)->data.int8;
```
## 🤔 의사결정 기준 (Decision Criteria)
### Post-training quantization (Python)
```python
import tensorflow as tf
**선택 A를 써야 할 때:**
- *(TODO)*
conv = tf.lite.TFLiteConverter.from_saved_model("model")
conv.optimizations = [tf.lite.Optimize.DEFAULT]
conv.target_spec.supported_types = [tf.int8]
conv.representative_dataset = lambda: (
[x.astype("float32")] for x in calib_samples[:200]
)
open("model_int8.tflite", "wb").write(conv.convert())
```
**선택 B를 써야 할 때:**
- *(TODO)*
### MQTT publish 추론 결과 (MicroPython)
```python
from umqtt.simple import MQTTClient
**기본값:**
> *(TODO)*
c = MQTTClient("esp32-01", "broker.local")
c.connect()
while True:
feat = read_imu()
label = tinyml_infer(feat)
if label != "normal":
c.publish(b"factory/line1/anomaly",
ujson.dumps({"label": label, "ts": time.time()}))
time.sleep(0.1)
```
## ❌ 안티패턴 (Anti-Patterns)
### Sensor fusion (Kalman, complementary)
```cpp
// 6DOF IMU complementary filter
float alpha = 0.98f;
roll = alpha * (roll + gyro_x * dt) + (1 - alpha) * accel_roll;
pitch = alpha * (pitch + gyro_y * dt) + (1 - alpha) * accel_pitch;
```
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
### Edge Impulse SDK (anomaly)
```cpp
ei_impulse_result_t result;
signal_t signal;
numpy::signal_from_buffer(features, EI_FEATURE_COUNT, &signal);
run_classifier(&signal, &result, false);
if (result.anomaly > 0.5) trigger_alert();
```
### OTA 모델 업데이트
```cpp
HTTPClient http;
http.begin("https://cdn/model_v3.tflite");
if (http.GET() == 200) {
File f = SPIFFS.open("/model.tflite", "w");
http.writeToStream(&f); f.close();
ESP.restart();
}
```
### Coral Edge TPU (Python)
```python
from pycoral.utils.edgetpu import make_interpreter
from pycoral.adapters import classify
it = make_interpreter("model_edgetpu.tflite")
it.allocate_tensors()
it.set_tensor(it.get_input_details()[0]["index"], img)
it.invoke()
print(classify.get_classes(it, top_k=1))
```
## 매 결정 기준
| 제약 | 권장 |
|---|---|
| MCU < 1MB RAM | TFLite Micro int8, MCUNet |
| 배터리 1년+ | LoRaWAN + duty cycle |
| Vision realtime | Coral / Jetson Nano |
| Privacy critical | edge inference, no cloud raw |
| Fleet 수만+ | MQTT broker cluster, OTA |
**기본값**: ESP32 + TFLite Micro int8 + MQTT QoS 1.
## 🔗 Graph
- 부모: [[Edge-Computing]], [[Embedded-Systems]]
- 변형: [[TinyML]], [[Federated-Learning]]
- 응용: [[Predictive-Maintenance]], [[Smart-Home]], [[Wearables]]
- Adjacent: [[Quantization]], [[MQTT]], [[Sensor-Fusion]]
## 🤖 LLM 활용
**언제**: latency 100ms 이하 필요, 네트워크 불안정, privacy 규제, bandwidth 비싼 환경.
**언제 X**: 모델 100MB+, 잦은 재학습 필요, 입력이 크고 다양한 multimodal.
## ❌ 안티패턴
- **Cloud 의존 edge**: 인터넷 끊기면 동작 안 함 → fallback 필수.
- **Float32 모델 그대로 배포**: RAM 부족, 발열.
- **OTA 미고려**: 모델 버그 fix 불가.
- **Sensor 단일**: 노이즈에 취약, fusion 으로 견고화.
- **MQTT QoS 0 + 중요 alert**: 패킷 유실 가능.
## 🧪 검증 / 중복
- TFLite Micro, Edge Impulse, MQTT 5.0 spec, Coral docs.
- Warden & Situnayake "TinyML" (O'Reilly).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — 3-layer 구조, TFLite Micro/Edge Impulse/MQTT/OTA 패턴 |