Skip to content

sensor: rm3100: Add Read/Decode and Streaming mode #89058

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 4 commits into
base: main
Choose a base branch
from

Conversation

ubieda
Copy link
Member

@ubieda ubieda commented Apr 25, 2025

Description

This PR introduces RM3100 magnetometer sensor, with basic support (read-decode) and Streaming mode (DRDY triggers).
This version includes I2C support only (SPI not included).

Testing

Run shell sample on nRF52840DK with the sensor connected.

  • Build command
west build -b nrf52840dk/nrf52840 samples/subsys/shell/shell_module -- -DCONFIG_I2C=y -DCONFIG_I2C_SHELL=y -DCONFIG_SENSOR=y -DCONFIG_RM3100_STREAM=y
  • Overlay (boards/nrf52840dk_nrf52840.overlay)
#include <zephyr/dt-bindings/sensor/rm3100.h>

&arduino_i2c {
	status = "okay";
	
	rm3100:rm3100@20 {
		compatible = "pni,rm3100";
		reg = <0x20>;
		status = "okay";
		odr = <RM3100_DT_ODR_1_2>;

		/* Arduino pin: D2 */
		int-gpios = <&arduino_header 8 GPIO_ACTIVE_HIGH>;
	};
};
  • Console Output
uart:~$ sensor get rm3100@20 
channel type=8(magn_x) index=0 shift=11 num_samples=1 value=559878875494ns (0.003333)
channel type=9(magn_y) index=0 shift=11 num_samples=1 value=559878875494ns (-0.105599)
channel type=10(magn_z) index=0 shift=11 num_samples=1 value=559878875494ns (0.353066)
channel type=11(magn_xyz) index=0 shift=11 num_samples=1 value=559878875494ns, (0.003333, -0.105599, 0.353066)
uart:~$ sensor get rm3100@20
channel type=8(magn_x) index=0 shift=11 num_samples=1 value=561543090582ns (0.003199)
channel type=9(magn_y) index=0 shift=11 num_samples=1 value=561543090582ns (-0.105866)
channel type=10(magn_z) index=0 shift=11 num_samples=1 value=561543090582ns (0.354132)
channel type=11(magn_xyz) index=0 shift=11 num_samples=1 value=561543090582ns, (0.003199, -0.105866, 0.354132)

uart:~$ sensor stream rm3100@20 on data_ready incl
Enabling stream...
channel type=8(magn_x) index=0 shift=11 num_samples=1 value=540267059088ns (0.001866)
channel type=9(magn_y) index=0 shift=11 num_samples=1 value=540267059088ns (-0.106132)
channel type=10(magn_z) index=0 shift=11 num_samples=1 value=540267059088ns (0.355066)
channel type=11(magn_xyz) index=0 shift=11 num_samples=1 value=540267059088ns, (0.001866, -0.106132, 0.355066)
channel type=8(magn_x) index=0 shift=11 num_samples=1 value=540332153082ns (0.001333)
channel type=9(magn_y) index=0 shift=11 num_samples=1 value=540332153082ns (-0.105866)
channel type=10(magn_z) index=0 shift=11 num_samples=1 value=540332153082ns (0.354799)
channel type=11(magn_xyz) index=0 shift=11 num_samples=1 value=540332153082ns, (0.001333, -0.105866, 0.354799)
channel type=8(magn_x) index=0 shift=11 num_samples=1 value=541182708502ns (0.001866)
channel type=9(magn_y) index=0 shift=11 num_samples=1 value=541182708502ns (-0.105732)
channel type=10(magn_z) index=0 shift=11 num_samples=1 value=541182708502ns (0.353599)
channel type=11(magn_xyz) index=0 shift=11 num_samples=1 value=541182708502ns, (0.001866, -0.105732, 0.353599)
channel type=8(magn_x) index=0 shift=11 num_samples=1 value=542033294440ns (0.002132)
channel type=9(magn_y) index=0 shift=11 num_samples=1 value=542033294440ns (-0.105465)
channel type=10(magn_z) index=0 shift=11 num_samples=1 value=542033294440ns (0.353332)
channel type=11(magn_xyz) index=0 shift=11 num_samples=1 value=542033294440ns, (0.002132, -0.105465, 0.353332)
uart:~$ sensor stream rm3100@20 off

@ubieda ubieda force-pushed the rm3100-add-basic-driver branch 3 times, most recently from 4781a94 to 2ec4bf1 Compare April 25, 2025 00:44
@bperseghetti bperseghetti self-assigned this Apr 28, 2025
ubieda added 3 commits April 29, 2025 10:16
This patch introduces rm3100 magnetometer sensor, with basic
support (only read-decode).

This driver has bus support for I2C.

Signed-off-by: Luis Ubieda <[email protected]>
Using pre-defined values displayed on datasheet's table 5-4 for
CMM Update Rates.

Please note that datasheet specifies these Update-Rates may have
up to 7% standard deviation, which may be significant for certain
applications.

Signed-off-by: Luis Ubieda <[email protected]>
Compatible trigger: DRDY.

Tested with Sensor Shell commands.

Signed-off-by: Luis Ubieda <[email protected]>
@ubieda ubieda force-pushed the rm3100-add-basic-driver branch from 2ec4bf1 to 5b05024 Compare April 29, 2025 14:24
@ubieda ubieda changed the title sensor: rm3100: Basic functionality sensor: rm3100: Add Read/Decode and Streaming mode Apr 29, 2025
For build-time validation.

Signed-off-by: Luis Ubieda <[email protected]>
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.

3 participants