Skip to content

Conversation

@markodraca
Copy link

Description
Adds documentation for the new diff_mode parameter to the MCP3204/MCP3208 sensor component in ESPHome.

Documents how to enable differential measurement mode.

Updates YAML examples to clarify differential channel pairings.

Related issue (if applicable):
None.

Pull request in esphome with YAML changes (if applicable):

esphome/esphome#7436

Checklist
I am merging into next because this is new documentation that has a matching pull request in esphome as linked above.

Added explanation and example for diff_mode parameter
Copy link

@esphome esphome bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is a feature matched with a PR in https://github.com/esphome/esphome, please target your PR to the next branch and rebase.

@esphome esphome bot marked this pull request as draft October 21, 2025 20:54
@esphome
Copy link

esphome bot commented Oct 21, 2025

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@netlify
Copy link

netlify bot commented Oct 21, 2025

Deploy Preview for esphome ready!

Name Link
🔨 Latest commit 953cb1e
🔍 Latest deploy log https://app.netlify.com/projects/esphome/deploys/68f7f2d8042d8000086f4ed7
😎 Deploy Preview https://deploy-preview-5510--esphome.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 21, 2025

Walkthrough

Documentation for the MCP3204/MCP3208 analog-to-digital converter sensor component was restructured and enhanced. Changes include improved image handling with a figure directive, expanded configuration variable documentation with explicit keys and defaults, clarified voltage calculation details, and comprehensive multi-sensor YAML examples demonstrating single-ended and differential measurement modes.

Changes

Cohort / File(s) Summary
MCP3204 Documentation Update
content/components/sensor/mcp3204.md
Restructured layout with consolidated header; replaced inline image placeholder with figure directive; enhanced component description with explicit ESPHome support; updated external datasheet and SPI Bus references to hyperlinks; added voltage calculation details; replaced basic YAML with multi-sensor examples showing single-ended and differential modes; expanded configuration variables section with explicit keys (mcp3204_id, number, diff_mode, update_interval) and defaults; added note on differential mode behavior and channel pairing

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

has-parent, next

Suggested reviewers

  • jesserockz

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title "Update mcp3204.md" is vague and generic, using non-descriptive language that doesn't convey meaningful information about the changeset. While it is technically related to the file being updated, it fails to highlight the primary purpose of the changes. According to the raw summary and PR description, the main focus is adding documentation for the new diff_mode parameter and updating the MCP3204/MCP3208 sensor component documentation—details that are completely absent from the title. This lack of specificity makes it unclear to someone reviewing the commit history what the substantive change contains. Consider revising the title to be more specific about the primary change, such as "Add diff_mode documentation to MCP3204/MCP3208 sensor component" or "Document differential measurement mode for MCP3204 sensors." This would help teammates scanning the commit history understand the substantive contribution at a glance.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed The description clearly articulates the purpose of the changes: adding documentation for the new diff_mode parameter, documenting how to enable differential measurement mode, and updating YAML examples to clarify differential channel pairings. This directly aligns with the actual changes in the changeset, which includes adding explicit keys for mcp3204_id, number, diff_mode, and update_interval, introducing differential mode behavior notes, and replacing basic YAML examples with multi-sensor examples showing both single-ended and differential modes.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
content/components/sensor/mcp3204.md (1)

27-27: Minor: Simplify "off of" to "from".

The phrase "off of" is unnecessarily wordy. Consider replacing it with "from" for clarity.

Apply this diff:

-Each pin will respond with a voltage calculated off of the :code:`reference_voltage` (default is 3.3V).
+Each pin will respond with a voltage calculated from the :code:`reference_voltage` (default is 3.3V).
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6211537 and 953cb1e.

📒 Files selected for processing (1)
  • content/components/sensor/mcp3204.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

  • Do not generate or add any sequence diagrams

Files:

  • content/components/sensor/mcp3204.md
🪛 GitHub Actions: Lint
content/components/sensor/mcp3204.md

[error] 1-1: Markdown lint failed: MD041 - First line in a file should be a top-level heading. Context: '.. seo::'

🪛 GitHub Check: build
content/components/sensor/mcp3204.md

[failure] 53-53:
Code block style [Expected: fenced; Actual: indented]


[failure] 34-34:
Code block style [Expected: fenced; Actual: indented]


[failure] 1-1:
First line in a file should be a top-level heading [Context: ".. seo::"]

🪛 LanguageTool
content/components/sensor/mcp3204.md

[style] ~27-~27: ‘off of’ might be wordy. Consider a shorter alternative.
Context: ... will respond with a voltage calculated off of the :code:reference_voltage (default ...

(EN_WORDINESS_PREMIUM_OFF_OF)

🔇 Additional comments (1)
content/components/sensor/mcp3204.md (1)

8-85: Documentation improvements are well-structured and technically accurate.

The PR successfully documents the new diff_mode parameter with clear examples and proper explanations. Key strengths:

  • Multi-sensor YAML examples effectively demonstrate both single-ended and differential measurement modes
  • Configuration variables section clearly documents mcp3204_id, number, diff_mode, and update_interval with proper defaults
  • Voltage calculation formula is explicit and helpful
  • Note section properly explains differential vs. single-ended behavior with datasheet reference
  • Figure directive with proper metadata improves visual presentation

Once the formatting issues above are resolved, this documentation will be clear and complete.

Comment on lines +1 to +6
.. seo::
description: Instructions for setting up MCP3204 & MCP3208 12-Bit Analog to Digital Converter in ESPHome.
image: mcp3204.jpg
---

The Microchip Technology Inc. MCP3204 & MCP3208 devices are successive approximation 12-bit Analog-to-Digital (A/D)
converters with on-board sample and hold circuitry. This component is common for both device types.
Configure both devices as MCP3204 and observe the maximum number of channels as per variant used.
MCP3204 & MCP3208 12-Bit A/D Converters
=======================================
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix markdown lint error MD041: First line should be a top-level heading.

The pipeline is failing because the file begins with a reStructuredText directive (.. seo::) rather than a top-level heading. The markdown linter expects a heading as the first element.

Move the SEO block below the title or restructure the file to start with the top-level heading:

-.. seo::
-
-    description: Instructions for setting up MCP3204 & MCP3208 12-Bit Analog to Digital Converter in ESPHome.
-    image: mcp3204.jpg
-
 MCP3204 & MCP3208 12-Bit A/D Converters
 =======================================
+
+.. seo::
+
+    description: Instructions for setting up MCP3204 & MCP3208 12-Bit Analog to Digital Converter in ESPHome.
+    image: mcp3204.jpg
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.. seo::
description: Instructions for setting up MCP3204 & MCP3208 12-Bit Analog to Digital Converter in ESPHome.
image: mcp3204.jpg
---
The Microchip Technology Inc. MCP3204 & MCP3208 devices are successive approximation 12-bit Analog-to-Digital (A/D)
converters with on-board sample and hold circuitry. This component is common for both device types.
Configure both devices as MCP3204 and observe the maximum number of channels as per variant used.
MCP3204 & MCP3208 12-Bit A/D Converters
=======================================
MCP3204 & MCP3208 12-Bit A/D Converters
=======================================
.. seo::
description: Instructions for setting up MCP3204 & MCP3208 12-Bit Analog to Digital Converter in ESPHome.
image: mcp3204.jpg
🧰 Tools
🪛 GitHub Actions: Lint

[error] 1-1: Markdown lint failed: MD041 - First line in a file should be a top-level heading. Context: '.. seo::'

🪛 GitHub Check: build

[failure] 1-1:
First line in a file should be a top-level heading [Context: ".. seo::"]

🤖 Prompt for AI Agents
In content/components/sensor/mcp3204.md lines 1-6 the file starts with a
reStructuredText SEO directive which triggers markdown-lint MD041 because the
first line must be a top-level heading; fix by moving the ".. seo::" block below
the main title (keep the "MCP3204 & MCP3208 12-Bit A/D Converters" as the very
first line preceded by a single "#"/underlined level-1 heading per your repo
style), ensure a blank line between the title and the SEO block, and verify the
file now begins with the top-level heading so the linter passes.

Comment on lines +34 to +36
mcp3204:
cs_pin: GPIOXX
reference_voltage: 3.3V
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use fenced code block style instead of indented.

The build tool reports that code block style should be fenced (with triple backticks), not indented.

Apply this diff to use fenced code block syntax:

-.. code-block:: yaml
-
-    mcp3204:
-        cs_pin: GPIOXX
-        reference_voltage: 3.3V
+.. code-block:: yaml
+
+    mcp3204:
+      cs_pin: GPIOXX
+      reference_voltage: 3.3V

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 GitHub Check: build

[failure] 34-34:
Code block style [Expected: fenced; Actual: indented]

🤖 Prompt for AI Agents
In content/components/sensor/mcp3204.md around lines 34 to 36, the YAML example
is written as an indented code block; replace it with a fenced code block using
triple backticks (```yaml) before the block and closing triple backticks after
it so the build tool recognizes the fenced style, preserving the exact content
and indentation inside the fenced block.

Comment on lines +51 to +68
.. code-block:: yaml

sensor:
- platform: mcp3204 # Single-ended mode: pin 0 of MCP3204
id: solar_voltage
number: 0

# Pin 7 of MCP3208 in single-ended mode (for MCP3208, use pin numbers 0-7)
- platform: mcp3204
id: supply_voltage
number: 7

# Differential mode: Measures voltage between channel 0 (IN+) and channel 1 (IN–)
- platform: mcp3204
id: differential_sensor
number: 0 # Channel 0 (IN+), paired with 1 (IN–) in differential mode
diff_mode: true # Enable differential mode
name: "Differential Voltage CH0–CH1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use fenced code block style instead of indented.

The build tool reports that code block style should be fenced (with triple backticks), not indented for the sensor examples block.

The indented code block structure appears correct for reStructuredText, but verify with the build configuration whether fenced blocks are required for consistency with the documentation style guide.

🧰 Tools
🪛 GitHub Check: build

[failure] 53-53:
Code block style [Expected: fenced; Actual: indented]

🤖 Prompt for AI Agents
In content/components/sensor/mcp3204.md around lines 51 to 68, the sensor
example uses an indented reStructuredText code-block; update it to use a fenced
code block with triple backticks and the yaml language tag (```yaml) so the
build tool accepts the block; preserve the same inner YAML content and
indentation, replace the leading ".. code-block:: yaml" and its indented content
with a fenced block opening and closing lines, and ensure there is a blank line
after the opening fence if required by the renderer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant