Intelligent Door

Story

The project demonstrates an intelligent door which sends out email notification to the owner when there is an intrusion. This is achieved by using ADXL345 accelerometer which detects the change in motion of the door and raspberry pi to communicate to the AWS IoT console. Based on the messages from the AWS IoT console, AWS SNS will send out email notification to the owner.

AWS IoT console's MQTT Protocol is used for achieving this. MQTT is a machine to machine messaging protocol widely used in Internet of Things projects. The protocol has MQTT Broker (Server) and MQTT Clients. In our case AWS IoT acts as a secure MQTT Broker and Raspberry pi acts as MQTT Client. MQTT follows publisher-subscriber model. A message published to a topic will be received in all clients which has subscribed to that topic. Hence two-way communication is easily possible with MQTT.

Platform Explanation:

  • AWS IoT Console: Amazon Web Services recenlty launched support for the IoT. It is a very secured platform compared to the other open source and free platfroms. You will have to register your device first and download certificates before publishing the data to the cloud.
  • AWS SNS Console: SNS is used to send out push notification by various means (HTTP, Email, Mobile etc.) In this project Email notification is chosen as most of the users uses email application in their mobile. No separte application is required to trigger push notifcaiton.
  • Raspberry Pi: Popularly known as low-cost credit card sized computer is a simple yet powerful ARM based computer runs Linux operating system. The default raspbian OS comes with preinstalled popular programming languages such as C++, python etc. 

Setting up the Hardware:

Raspberry Pi is very easy to setup. Follow this official getting started guide, once done open terminal window. Before start coding, lets connect ADXL345 accelerometer to the Raspbbery Pi. The connection is simple. Connect VCC — VCC, GND — GND, SCL — SCL, SDL — SDL. Schematic is provided below:

ADXL345 accelerometer communicate to the master device through I2C communication. I2C is not enabled in raspberry pi by default. 

Run the following commands sequentially to install necessary libraries for I2C:

$ sudo apt-get install python-smbus
$ sudo apt-get install i2c-tools

We will have to enable the I2C in raspberry pi configuration window so that the I2C module loads by default.

The following steps will show you do that:

Then reboot the raspberry pi.

With the accelerometer connected type the following command in the terminal.

$ sudo i2cdetect -y 1   

If you have made the connection correclty, you should get output like this:

53 says that the in the address 53 accelerometer in connected.

Setting up the environment:

 Create a new folder names aws-iot for this project by typing the following command.

$ mkdir aws-iot
$ cd aws-iot

Now download the pimoroni accelerometer library by entering the following command:

$ curl https://raw.githubusercontent.com/pimoroni/adxl345-python/master/adxl345.py > adxl345.py

The library helps to reduce the complexity of interfacing the ADXL345 accelerometer.

The raspberry pi is going to communicate with the AWS server though MQTT protocol. So we need to install mqtt client library for python.

$ sudo pip install paho-mqtt

Setting up AWS IoT:

Once you sign up for the Amazon Webservice select the AWS IoT console.

In order to connect a device to the AWS IoT, we need to create a resource in it.

Source: Intelligent Door


About The Author

Muhammad Bilal

I am highly skilled and motivated individual with a Master's degree in Computer Science. I have extensive experience in technical writing and a deep understanding of SEO practices.

Leave a Comment

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

Scroll to Top