Stufin
Home Quick Cart Profile

Tilt Sensor

Buy Now on Stufin

Measurement range

180 (single-axis), 90 (dual-axis), 45 (triple-axis)

Resolution

0.1 to 1

Accuracy

1 to 5

Sensitivity

0.01 to 1/s

Power consumption

1 mA to 10 mA

Operating temperature

-40C to 125C

Interface

Analog, digital, I2C, SPI, UART

Conclusion

The Tilt Sensor is a versatile and accurate component that measures the tilt angle of an object with respect to the horizontal plane. Its compact design, low power consumption, and high sensitivity make it suitable for a wide range of IoT applications, robotics, and industrial automation. By selecting the appropriate type of Tilt Sensor and configuring it for the specific application, developers can achieve precise and reliable measurements.

Pin Configuration

  • Tilt Sensor Component Documentation
  • Pinout Description
  • The Tilt Sensor component has a total of 3 pins, which are used to connect the sensor to a microcontroller or other electronic circuits. The pins are described below:
  • Pin 1: VCC
  • Function: Power Supply
  • Description: This pin is used to supply power to the Tilt Sensor. Typically, a voltage source between 3.3V to 5V is recommended.
  • Connection: Connect this pin to a power source, such as a battery or a voltage regulator output.
  • Pin 2: SIGNAL (or OUT)
  • Function: Output Signal
  • Description: This pin provides the output signal from the Tilt Sensor, which indicates the tilt angle of the sensor. The signal is typically a digital signal that switches between HIGH (logic 1) and LOW (logic 0) depending on the tilt angle.
  • Connection: Connect this pin to a digital input pin on a microcontroller or a logic-level converter.
  • Pin 3: GND
  • Function: Ground
  • Description: This pin is used to provide a ground connection for the Tilt Sensor.
  • Connection: Connect this pin to a ground point on the circuit, such as the negative terminal of a battery or a ground pin on a microcontroller.
  • Connection Structure
  • To connect the Tilt Sensor to a microcontroller or other electronic circuits, follow the structure below:
  • 1. Power Connection:
  • Connect Pin 1 (VCC) to a power source (e.g., a battery or a voltage regulator output).
  • Ensure the power source is within the recommended voltage range (3.3V to 5V).
  • 2. Signal Connection:
  • Connect Pin 2 (SIGNAL or OUT) to a digital input pin on a microcontroller or a logic-level converter.
  • Use a suitable pull-up resistor (e.g., 10k) if required, depending on the microcontroller or circuit requirements.
  • 3. Ground Connection:
  • Connect Pin 3 (GND) to a ground point on the circuit (e.g., the negative terminal of a battery or a ground pin on a microcontroller).
  • Important Notes
  • Ensure proper power supply and ground connections to avoid damage to the Tilt Sensor.
  • Use a breadboard or a PCB with a reliable connection system to avoid loose connections.
  • Follow the datasheet recommendations for the specific Tilt Sensor model being used, as pinouts and operating conditions may vary.
  • By following this connection structure, you can successfully integrate the Tilt Sensor into your IoT project and start measuring tilt angles with ease!

Code Examples

Tilt Sensor Documentation
Overview
The Tilt Sensor is a digital sensor that detects changes in tilt or orientation of an object. It is commonly used in IoT applications such as robotics, gaming, and smart home devices. The sensor outputs a digital signal indicating the tilt direction (up, down, left, right, or neutral).
Pinout
| Pin | Function |
| --- | --- |
| VCC | Power Supply (3.3V or 5V) |
| GND | Ground |
| OUT | Digital Output (Tilt Direction) |
Interfacing with Microcontrollers
The Tilt Sensor can be easily interfaced with popular microcontrollers such as Arduino, Raspberry Pi, and ESP32.
Example 1: Arduino
In this example, we will use an Arduino board to read the tilt direction and control an LED accordingly.
```c++
const int tiltPin = 2;  // Tilt sensor output pin
const int ledPin = 13; // LED pin
void setup() {
  pinMode(tiltPin, INPUT);
  pinMode(ledPin, OUTPUT);
}
void loop() {
  int tiltState = digitalRead(tiltPin);
  if (tiltState == HIGH) {
    digitalWrite(ledPin, HIGH); // Turn on the LED when tilted
  } else {
    digitalWrite(ledPin, LOW); // Turn off the LED when not tilted
  }
  delay(50);
}
```
Example 2: Python with Raspberry Pi
In this example, we will use a Raspberry Pi board to read the tilt direction and print the result to the console.
```python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
tilt_pin = 17  # Tilt sensor output pin
GPIO.setup(tilt_pin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
    tilt_state = GPIO.input(tilt_pin)
    if tilt_state:
        print("Tilted!")
    else:
        print("Not tilted.")
    time.sleep(0.5)
```
Example 3: ESP32 with MicroPython
In this example, we will use an ESP32 board to read the tilt direction and send the result to a remote server using Wi-Fi.
```python
import machine
import urequests
tilt_pin = machine.Pin(4, machine.Pin.IN)
wi Fi_ssid = "your_wifi_ssid"
wi Fi_password = "your_wifi_password"
def connect_wifi():
    import network
    sta_if = network.WLAN(network.STA_IF)
    sta_if.active(True)
    sta_if.connect(wiFi_ssid, wiFi_password)
    while not sta_if.isconnected():
        pass
connect_wifi()
while True:
    tilt_state = tilt_pin.value()
    if tilt_state:
        print("Tilted!")
        urequests.post("http://your_server_ip/toggle", json={"state": "tilted"})
    else:
        print("Not tilted.")
        urequests.post("http://your_server_ip/toggle", json={"state": "not_tilted"})
    time.sleep(0.5)
```
Notes
The tilt sensor output may require debouncing depending on the mechanical characteristics of the sensor and the application.
 The examples above assume a simple digital output from the tilt sensor. If your sensor provides analog output, you may need to use an ADC (Analog-to-Digital Converter) to read the output.
 Ensure to power the tilt sensor according to the manufacturer's specifications to avoid damage.