This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Sphinx documentation repository for the Mk2PVRouter project - a DIY solar PV router for optimizing self-consumption of solar energy. The documentation is written entirely in French and covers assembly, installation, calibration, and troubleshooting of the universal 3phaseDiverter board, which supports 4 configurations: single-phase (monophasé), 3-phase with neutral, 3-phase without neutral, and split-phase.
The actual firmware code and hardware designs are maintained in separate repositories linked as git submodules:
1-phase/: https://github.com/FredM67/PVRouter-1-phase3-phase/: https://github.com/FredM67/PVRouter-3-phasehardware/: https://github.com/FredM67/PVRouter-KiCad
Both firmware repositories contain:
- Main firmware: Arduino sketches (.ino files) targeting ATmega328P microcontroller
- PlatformIO support:
platformio.inifiles for modern build system - Development tools: Calibration programs, test utilities in
dev/subfolder - Doxygen documentation: Generated API documentation (see GitHub Pages)
1-phase firmware variants:
Mk2_fasterControl_Full/- Main firmware with all features (display, temperature sensor, telemetry)Mk2_fasterControl_twoLoads_temp_1/- Two-load variantMk2_fasterControl_threeLoads_temp_1/- Three-load variantRobin/- Original Robin Emley implementation
3-phase firmware:
Mk2_3phase_RFdatalog_temp/- Main three-phase firmware with RF logging and temperature supportdev/cal_CTx_v_meter/- CT sensor calibration tool (critical for accurate power measurement)
# Build HTML documentation (default)
make html
# Build PDF documentation
make simplepdf
# View all available Sphinx build targets
make help
# Clean build artifacts
make clean
# Manually export DrawIO diagrams to PDF (if needed)
./build_pdf_from_drawio.shBuilt documentation is output to _build/html/ (HTML) or _build/simplepdf/ (PDF).
Note: DrawIO diagrams in content/drawio/*.drawio are automatically converted during the Sphinx build process via the sphinxcontrib.drawio extension. The build_pdf_from_drawio.sh script is for manual export only.
# Open the main index page (macOS)
open _build/html/index.html
# Linux
xdg-open _build/html/index.html# Install Python dependencies for building documentation
pip install -r requirements.txtKey dependencies: Sphinx 8.2.3+, sphinx_rtd_theme, sphinxcontrib-drawio (for diagram support), sphinx-copybutton, sphinx-simplepdf.
The repository includes .vscode/tasks.json with pre-configured tasks:
- build: Run
make html - build PDF: Run
make simplepdf - open page: Open built HTML index
# Check for build warnings and errors
make html 2>&1 | grep -E "(WARNING|ERROR|CRITICAL)"
# Check for title level inconsistencies specifically
make html 2>&1 | grep -i "title level inconsistent"
# Count total warnings
make html 2>&1 | grep WARNING | wc -lThe goal is to keep warnings to a minimum (currently ~5 warnings is baseline).
Documentation source files are in content/ with this structure:
content/
├── conf.py # Sphinx configuration
├── index.rst # Main documentation entry point
├── introduction.rst # General introduction
├── principe-fonctionnement.rst
├── burst-fire-control.rst
├── safety-overview.rst # Unified safety chapter (CRITICAL - must be read first)
├── installation-logiciel.rst # Software installation guide
├── installation-finale.rst # Final electrical installation (high voltage)
├── troubleshooting.rst # Comprehensive troubleshooting guide
├── etalonnage.rst # Unified calibration (mono + tri)
├── glossary.rst # Technical terms glossary
├── soldering-tutorial.rst # Beginner soldering guide
├── carte-mere/ # Universal motherboard (3phaseDiverter)
│ ├── presentation.rst # Board overview, renders, connectors, pinout
│ ├── choix-configuration.rst # Decision guide for 4 configurations
│ ├── assemblage-carte-mere.rst # Through-hole assembly
│ ├── tests-electriques.rst # Electrical tests
│ └── cavaliers.rst # Solder jumper configuration
├── firmware/ # Firmware choice, upload, test
│ ├── test-logiciel.rst # Unified software test + firmware choice
│ ├── firmware-monophase.inc.rst # 1-phase firmware specifics
│ └── firmware-triphase.inc.rst # 3-phase firmware specifics
├── etage-sortie/ # Output stage boards
│ ├── carte-sortie.rst # Triac output board assembly
│ └── carte-sortie-relais.rst # Relay board
├── mk2wifi/ # ESP32-C3 expansion module
│ ├── presentation-mk2wifi.rst # Module overview
│ └── installation-mk2wifi.rst # Install + firmware flash
├── boitier/ # Case & cabling
│ ├── percages.rst # Drilling (case + heatsink)
│ ├── confection-cables.rst # Cable fabrication
│ └── assemblage.rst # Final case assembly
├── common/ # Shared include snippets
│ ├── connexion-ftdi.inc.rst
│ ├── installation-arduino-ide.inc.rst
│ ├── installation-platformio.inc.rst
│ ├── compilation-televerement.inc.rst
│ ├── moniteur-serie.inc.rst
│ ├── resolution-problemes-upload.inc.rst
│ ├── qualite-soudures.inc.rst
│ ├── burden-calc.inc.rst
│ ├── test-logiciel-requirements.inc.rst
│ ├── configuration-arduino-ide.inc.rst
│ └── outils.inc.rst
├── img/ # Images (build-copied renders + static images)
└── drawio/ # DrawIO diagram sources
Shared procedures are extracted into include files (.inc.rst) in content/common/:
connexion-ftdi.inc.rst- FTDI connection for programminginstallation-arduino-ide.inc.rst- Arduino IDE setupinstallation-platformio.inc.rst- PlatformIO alternativecompilation-televerement.inc.rst- Firmware compilation and uploadmoniteur-serie.inc.rst- Serial monitor usageresolution-problemes-upload.inc.rst- Upload troubleshootingqualite-soudures.inc.rst- Solder quality guidelinesburden-calc.inc.rst- Burden resistor calculationstest-logiciel-requirements.inc.rst- Test prerequisites
These are included in standalone files using:
.. include:: ../common/filename.inc.rstFirmware-specific includes live in content/firmware/:
firmware-monophase.inc.rst- 1-phase firmware specificsfirmware-triphase.inc.rst- 3-phase firmware specifics
The documentation follows a progressive assembly workflow:
- Safety chapter (
safety-overview.rst) - MUST be read first - Introduction - Overview, tools, time estimates, skill levels
- Theory - How the router works (principle, burst-fire control)
- Software setup - Arduino IDE or PlatformIO installation
- Assembly - Step-by-step soldering (motherboard → output boards)
- Drilling - Case and heatsink preparation
- Assembly - Mounting components in case
- Calibration - CT sensor calibration
- Final installation - Connection to mains electrical system
- Troubleshooting - Diagnosis and problem resolution
Each major assembly section includes:
- Time estimates (beginner vs. experienced)
- Skill level indicators (difficulty rating)
- Prerequisites boxes (checklist before starting)
- Verification checkpoints (checklist after each major step)
- Safety warnings (using RST
.. danger::directive)
The project uses a consistent RST heading hierarchy (see RST_SECTION_LEVELS.md):
Document Title (Level 1)
=========================
Major Section (Level 2)
-----------------------
Subsection (Level 3)
~~~~~~~~~~~~~~~~~~~~
Sub-subsection (Level 4)
^^^^^^^^^^^^^^^^^^^^^^^^
Paragraph (Level 5)
"""""""""""""""""""
Sub-paragraph (Level 6)
'''''''''''''''''''''''IMPORTANT: Always maintain this hierarchy. Sphinx will error on "Title level inconsistent" if you skip levels or use inconsistent characters.
Technical terms are defined in content/glossary.rst and should be linked using:
:term:`PCB`
:term:`CT`
:term:`triac`Cross-references between sections use:
:ref:`safety-overview`
:ref:`etalonnage`
:ref:`choix-configuration`The documentation is written in French with proper French typography:
-
Non-breaking spaces (U+00A0
) before:- Punctuation:
!,?,;,: - Units:
3 kW,230 V,50 Hz - Guillemets:
« texte »
- Punctuation:
-
Typographic apostrophes (U+2019
') not straight quotes (') -
French quotation marks:
« guillemets »not"quotes" -
Decimal comma:
3,5 heuresnot3.5 heures -
Inclusive writing (when appropriate):
Pont·s redresseur·s
To insert non-breaking space in vim: Ctrl+V u00a0 or Ctrl+V xa0
Key configuration in content/conf.py:
-
Language:
language = 'fr' -
Theme:
sphinx_rtd_theme(Read the Docs theme) -
Extensions:
sphinxcontrib.drawio- Diagram support (requires DrawIO installation)sphinx_copybutton- Copy button on code blockssphinx_simplepdf- PDF generationsphinx_last_updated_by_git- Show last update time from gitsphinx.ext.autosectionlabel- Auto-generate section labels for cross-refssphinx.ext.graphviz- Graphviz diagram supportsphinx.ext.imgmath- Math rendering as images (SVG format)
-
Auto-section labeling:
autosectionlabel_prefix_document = True # Prefix labels with document name autosectionlabel_maxdepth = 2 # Only top 2 levels get auto-labels
This prevents duplicate label warnings in large documentation.
-
Create the file in the appropriate subdirectory (
content/carte-mere/,content/firmware/,content/etage-sortie/,content/boitier/,content/mk2wifi/, orcontent/common/for shared includes) -
Add frontmatter with metadata:
⏱️ **Temps estimé** : X-Y heures (débutant), A-B heures (expérimenté) 🔧 **Niveau de difficulté** : Débutant / Intermédiaire / Avancé ⚠️ **Niveau de risque** : Faible / Moyen / Élevé / Très élevé
-
Add prerequisites box:
.. admonition:: 📋 Prérequis Avant de commencer ce chapitre : ☐ Chapitre :ref:`safety-overview` lu et compris ☐ Outils nécessaires à disposition ☐ Temps disponible (X heures) ☐ Espace de travail propre et organisé
-
Add verification checkpoints after major steps:
.. admonition:: ✅ Point de Contrôle — [Component Type] Avant de continuer, vérifiez : ☐ Item 1 ☐ Item 2 ☐ Item 3
-
Link technical terms to glossary using
:term:term`` -
Add cross-references to related sections using
:ref:label`` -
Update
index.rstto include the new section in the table of contents
If you need to modify shared content:
- Check if it's an include file: Look for
.. include::directives in the parent files - Edit the include file in
content/common/*.inc.rstorcontent/firmware/*.inc.rst - Test the build: Ensure changes work correctly in all contexts where the include is used
- Verify section levels: Include files should start at the appropriate heading level for their inclusion context
Use appropriate RST directives based on severity:
.. danger::- Physical safety hazards (electrical shock, fire, burns).. warning::- Software/configuration issues, potential mistakes.. important::- Critical information that's not a safety hazard.. note::- General information, clarifications, tips.. tip::- Helpful suggestions, best practices.. hint::- Reminders, procedural guidance
Reserve .. danger:: for actual physical safety hazards only to avoid "warning fatigue" where users start ignoring danger alerts.
After making changes:
-
Build and check for errors:
make html
-
Review warnings: Aim to keep warnings minimal. Common acceptable warnings:
- Glossary terms not yet linked (will be fixed incrementally)
- External links that are correct but Sphinx can't verify
-
Check French typography: Use proper non-breaking spaces and typographic apostrophes
-
Verify cross-references: Ensure all
:ref:and:term:links resolve correctly -
Test visual appearance: Open
_build/html/index.htmland spot-check pages
The 1-phase/, 3-phase/, and hardware/ directories are git submodules pointing to external repositories. They are not actively developed in this repository. If you need to work on the firmware or hardware design, clone the respective repository directly.
# Initialize and update submodules (first time or after clone)
git submodule update --init --recursive
# Update submodules to latest commit from their remote repositories
git submodule update --remote
# Check current submodule status
git submodule statusIf you need to modify firmware code:
-
For documentation purposes only: The submodules are read-only references. Do NOT modify them in this repository.
-
For firmware/hardware development: Clone the respective repository directly:
# Single-phase firmware git clone https://github.com/FredM67/PVRouter-1-phase.git # Three-phase firmware git clone https://github.com/FredM67/PVRouter-3-phase.git # Hardware designs (KiCad) git clone https://github.com/FredM67/PVRouter-KiCad.git
-
For documentation cross-references: You can reference firmware files in documentation using relative paths like
../../1-phase/Mk2_fasterControl_Full/but avoid duplicating firmware documentation in this repository.
The submodules are primarily included for:
- Easy access to firmware version information
- Reference to PCB designs and schematics (KiCad)
- Generating cross-references in documentation
- Ensuring documentation matches firmware and hardware capabilities
The documentation has two deployment targets:
Workflow: .github/workflows/documentation.yaml
Triggers on:
- Push to any branch (except changes to submodules)
- Pull requests
- Manual workflow dispatch
Build process:
- Installs DrawIO (with caching) for diagram rendering
- Installs Graphviz for graph diagrams
- Installs Python dependencies from
requirements.txt - Builds HTML documentation with Sphinx
- Deploys to GitHub Pages (on main and legacy branches)
Note: Changes to submodules (1-phase/, 3-phase/, hardware/) do NOT trigger documentation builds since they're maintained separately.
Configuration: .readthedocs.yaml
The documentation is also built and deployed to ReadTheDocs on push to the main branch. ReadTheDocs uses custom build commands to install DrawIO for diagram rendering.
Both deployments ensure diagrams (.drawio files) are properly rendered to PNG/SVG format.
The documentation has undergone significant improvements:
- Universal board restructure: Replaced separate mono/tri documentation with unified structure for the 3phaseDiverter universal board. Old mono/tri docs preserved on the
legacybranch. - New sections:
carte-mere/,mk2wifi/,firmware/,etage-sortie/,boitier/directories with standalone content files. - Build-time asset pipeline: Hardware renders copied from
hardware/submodule at build time viamake copy-assets. - Version selector:
legacybranch deployed alongsidemainfor users with older mono/tri-specific boards. - Build quality improved from 73 warnings → 5 warnings (93% reduction)
- Added 16 verification checkpoints across assembly guides
- Created comprehensive safety chapter (684 lines)
- Added detailed troubleshooting guide (1,159 lines)
The target audience is non-specialist users with minimal electrical/electronics knowledge. All content should:
- Explain technical terms before using them
- Provide clear, detailed procedures (not vague instructions like "use adhesive")
- Include safety context and prevention measures
- Have photos or diagrams for complex steps
- Anticipate common mistakes and provide guidance
- Use verification checkpoints to prevent errors from propagating
This project involves:
- High voltage electrical work (230V AC, life-threatening)
- Fire hazards (high-power soldering, incorrect wiring)
- Legal requirements (French NF C 15-100 standard, Consuel certification, insurance implications)
Always maintain and enhance safety warnings. The installation-finale.rst chapter is particularly critical as it covers mains electrical connection.
- GitHub Issues: Report documentation issues at https://github.com/FredM67/Mk2PVRouter/issues
- DOCUMENTATION_REVIEW.md: Comprehensive documentation quality assessment and improvement roadmap
- RST_SECTION_LEVELS.md: Reference for RST heading hierarchy
- CONTRIBUTING.md: General contribution guidelines