Skip to content

AP_TemperatureSensor: Add support for MCP9808 I2C temperature sensor - #33746

Open
lavleshpoyrekar wants to merge 20 commits into
ArduPilot:masterfrom
lavleshpoyrekar:ap-temp-mcp9808
Open

AP_TemperatureSensor: Add support for MCP9808 I2C temperature sensor#33746
lavleshpoyrekar wants to merge 20 commits into
ArduPilot:masterfrom
lavleshpoyrekar:ap-temp-mcp9808

Conversation

@lavleshpoyrekar

Copy link
Copy Markdown

Summary

Add MCP9808 temperature sensor support to AP_TemperatureSensor.
The driver provides I2C communication, device detection, temperature reading, and integration with ArduPilot temperature sensor framework.

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Testing performed:

  • Built successfully with ArduPilot waf build system.
  • Tested MCP9808 sensor on actual hardware using I2C interface.
  • Verified sensor initialization and temperature readings.
  • Tested with two MCP9808 sensors connected on the I2C bus.
  • Verified sensor detection, device ID reading, and temperature output through MAVLink logs.

Description

This PR adds support for the MCP9808 digital temperature sensor in the AP_TemperatureSensor library.

Changes include:

  • Added MCP9808 backend driver implementation.
  • Added MCP9808 sensor registration and integration with AP_TemperatureSensor.
  • Added I2C communication support for MCP9808.
  • Added sensor initialization, device ID verification, and temperature reading.
  • Added support for MCP9808 configuration through ArduPilot temperature sensor framework.

Log Link
https://drive.google.com/file/d/1lO0TRcomo0k0ZZJ5mHk8dpHhfN6aIto6/view?usp=sharing

The implementation was tested on real hardware with MCP9808 sensors connected over I2C and verified using MAVLink logs.
MCP9808_TEMP_SENSOR_PRINT_USING_LUA

MCP9808_TEMP_SENSOR_LOG

@peterbarker peterbarker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Requires a simulator + addition to autotest

Spaces after commas.

Add trailing newlines to files.

Needs an entry in build_options.py

Pretty solid!

Comment thread libraries/AP_TemperatureSensor/AP_TemperatureSensor_MCP9808.cpp Outdated
Comment thread libraries/AP_TemperatureSensor/AP_TemperatureSensor_MCP9808.cpp Outdated
Comment thread libraries/AP_TemperatureSensor/AP_TemperatureSensor_MCP9808.cpp Outdated
Comment thread libraries/AP_TemperatureSensor/AP_TemperatureSensor_MCP9808.cpp Outdated
Comment thread libraries/AP_TemperatureSensor/AP_TemperatureSensor_MCP9808.cpp Outdated
Comment thread libraries/AP_TemperatureSensor/AP_TemperatureSensor_MCP9808.cpp
Comment thread libraries/AP_TemperatureSensor/AP_TemperatureSensor_MCP9808.cpp Outdated
@Hwurzburg Hwurzburg added the WikiNeeded needs wiki update label Jul 17, 2026

@peterbarker peterbarker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CI must pass

@lavleshpoyrekar

Copy link
Copy Markdown
Author

@peterbarker . I've addressed the requested changes:

  1. Added the simulator and autotest coverage.
  2. Fixed spacing and Formatting.
  3. Added the required build_options.py entry.
    Please review the changes when you get a chance. Thanks!

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.

3 participants