IoT Door Security with custom Android App using Firebase
An IoT door security system that uses Internet of Things (IoT) technology to enhance the security of a door by allowing the door to be monitored and controlled remotely. This can be achieved through the use of sensors and other devices that are connected to the internet and can send and receive data. Some examples of IoT door security systems include smart locks, which allow you to remotely lock and unlock your door using a smartphone app. This allows you to monitor your door and communicate with them remotely. Other features that may be included in an IoT door security system include motion sensors, alarms, and real-time monitoring and notification. IoT Door Security with custom Android App using Firebase could be a great way to increase the security of your home or business.
- WeMOS D1 Mini / NodeMCU
- Magnetic Door Sensor
- Buzzer 5V
- Transistor BC547 x 1
- Resistor 330Ω x 3
- LED x 2
- 2 Pin Screw connector x 1
- Male/Female berg strip x 1 (Each)
- Dotted PCB small x 1
The magnetic sensor sends the data to ESP8266. The ESP8266 further sends the data to firebase real-time database for keeping the status. From this DB the android app reads the data and shows you the real time status of door. The app gives you the privilege’s to Activate Alarm and Deactivate Alarm. Also a buzzer and alarm notification LED is also connected.
The connection is simple and can be mounted on a bread board as well. We have built this on a PCB after testing it in breadboard.
To use a library in an Arduino sketch, it must first be added to the Arduino development environment. This is typically done by selecting Sketch > Include Library > Manage Libraries from the top menu. Type in esp8266 firebase and install the below library.
Building Firebase Realtime Database
Login to Firebase and create an account if you are using it for the first time. Provide a name for your project.
As per your requirement you can enable google analytics or disable it and click on Continue. This is optional and doesn’t make any impact if you don’t enable it.
Now you project will be prepared and ready in sometime. Click on Continue.
We need a Realtime Database hence we will click on it.
Click on Create Database to build it.
Let the default location be there for your Realtime DB and click on Next.
By default the locked mode will be selected, click on enable.
After enabling, click on Rules and edit rules. Make the read and write as true. Also click on Publish to save changes.
Click on Data and here you will get the the URL of your database which is created. Copy this and keep it in a notepad. We need to put this in our Arduino code.
Go to Project settings and collect the required information.
Click on Service accounts and click on Database secrets to get the secret key to connect with your database. Copy and paste it in notepad as we need it in our Arduino code.
You can download the code from below link and open it using Arduino IDE. Also make changes before uploading the code.
Update the firebase URL, firebase secret key, your wifi ssid along with the wifi password to connect with firebase db and internet.
If you are changing the bucket and names then make sure you change it in the highlighted areas as well. Or else the communication will not happen correctly with database.
This snapshot is for your reference from the firebase real-time database.
Building Android App
Here we are using MIT App Inventor for building a custom Android app. MIT App Inventor is a web-based software development environment that allows anyone to build mobile apps for Android devices. It is developed and maintained by the Massachusetts Institute of Technology (MIT). With MIT App Inventor, you can design and build mobile apps using a visual drag-and-drop interface. No prior programming experience is required. You can then use the web-based interface to design and build your app, and test it on your device using the Companion app.
MIT App Inventor is a great tool for educators, students, and hobbyists who want to learn how to build mobile apps. It is also a useful resource for professionals who want to create prototypes or test ideas quickly and easily.
Here we have shared the aia file. You can download and import it in MIT App Inventor. Before you create an apk file you have to make changes in the firebase DB as shown below.
Update the Firebase DB secret key in firebase token. Also ass the firebase URL which you have coped earlier along with the project bucket.
For sending push notification we are using a notification extension. Just download the file and import it in mit app inventor.
Notification Extension download link.
Project aia file download link.
Building and Testing
Here we have connected the components in a PCB and uploaded the code in ESP8266.
Once you move the magnetic sensor the door status gets open. The moment the sensor are close then the door status will be close. If you activate the alarm and open the door the buzzer will beep and you will receive notification on your mobile. If the alarm is deactivated then it will show you the status of the door.
In this tutorial we learnt about building an IoT Door Security with custom Android App using Firebase. We have shown you the creation of firebase real-time database along with its configuration. The Arduino code with the changes needed and building an Android app. Hope you like this project, don’t forget to share this page with others.
More Interesting Projects:
- Raspberry Pi Pico with LCD & SSD1306 OLED Display
- Raspberry Pi Pico W web server with BMP180 sensor
- Controlling Devices with Raspberry Pi using Python
- IoT LPG Gas Detection with Blynk 2.0
- Building Node-RED Dashboard with DHT11 Sensor
- IoT Smart Plant Watering System Project
- Monitoring Weather Data using BMP280 and Blynk 2.0
- Getting Started with Arduino IoT cloud using NodeMCU and DHT11
- Weather Station with Raspberry Pi PICO and DHT11
- Controlling a servo motor using Raspberry Pi Pico
- Configuring BMP280 Sensor with Raspberry Pi
- Weather Station with BMP280 Sensor and Raspberry Pi Pico