Template: Tilt Sensor STM32 Guide

From Waveshare Wiki
Jump to: navigation, search

The STM32 examples are based on the STM32F103RBT6 and the STM32H743. The connection provided below is based on the STM32F103RB. If you need to use other STM32 boards, you may need to change the hardware connection and port the code yourself.

STM32

Hardware Connection

Sensor STM32 Description
VCC 3.3V Power input
GND GND Power ground
DOUT PA4 Digital output
Tilt-STM32-2.jpg

Examples

The demo is developed based on the HAL library. Please download the program inside the material, find the STM32 program file directory, open the Tilt-Sensor-code\STM32\STM32F103RB\MDK-ARM directory of Tilt Sensor.uvprojx, and you can see the program.
Tilt sensor stm32.jpg
Open main.c and recompile to download.
Tilt sensor stm3202.jpg

  • After downloading, run SSCOM to connect the Tilt module, and you can see the sensor status.
Tilt STM32 3.png

When shake or tilt the module, the signal indicator on the module is on. When placing the module, the signal indicator on the module is off.