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.
- Model: SW-520D
- Max Current : 20mA
- Max voltage : 12V
- Conductive time : 2ms
- Closed resistance :< 10M ohm
- Open resistance : > 10M ohm
- Total Size: 23 x 5.2mm/0.9" x 0.2"(L*D)
- Lead Size: 10 x 0.6mm/0.4" x 0.024"(L*D)
- Material: Metal, PVC
- SW-520D is roll ball type tilt switch
Tilt Sensor & MQTT:http://osoyoo.com/2017/05/16/nodemcu-lesson-13-tilt-sensor-mqtt/