MCUXpresso SDK Documentation

magnetic_switch

magnetic_switch#

Overview#

The magnetic_switch example demonstrates communication with the on-board I2C magnetic switch NMH1000. The value of magnetic field strength is read from the magnetic switch and print to terminal.

Please refer to NMH1000 Magnetic Switch Sensor Datasheet for more information. https://www.nxp.com/docs/en/data-sheet/NMH1000.pdf

Running the demo#

When the example runs successfully, you can see the similar information from the terminal as below. To get different magnetic field strength values, place magnet near the NMH1000 sensor.

I2C magnetic switch NMH1000
Relative magnetic field strength: 1 G
Relative magnetic field strength: 0 G
Relative magnetic field strength: 0 G
Relative magnetic field strength: 1 G
Relative magnetic field strength: 1 G
Relative magnetic field strength: 34 G
Relative magnetic field strength: 53 G
Relative magnetic field strength: 47 G
Relative magnetic field strength: 8 G
Relative magnetic field strength: 5 G
Relative magnetic field strength: 39 G
...

Supported Boards#

FRDM-MCXE247
Hardware requirements
  • USB-C cable

  • FRDM-MCXE247 board

  • Personal Computer

Board settings

No special is needed.

Prepare the Demo
  1. Connect a USB cable between the host PC and the MCU-LINK USB port on the target board.

  2. Open a serial terminal with the following settings:

  • 115200 baud rate

  • 8 data bits

  • No parity

  • One stop bit

  • No flow control

  1. Download the program to the target board.

  2. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

FRDM-MCXE31B
Hardware requirements
  • USB-C cable

  • FRDM-MCXE31B board

  • Personal Computer

Board settings

No special is needed.

Prepare the Demo
  1. Connect a USB cable between the host PC and the MCU-LINK USB port on the target board.

  2. Open a serial terminal with the following settings:

  • 115200 baud rate

  • 8 data bits

  • No parity

  • One stop bit

  • No flow control

  1. Download the program to the target board.

  2. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

FRDM-MCXE32B
Hardware requirements
  • USB-C cable

  • FRDM-MCXE32B board

  • Personal Computer

Board settings

No special is needed.

Prepare the Demo
  1. Connect a USB cable between the host PC and the MCU-LINK USB port on the target board.

  2. Open a serial terminal with the following settings:

  • 115200 baud rate

  • 8 data bits

  • No parity

  • One stop bit

  • No flow control

  1. Download the program to the target board.

  2. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

FRDM-MCXL255
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXL255 board

  • Personal Computer

Board settings
Prepare the Demo

Note: MCUXpresso IDE project default debug console is semihost

  1. Connect a Type-C USB cable between the host PC and the MCU-Link port(J16) on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.