7

Description:

This SW-520D basic tilt switch can easily be used to detect orientation. Inside the can is a ball that make contact with the pins when the case is upright. Tilt the case over and the balls don’t touch, thus not making a connection.

There are numerous uses for these basic sensors, but keep in mind you might need to use some debouncing code, as the sensor isn’t immune to small vibrations and such.

QQ截图20170508105614

Example

Example: https://www.arduino.cc/en/Tutorial/TiltSensor

Tilt Sensor & MQTT:https://osoyoo.com/2017/05/16/nodemcu-lesson-13-tilt-sensor-mqtt/