Skip to content

drivers: sensor: mb7040: add support for MaxBotix MB7040 ultrasonic sensor #91688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ww3ak
Copy link

@ww3ak ww3ak commented Jun 16, 2025

Adds a new Zephyr sensor driver for the MaxBotix MB7040 ultrasonic rangefinder.

The driver uses I2C communication to read range data from the sensor and exposes it via the Zephyr sensor API.

Functionality was tested on an esp32-s3.

Copy link

Hello @ww3ak, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@jilaypandya
Copy link
Member

Hey @ww3ak, Thanks for creating this PR, If i am not completely mistaken, i think a couple of files are missing here. Taking reference from a recent sensor driver contribution #89908, you would need to add bindings, also add the sensor to i2c.dtsi.

@jilaypandya jilaypandya requested a review from Copilot June 16, 2025 20:04
Copy link

@Copilot 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

Adds support for the MaxBotix MB7040 ultrasonic sensor via I2C and optional status GPIO, exposing distance measurements through the Zephyr sensor API.

  • Implements sample fetch, channel get, and initialization routines with semaphore and GPIO callback
  • Provides Kconfig options for driver enablement and measurement timing
  • Registers the driver in CMakeLists for build integration

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
drivers/sensor/mb7040/mb7040.c New sensor driver with I2C read/write, status GPIO interrupt, and Zephyr sensor API hooks
drivers/sensor/mb7040/Kconfig Configuration entries for enabling the driver, delay timing, and status GPIO support
drivers/sensor/mb7040/CMakeLists.txt Build file including the new driver source in the Zephyr library
Comments suppressed due to low confidence (2)

drivers/sensor/mb7040/Kconfig:19

  • Update help text to reflect that MB7040_DELAY_MS is applied unconditionally (used even when status GPIO is enabled).
Default delay if status-gpio is not defined

drivers/sensor/mb7040/mb7040.c:1

  • [nitpick] Consider adding unit or integration tests for the new driver to verify I2C read/write behavior and status GPIO handling.
/*

@ww3ak ww3ak force-pushed the add_mb7040_sensor branch from 36aa2d2 to c75d378 Compare June 17, 2025 07:37
@ww3ak
Copy link
Author

ww3ak commented Jun 17, 2025

I believe I fixed/added necessary things!

Copy link
Member

@jilaypandya jilaypandya left a comment

Choose a reason for hiding this comment

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

could you run check_compliance.py locally, it will help you solve some of the compliance issues.
https://docs.zephyrproject.org/latest/contribute/style/code.html

@ww3ak ww3ak force-pushed the add_mb7040_sensor branch from c75d378 to 9d1ad96 Compare June 17, 2025 08:49
@ww3ak ww3ak force-pushed the add_mb7040_sensor branch 3 times, most recently from 2b86f88 to 486a540 Compare June 17, 2025 09:16
@pdgendt pdgendt dismissed their stale review June 17, 2025 09:21

comment addressed

@ww3ak ww3ak force-pushed the add_mb7040_sensor branch 11 times, most recently from 13383bd to 10dea60 Compare July 4, 2025 10:30
@ww3ak ww3ak requested review from jilaypandya and kartben July 7, 2025 07:04
@ww3ak ww3ak force-pushed the add_mb7040_sensor branch 7 times, most recently from 7ddebba to 527215e Compare July 7, 2025 18:07
This commit adds a new driver for the MaxBotix MB7040 ultrasonic
rangefinder. The driver uses I2C communication to read range data
from the sensor and exposes it via the Zephyr sensor API.

Tested on an esp32-s3 board using I2C bus. Verified readings at multiple
distances to confirm accuracy.

Signed-off-by: Sabrina Simkhovich <sabrinasimkhovich@gmail.com>
@ww3ak ww3ak force-pushed the add_mb7040_sensor branch from 527215e to b95aa48 Compare July 7, 2025 18:07
Copy link

sonarqubecloud bot commented Jul 7, 2025

Please retry analysis of this Pull-Request directly on SonarQube Cloud

@ww3ak ww3ak requested a review from jilaypandya July 8, 2025 07:33
@ww3ak
Copy link
Author

ww3ak commented Jul 8, 2025

@jilaypandya thanks for the approval! What do I have to wait for now for this to be merged?

@ww3ak ww3ak requested a review from ubieda July 8, 2025 07:43
@jilaypandya
Copy link
Member

jilaypandya commented Jul 8, 2025

You need an approval from the assignee of the PR :). Other requested changes need to be addressed if any, after that the PR is merge ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Display area: DMA Direct Memory Access area: Input Input Subsystem and Drivers area: Samples Samples area: Sensors Sensors area: Shields Shields (add-on boards) platform: NXP Drivers NXP Semiconductors, drivers platform: NXP NXP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants