Arduino ProjectsESP32

Digital 360° Tilt Sensor with Arduino and ESP32

Digital 360° Tilt Sensor:

Digital 360° Tilt Sensor with Arduino and ESP32- Imagine a tiny sensor that can detect tilting in any direction; 360 degrees using just a clever metal ball and gravity. Today we are diving into the DFRobot Digital 360° Tilt Sensor V1.0.

Digital 360° Tilt Sensor with esp32 and arduino

And I will show you how to use it with both a 5V Arduino and a 3.3V ESP32 WiFi + Bluetooth Module. Whether you are building a smart alarm or a motion-triggered gadget, this sensor has got you covered.

allpcb circuit

We will cover a total of four examples. And let me tell you, in the fourth example, we will monitor this tilt sensor through the Blynk application. You absolutely should not miss this example if you want to build an IoT-based security system using a Digital 360° Tilt Sensor.

So, without any further delay; let’s get started!




Amazon Links:

Arduino Nano USB C type (Recommended)

5V SPDT Type Relay

DFRobot Digital 360° Tilt Sensor V1.0

Other Tools and Components:

ESP32 WiFi + Bluetooth Module (Recommended)

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!



Digital 3600  Tilt Sensor:

This tilt sensor uses a metal ball that moves within its unique internal structure under the influence of gravity, either completing or breaking an electrical circuit.

Digital 360° Tilt Sensor internal structure

This design makes it a simple and effective tilt switch.

Digital 360° Tilt Sensor switch angle

When paired with an Arduino board via a digital input, it enables a variety of engaging interactive projects. Unlike mercury-based tilt switches, this sensor offers a safer alternative.

Traditional steel ball tilt switches, which detect tilting in only one direction, this sensor features a cylindrical shape that allows it to sense inclination in all 360° directions.

And let me tell you; this is a switch-type sensor and does not measure tilt angles. It reliably outputs a signal when tilted beyond a specific angle from the horizontal position. For precise tilt angle measurements, consider using a triple-axis accelerometer instead the most popular one is the MPU6050 which I have already used in multiple projects.



Digital 360° Tilt Sensor Specifications:

Working Voltage: 3.3/5V DC

Interface Type: Digital

Pin Definition: D: Digital output; +: Power -: Ground

Steel Ball Switch Closed Tilt Switch Angle: 45°

Digital 360° Tilt Sensor specification

The DFRobot Digital 360° Tilt Sensor V1.0 is designed to operate with a working voltage of either 3.3V or 5V DC, making it compatible with a wide range of microcontroller boards. It uses a simple digital interface, providing an easy way to connect to devices like Arduino or ESP32.

The sensor has three pins: “D” for digital output, “+” for power, and “−” for ground, ensuring straightforward wiring. Inside, a steel ball moves to close the switch when tilted at an angle of 45° or more from the horizontal position, delivering a reliable signal for tilt detection in your projects.



Digital 3600  Tilt Sensor Wiring with Arduino:

Digital 360° Tilt Sensor interfacing with arduino

As you can see, I have connected the DFRobot Digital 360° Tilt Sensor to an Arduino Nano. The reason I am using this development board is because it already has an SSD1306 OLED display module and a 5V buzzer, which I am going to use in two examples. Let me tell you how to connect all these components.

Connect the red and black wires of the tilt sensor to the Arduino 5V and GND pins. Connect the green wire to digital pin 3 on the Arduino.

The buzzer is connected to the Arduino digital pin 8. You can follow this circuit diagram.

5v buzzer circuit diagram with arduino and Digital 360° Tilt Sensor

I have used an I2C-supported SSD1306 OLED display module.

Simply connect its voltage and ground pins to the Arduino 3.3V and GND. And connect the SDA and SCL pins to the Arduino I2C pins A4 and A5.

If you also want to make the same Arduino Nano-based development board, then I highly recommend reading my previous article. Now, let’s go ahead and take a look at the programming.




Tilt Sensor and Buzzer Code:

In this example, we are not using the OLED display; instead, we are focusing on the tilt sensor and the buzzer. The code starts by defining two variables: The buzzer uses pin 8, and the tilt sensor uses pin 3.

The setup() function runs once when the Arduino starts. It sets pin 8 as an output to send signals to the buzzer and pin 3 as an input to read signals from the tilt sensor.

Then, in the loop() function, the program constantly checks the tilt sensor’s value using digitalRead().

If the sensor reads HIGH; meaning it’s tilted- the buzzer turns on with digitalWrite(Buzzer, HIGH) and stays on for 2 seconds due to delay(2000).

If the sensor reads LOW; indicating it’s not tilted- the buzzer turns off with digitalWrite(Buzzer, LOW).

I have already uploaded this program and now let’s watch the DFRobot Digital 360° Tilt Sensor in action.



Practical Demonstration:

control a buzzer using Digital 360° Tilt Sensor and arduino

Next, in this example, we will use the tilt sensor along with an OLED display to enhance our project.



Tilt Sensor, Buzzer, and Oled display Code:

This code connects a tilt sensor to pin 3 and a buzzer to pin 8 on the Arduino, while also using an SSD1306 OLED display module to show a switch graphic.

In setup(), it initializes the pins and OLED, starting with an “OFF” display. The loop() checks if the tilt sensor tilts (HIGH), toggling a systemActive state that updates the OLED to show “ON” or “OFF” and sounds the buzzer for 2 seconds when active and tilted.

The updateDisplay() function draws a 68×34 pixel switch, moving it right for “ON” or left for “OFF” based on the state. If the system isn’t active, the buzzer stays off, and the display defaults to “OFF.



Practical Demonstration:

OFF State

Digital 360° Tilt Sensor with arduino and ssd1306 oled

ON State

Digital 360° Tilt Sensor and arduino




Digital 3600  Tilt Sensor with ESP32:

This time, I have connected the tilt sensor to an ESP32 WiFi + Bluetooth Module. If you prefer you can also do the wiring on a breadboard.

Digital 360° Tilt Sensor with esp32

The reason I am using my designed esp32 development board is because, this board has a 5V SPDT type relay, which I can use to control almost anything. Let me tell you how to connect this tilt sensor and 5V SPDT type relay.



Interfacing:

Since ESP32 is a 3.3V compatible controller board, so connect the voltage and ground wires of the Tilt Sensor to the ESP32 3.3V and Gnd pins. Connect the Green wire to the ESP32 GPIO 15.

The 5V SPDT type relay is connected to the GPIO 13. For the relay connections you can follow this circuit diagram.

Digital 360° Tilt Sensor with esp32 5v relay circuit diagram

Now, let’s go ahead and take a look at the programming.



TilT Sensor ESP32 Code:

This is exactly the same code I used with the Arduino in example 1. This time I only changed the pin numbers. I am using GPIO 13 to control the relay and GPIO 15 for monitoring the Tilt sensor.

Practical demonstration:

For now, I haven’t connected any load to the relay, but if you want, you can connect any AC or DC load to it. Anyway, when I tilt the sensor, you will be able to hear the relay’s clicking sound. For the practical demonstration watch the video tutorial given at the end of this article.

Digital 360° Tilt Sensor with esp32



Tilt Sensor and Blynk application:

Now, in this fourth example, we will monitor the 360° Tilt Sensor V1.0 through the Blynk application. Since this is going to be an IoT-based project, it means we will be able to monitor this tilt sensor from any part of the world. So let’s go ahead and start with the Blynk IoT dashboard setup.

I have already written a getting-started article on the ESP32 and Blynk, where I have explained each and every detail. This includes how to install the ESP32 board in the Arduino IDE, how to install the Blynk library, and how to control and monitor loads and sensors over a long distance using the Blynk IoT application on a Smartphone.

Digital 360° Tilt Sensor blynk datastream scaled

For this project you only need to define a single virtual pin “V0” and assign it to the “LED Widget”. Then copy the credentials and paste them in the following code. If you find it difficult, no worries at all, I have covered it in the video tutorial given at the end of this article.




Tilt Sensor & Blynk ESP32 Code:

Now let’s start with the Blynk IoT application setup on the Smartphone. This also involves a few steps, simply download the Blynk IoT application and login with the same email ID. Once you open the blynk iot application I will be able to see the project template; simply open it up, add the LED Widget and assign it the DataStream “V0”. And that’s it, again for the guidance you can watch the video tutorial. Your application should look something like this.

blynk application for monitoring the Digital 360° Tilt Sensor

security system using Digital 360° Tilt Sensor and blynk esp32

The Green dot next to the Tilt Sensor means; its connected to the WiFi. The ESP32 is also connected to the WiFi. Anyways, as you can see when the 360 degrees tilt sensor is flat the LED widget on the Blynk application is OFF.

But as soon as I tilt the sensor, the LED widget is turned ON.

Iot based Digital 360° Tilt Sensor using blynk application

So, that’s all for now.



Watch Video Tutorial:

 

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Electronic Clinic
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.