1.. zephyr:code-sample:: magn_polling 2 :name: Magnetometer Sensor 3 :relevant-api: sensor_interface 4 5 Get magnetometer data from a magnetometer sensor (polling mode). 6 7Overview 8******** 9 10Sample application that periodically reads magnetometer (X, Y, Z) data from 11the first available device that implements SENSOR_CHAN_MAGN_* (predefined array 12of device names). 13 14Board-specific overlays 15*********************** 16 17TMAG5170 via Raspberry Pi Pico 18============================== 19 20The Zephyr driver for the :dtcompatible:`ti,tmag5170`` requires an SPI driver 21that supports 32-bit SPI_WORD_SIZE. On the :zephyr:board:`rpi_pico`, the 22:dtcompatible:`raspberrypi,pico-spi-pio` SPI driver provides this support, 23demonstrated with the 24:zephyr_file:`samples/sensor/magn_polling/boards/rpi_pico.overlay`. 25 26The GPIO pin assignments in the overlay file are arbitrary. The PIO SPI 27driver allows using any four GPIO pins for the SPI bus. Just keep in mind 28that the pin assignments in the pinctrl block and the pio0_spi0 block 29must match. 30 31With the sensor wired to the desired pins, build and flash with: 32 33.. zephyr-app-commands:: 34 :zephyr-app: samples/sensor/magn_polling 35 :goals: build flash 36 :board: rpi_pico 37