헤드리스 Pi 콘솔/journalctl에서 한글이 깨져 보이는 문제로, Pi 번들(02/03/04)에 들어가는 모든 소스의 사람-대상 텍스트를 영어로 전환. 코드·식별자·설정키·경로·숫자·hex·서명 스킴·f-string 플레이스홀더는 불변. - raspberry_pi4/, raspberry_pi4_sht30/: 로그·주석·문서·센서명·위치 영어화 - tools/make_deploy_bundles.py: 생성 템플릿(config_local.py/setup.sh/SETUP.md/PI_META 위치) 영어화 - tools/harden_pi.sh, tools/set_network.sh: echo/주석 영어화 - WIRING.html: 영어화 + SHT30 전압 경고 정정 반영 - 서버 번들(01, php/)은 한글 유지(브라우저 대시보드, Pi에서 안 깨짐) - 전 파이썬/셸 문법검사 통과, JSON 본문 서명 무영향
82 lines
5 KiB
Python
82 lines
5 KiB
Python
# =============================================================================
|
|
# config.py - Temperature/Humidity (SHT30) monitoring module (Pi 4 Model B) config — non-secret defaults
|
|
#
|
|
# Operational/secret values such as server URL / API_KEY / device identifiers (DEVICE_ID/LOCATION)
|
|
# are loaded from config_local.py. config_local.py is excluded from commits via .gitignore.
|
|
# Setup: cp config_local.example.py config_local.py → fill in the real values
|
|
#
|
|
# This module is "Module 2" (temperature/humidity). The server (php/) dashboard shows sensor_id=2 as the
|
|
# default temperature/humidity sensor, so the SENSOR_ID default is set to 2.
|
|
# =============================================================================
|
|
|
|
# ─────────────────────────────────────────────
|
|
# Sensor identity (for server dashboard display; not secret)
|
|
# SENSOR_ID is the key in the server's leak_sensor_metric / leak_sensor_status. Dashboard default chart=2.
|
|
# ─────────────────────────────────────────────
|
|
SENSOR_ID = 2
|
|
SENSOR_NAME = "Sensor 2 (SHT30)"
|
|
|
|
# ─────────────────────────────────────────────
|
|
# I2C bus config (Pi 4 40-pin header)
|
|
# SDA = GPIO2 (physical pin 3), SCL = GPIO3 (physical pin 5) → I2C bus 1
|
|
# ADDR pin: GND=0x44, VDD=0x45
|
|
# ─────────────────────────────────────────────
|
|
I2C_BUS = 1
|
|
I2C_ADDR = 0x44
|
|
|
|
# Force simulation. If True, runs with dummy measurements without hardware (for server integration checks).
|
|
# Even if False, the driver auto-falls back to simulation when smbus2 is not installed / I2C is disabled.
|
|
FORCE_SIMULATION = False
|
|
|
|
# ─────────────────────────────────────────────
|
|
# Measurement/report intervals (same defaults as firmware app_config.h)
|
|
# ─────────────────────────────────────────────
|
|
REPORT_INTERVAL = 300 # Normal measure/report interval (seconds) = 5 minutes
|
|
MEASURE_RETRY_DELAY = 5 # Wait before retry after a failed measurement (seconds)
|
|
|
|
# ─────────────────────────────────────────────
|
|
# Physical plausibility range for temp/humidity (same as firmware classify_metric_status)
|
|
# Values outside this range are reported as metric_status="out_of_range".
|
|
# * Operational threshold judgments (high/low temp, high/low humidity) and SMS are all handled
|
|
# by the server (config.php METRIC_*). This module only faithfully reports measurements.
|
|
# ─────────────────────────────────────────────
|
|
TEMP_LOW_C = -40.0
|
|
TEMP_HIGH_C = 125.0
|
|
RH_LOW = 0.0
|
|
RH_HIGH = 100.0
|
|
|
|
# Module identity version (server app_version field; the server only records it, does not validate)
|
|
APP_VERSION = "v2606-sht30-rpi4"
|
|
|
|
# ─────────────────────────────────────────────
|
|
# Logging config
|
|
# ─────────────────────────────────────────────
|
|
LOG_FILE = "/var/log/sht30_sensor.log"
|
|
LOG_MAX_BYTES = 5 * 1024 * 1024 # 5MB
|
|
LOG_BACKUP_COUNT = 3
|
|
|
|
# ─────────────────────────────────────────────
|
|
# HTTP retry config (same defaults as firmware APP_HTTP_*)
|
|
# ─────────────────────────────────────────────
|
|
HTTP_TIMEOUT = 10 # Single request timeout (seconds)
|
|
HTTP_RETRY_COUNT = 3 # Number of retries
|
|
HTTP_RETRY_DELAY = 5 # Wait between retries (seconds)
|
|
|
|
# ─────────────────────────────────────────────
|
|
# Load operational/secret values (fail closed)
|
|
# If config_local.py is missing, abort immediately with a clear error instead of
|
|
# starting incorrectly with placeholder/hardcoded secrets.
|
|
# ─────────────────────────────────────────────
|
|
try:
|
|
from config_local import ( # noqa: F401 (sht30_sensor.py re-imports from config)
|
|
API_URL,
|
|
API_KEY,
|
|
DEVICE_ID,
|
|
DEVICE_LOCATION,
|
|
)
|
|
except ImportError as e:
|
|
raise RuntimeError(
|
|
"config_local.py not found. "
|
|
"Run `cp config_local.example.py config_local.py`, then fill in the real server URL / API_KEY / "
|
|
"device info. (Never commit secret values.)"
|
|
) from e
|