Skip to content

Conversation

@jablikcz
Copy link

Added note about sensor frequency for improved reliability, and allow it to work.

Description:

I spend a lot of time with searching for why the sensor AM2320 doesn't work with ESPhome, but with arduino code yes. I tried many solutions, like add there setup prio -100, or pull up the SCL right after the boot, but nothing of that work correctly and reliably. After that I found a documentation for AM2320 where is that maximal BUS frequency is 100kHZ, and thats it. Just decrease the frequency from default 200kHz to 50kHz make the magic.
So would be perfect add this info to official FAQ to help others.

Related issue (if applicable): fixes

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

  • esphome/esphome#

Checklist:

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

  • I am merging into current because this is a fix, change and/or adjustment in the current documentation and is not for a new component or feature.

  • Link added in /components/index.rst when creating new documents for new components or cookbook.

New Component Images

If you are adding a new component to ESPHome, you can automatically generate a standardized black and white component name image for the documentation.

To generate a component image:

  1. Comment on this pull request with the following command, replacing COMPONENT_NAME with your component name in UPPER_CASE format with underscores (e.g., BME280, SHT3X, DALLAS_TEMP):

    @esphomebot generate image COMPONENT_NAME
    
  2. The ESPHome bot will respond with a downloadable ZIP file containing the SVG image.

  3. Extract the SVG file and place it in the images/ folder of this repository.

  4. Use the image in your component's index table entry in /components/index.rst.

Example: For a component called "DHT22 Temperature Sensor", use:

@esphomebot generate image DHT22

Added note about sensor frequency for improved reliability, and allow it to work.
Copilot AI review requested due to automatic review settings October 24, 2025 14:05
@esphome esphome bot added the current label Oct 24, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the AM2320 sensor documentation to address reliability issues caused by I2C bus frequency settings. The primary purpose is to help users avoid common configuration problems by documenting that the AM2320 sensor requires a lower I2C bus frequency than ESPHome's default.

Key changes:

  • Added frequency recommendation note explaining the 100kHz limitation and default 200kHz issue
  • Expanded example configuration to show complete I2C bus setup with recommended 50kHz frequency
  • Added explicit i2c_id and address configuration in the sensor example

> [!NOTE]
> Logs might include some warnings about receiving a NACK from the sensor.
> This is due to a wake call to the sensor which the sensor never acknowledges by design.
> Sensor works on BUS frequency up to 100kHz, but by default is 200kHz in use. So decrease will help with sensor reliability.
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

The note should explain why 50kHz is recommended when the sensor supports up to 100kHz. Consider revising to: 'The sensor supports I2C bus frequencies up to 100kHz. ESPHome's default frequency is 200kHz, which may cause reliability issues. Setting the frequency to 50kHz (well below the maximum) ensures stable operation.'

Suggested change
> Sensor works on BUS frequency up to 100kHz, but by default is 200kHz in use. So decrease will help with sensor reliability.
> The sensor supports I2C bus frequencies up to 100kHz. ESPHome's default frequency is 200kHz, which may cause reliability issues. Setting the frequency to 50kHz (well below the maximum) ensures stable operation.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

As far as I know the default is 50kHz? Where do you see a default of 200?

Copy link
Author

Choose a reason for hiding this comment

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

I just see there in the logs from some esp device. Maybe this is the default in some sensor library. Lets change the notes as needed.

def_freq

sda: GPIO4
scl: GPIO5
scan: true
frequency: 50000
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a comment in the YAML example explaining the frequency value, such as frequency: 50000 # 50kHz - recommended for AM2320 reliability

Suggested change
frequency: 50000
frequency: 50000 # 50kHz - recommended for AM2320 reliability

Copilot uses AI. Check for mistakes.
@netlify
Copy link

netlify bot commented Oct 24, 2025

Deploy Preview for esphome ready!

Name Link
🔨 Latest commit bc988e3
🔍 Latest deploy log https://app.netlify.com/projects/esphome/deploys/68fb87972846930008fc251a
😎 Deploy Preview https://deploy-preview-5522--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 24, 2025

Walkthrough

Documentation update for the AM2320 sensor component adding a clarification note about I²C frequency operation limits and expanding the configuration example with I²C bus ID, frequency, and device address settings.

Changes

Cohort / File(s) Summary
AM2320 Sensor Documentation
content/components/sensor/am2320.md
Added blockquote clarifying sensor operates at up to 100kHz but typically 200kHz; enhanced YAML example with top-level i2c entry (bus_a with frequency: 50000 and scan: true), i2c_id, and address settings under sensor configuration

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested reviewers

  • nagyrobi
  • frenck

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Update AM2320 documentation with frequency note" directly and clearly relates to the main changes in the changeset. The raw summary confirms that the primary modification is adding an explanatory note about sensor frequency (specifically that the sensor operates up to 100kHz but is typically 200kHz), along with enhanced YAML configuration examples that include frequency settings at 50000. The title accurately captures this core change without being overly vague or misleading.
Description Check ✅ Passed The pull request description is clearly related to the changeset. It explains the motivation behind the changes: the author encountered reliability issues with the AM2320 sensor in ESPHome, discovered that the maximum I2C bus frequency is 100kHz rather than the default 200kHz, and determined that reducing the frequency to 50kHz resolved the problem. The description connects directly to the documentation changes and YAML configuration examples being added, making it substantively related to the modifications in the changeset.
✨ 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: 0

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

17-20: Improve grammar and clarity of the frequency note.

The note provides important troubleshooting information, but the phrasing on line 20 could be clearer. The current text "So decrease will help with sensor reliability" is grammatically awkward and could be misunderstood.

Apply this diff to improve clarity:

  > [!NOTE]
  > Logs might include some warnings about receiving a NACK from the sensor.
  > This is due to a wake call to the sensor which the sensor never acknowledges by design.
- > Sensor works on BUS frequency up to 100kHz, but by default is 200kHz in use. So decrease will help with sensor reliability.
+ > The AM2320 sensor operates reliably at I²C frequencies up to 100 kHz. ESPHome defaults to 200 kHz, which may cause intermittent communication issues. Reducing the I²C frequency improves reliability.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7dbc603 and bc988e3.

📒 Files selected for processing (1)
  • content/components/sensor/am2320.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/am2320.md
🔇 Additional comments (1)
content/components/sensor/am2320.md (1)

24-39: Configuration example is good, but document the new options.

The enhanced configuration example is clear and correct:

  • The i2c bus definition with frequency: 50000 (50 kHz) is well below the 100 kHz sensor limit, which is appropriately conservative.
  • Explicit i2c_id and address references are helpful for clarity.

However, the Configuration variables section (lines 42–52) does not document the newly added i2c_id and address options. If these are not inherited from parent component documentation, they should be added to the configuration variables list.

Please verify: Are i2c_id and address documented in the general I²C component documentation and Sensor base documentation respectively? If not, add them to the Configuration variables section here.

> [!NOTE]
> Logs might include some warnings about receiving a NACK from the sensor.
> This is due to a wake call to the sensor which the sensor never acknowledges by design.
> Sensor works on BUS frequency up to 100kHz, but by default is 200kHz in use. So decrease will help with sensor reliability.
Copy link
Member

Choose a reason for hiding this comment

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

As far as I know the default is 50kHz? Where do you see a default of 200?

@esphome esphome bot marked this pull request as draft October 27, 2025 02:09
@esphome
Copy link

esphome bot commented Oct 27, 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.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants