7aa8cd2a1c
Spec, plan d'implémentation, design system, documentation de déploiement. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
100 lines
4.4 KiB
Markdown
100 lines
4.4 KiB
Markdown
# CLAUDE.md
|
||
|
||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. tu t'exprimera uniquement en francais, les page web et les commentaire seront en francais
|
||
brainstorming + recherche web -> plan.md et feature.md
|
||
ecrire un fichier readme.md de deploiement
|
||
|
||
## Project
|
||
|
||
**esp_jardin** — ESP32 firmware for a garden environmental monitoring station. Acquires temperatures from 3 DS18B20 sensors on OneWire (GPIO 4), stores 24h rolling history in RAM, and exposes a real-time web interface (WebSocket) and a REST API.
|
||
|
||
Full specifications: [`Fichier de Consignes - esp_jardin.md`](Fichier\ de\ Consignes\ -\ esp_jardin.md)
|
||
|
||
## Build & Development Commands
|
||
|
||
```bash
|
||
pio run # Compile only
|
||
pio run -t upload # Compile + flash via USB
|
||
pio device monitor # Open serial monitor (115200 baud)
|
||
pio run -t upload && pio device monitor # Flash then monitor
|
||
pio run -t clean # Clean build artifacts
|
||
```
|
||
|
||
Environment: `esp32dev` (Espressif32, Arduino framework) — defined in [platformio.ini](platformio.ini).
|
||
|
||
## Target Architecture
|
||
|
||
The project must be **modular** — no logic in `main.cpp` beyond initialisation and the state machine loop.
|
||
|
||
```
|
||
include/
|
||
config.h # Constants and structs derived from parametrage.md
|
||
network.h # WiFi (STA/AP hybrid), mDNS, OTA, WebSockets
|
||
sensors.h # OneWire, DallasTemperature, circular RAM buffer
|
||
web_server.h # HTTP routing, REST API declarations
|
||
mqtt_manager.h # MQTT client declarations
|
||
src/
|
||
main.cpp # setup(), loop() — state machine only, no blocking
|
||
network.cpp
|
||
sensors.cpp
|
||
web_server.cpp
|
||
mqtt_manager.cpp
|
||
data/
|
||
index.html # Served from SPIFFS/LittleFS
|
||
design_system/ # CSS tokens, React UI-kit (read-only reference)
|
||
```
|
||
|
||
## Critical Constraints
|
||
|
||
**No blocking code** — `delay()` is forbidden. Use `millis()` for all timing.
|
||
|
||
**Temperature handling:**
|
||
- Format to 1 decimal place (`%.1f`)
|
||
- Discard sensor errors: −127.0°C (CRC fail) and 85.0°C (power-on default)
|
||
- History: circular buffer of 288 points/sensor (uint32_t timestamp + 2× float = 12 bytes each)
|
||
|
||
**WiFi:** Boot in STA mode; fall back to AP (`ESP_CHEF_JARDIN`) after 30s timeout. Reconnect loop must never block the main loop.
|
||
|
||
**WebSocket:** Push new readings as JSON to all connected clients immediately after acquisition. No HTTP polling for real-time data.
|
||
|
||
**MQTT per-sensor:** Each sensor publishes independently with deadband filtering (skip publish if delta < threshold AND max interval not elapsed).
|
||
|
||
**REST endpoints:**
|
||
- `GET /api/status` — WiFi RSSI, uptime, free RAM
|
||
- `GET /api/temperatures` — current readings as JSON
|
||
- `GET /api/history` — full 24h buffer as JSON array
|
||
|
||
## GPIO Allocation
|
||
|
||
| GPIO | Function | Notes |
|
||
|------|----------|-------|
|
||
| 4 | OneWire bus (DS18B20) | 4.7kΩ pull-up to 3.3V required |
|
||
| 21 | I2C SDA (future) | BH1750 / SHT31 |
|
||
| 22 | I2C SCL (future) | |
|
||
| 32/33 | ADC1 (future) | Soil moisture — ADC1 only (ADC2 conflicts with WiFi) |
|
||
| 25/26 | Digital out (future) | Relays / actuators |
|
||
| 14/27 | Interrupts (future) | Rain gauge / push button |
|
||
|
||
## Web Interface — Design System
|
||
|
||
The web UI must use the **Gruvbox Seventies** design system from [`design_system/`](design_system/). Full rules in [`design_system/consigne_design_system.md`](design_system/consigne_design_system.md).
|
||
|
||
**Absolute rules:**
|
||
- Always use CSS variables — never hardcode hex colors (`var(--accent)` not `#fe8019`)
|
||
- Always declare `data-theme="dark"` (or `"light"`) on `<html>` or a parent wrapper
|
||
- Use existing components from `ui-kit.jsx` — check before creating anything new
|
||
- Icons: use `<Icon name="…">` with mapped names — no emoji, no inline SVG
|
||
- Fonts: `--font-ui` (Inter) for UI, `--font-mono` (JetBrains Mono) for numeric data, `--font-terminal` (Share Tech Mono) for logs
|
||
- Tiles: `border-radius: 10–12px`, use `className="glass"` for styling
|
||
- Labels: uppercase + `letter-spacing: 0.08em`
|
||
|
||
**For temperature display:** `<LineChart>` for 24h history, `<RadialGauge>` or `<BatteryGauge>` for live KPIs, `<StatusLed status="err" pulse />` for sensor faults.
|
||
|
||
Chart.js (or equivalent via CDN) initialises from `/api/history` then increments via WebSocket messages.
|
||
|
||
## Code Style
|
||
|
||
- Comments in French (project convention from specs)
|
||
- All configurations and default values sourced from `parametrage.md` → reflected in `config.h`
|
||
- OTA upload protected with a password
|