Example Code for Raspberry Pi-threshold interrupt function
Last revision 2026/01/21
Set up the threshold interrupt function for the BMM150 sensor on Raspberry Pi.
Hardware Preparation
- Raspberry Pi 4 Model B-2GB (or similar) x 1
- BMM150 Triple Axis Magnetometer Sensor x1
- Dupont Wires
Software Preparation
- BMM150 Sensor Python Library
- RASPBIAN Official OS
Wiring Diagram
Connect the module with Raspberry Pi as shown below. Default address: 0x13.

Other Preparation Work
- Enable Raspberry Pi I2C (follow steps in previous example).
- Install dependencies (follow steps in previous example).
- Download the library (follow steps in previous example).
- Navigate to the sample code directory:
cd DFRobot_BMM150/python/raspberrypi/examples/threshold_interrupt
Sample Code
Open the terminal and enter the following commands to run the sample code:
cd DFRobot_BMM150/python/raspberrypi/examples
cd threshold_interrupt
python threshold_interrupt.py
Result

Was this article helpful?
