Step 1: ​Table of Contents

1 Overview of Smart Secure Home

2 Hardware requirements + Setup

3 Software requirements + Setup

4 Register raspberrypi as a thing

5 Create a S3 Bucket

6 DynamoDB setup + Rules

7 Expected outcome

8 Codes (From Pastebin)

9 References


Welcome! This Raspberry Pi project is a "smart home" management system, with certain security features. The project is able to measure various values such as temperature and light. The security section consists of a Buzzer, a card scanner system(Authorises card), an indoor and outdoor camera as well as a SMS alert system. The following instructions will cover the set up of the entire project.

Basically, we have a light diode resistor and a DHT11 sensor to get the temperature as well as light values. The values will then be published to ‘smartroom/sensors/values’ and there will be a subscription to the topic to check if the values are being published. Once values are being published, the values will also be sent to our DynamoDB table. The values stored inside DynamoDB can be extracted and be plotted into a graph that displays real time values in our web interface. (Light graph) Besides using the sensors for getting values to plot our graph for analysis purposes, our dht11 sensor is also used as a potential “fire” detector. When it hits a certain temperature that might be a fire, we have a script named that will publish the temperature to a topic ‘smartroom/sensor/fire’, the breadboard which symbolises the outside of the apartment will then subscribe to that topic and have a LED light up to indicate that there might be a potential fire. The alarm will go off too as well as an SMS to alert the home owner when there might be a potential fire.

To enter the home/room, user will have to tap their card at the RFID scanner. If the tapped card is incorrect, the alarm will sound until a card with the right credentials are tapped. In addition, when an incorrect card is tapped, the surveillance camera outside will take a picture of the user who tapped the card and upload the picture into S3 bucket. The home owner will also receive an SMS stating that someone attempted to enter his/her home. The room also has an LED indicator outside to label if the door is unlocked/locked. When the door is locked, the yellow LED is lit. When unlocked, the green LED will be lit. When an authorised card is tapped, the door will be unlocked for 15 seconds and with the green LED lit then be back into unlocked mode with the yellow LED lit. Users can view the data collected via a Dashboard in Node-Red that shows the current measurement values in addition to a graphical representation of a gauge and a historical graph. The Dashboard also includes additional features such as a clock that displays the current data and time and switches to remotely control various electrical appliances, which are represented as LEDs and a buzzer. Lastly, we also have a telegram bot feature. The telegram bot is able to remotely take pictures of whatever that is happening inside the room and store it into the S3 bucket. These pictures will be labelled with inside a folder named “Homed/User The telegram bot will be able to remotely control the LED light in the room too.

Step 2: Step 1: Hardware Requirements + Setup

Connect the following components with your 2 raspberry pis as shown in the fritzing diagrams above.

2 x Raspberry Pi

3 x Breadboard

1 x MCP3008 ADC

1 x DhT 11 sensor

1 x LDR

1 x RFID/NFC MFRC522 Card Reader

4 x LED 1 x LCD Screen

3 x 10k Resistor

4 x 220/330 Resistor

1 x Button

1 x Buzzer

34 x Male to male cables

11 x Male to female cables

Step 3: Software Requirements + Setup

Type the following commands into your raspberry pi terminal to ensure that they are installed.

If any of the following software are already downloaded into your pi , sudo pip install (Software name) --upgrade will do the trick of updating it.

- sudo pip install gevent

- sudo pip install flask

- sudo pip install nexmo

- sudo pip install --upgrade --force-reinstall pip==9.0.3

- sudo pip install AWSIoTPythonSDK --upgrade --disable-pip-version-check

- sudo pip install --upgrade pip

- sudo apt-get install python-dev

- sudo pip install boto3

- sudo pip install botocore

- sudo pip install numpy

- "cd ~ git clone cd ~/SPI-Py sudo python install" - "cd ~ git clone cd ~/MFRC522-python sudo python install"

- sudo nano /boot/config.txt , check if lines device_tree_param=spi=on dtoverlay=spi-bcm2835 are inside, else add in.

- Sign up for a nexmo account for SMS :

Step 4: Registering a Thing

a) First, navigate to IoT Core within the AWS website by

clicking on services, then IoT Core.

b) At the navigation bar under manage, select things and choose register a thing.

c) Choose Create a single thing.

d) Enter a name for your thing, for example, MyRaspberryPi2. Leave the rest of the fields by their default values. Click next at the bottom of the page.

e) Click create certificate. Download all four files. For the root CA file, download the Amazon Root CA 1 and save it in a notepad.

f) Once done, move the four files to into a directory in raspberry pi.

g) Click activate.

h) After clicking on attach policy, you will be brought to the following page. Click register thing, policy will be created later.

i) On the iot dashboard, navigate to policies under the secure section. Click create a policy.

j) Enter a name for your policy, for this example it will be MyRaspberryPiSecurityPolicy and key in the following under Add statements. Then click on Create.

k) On the iot dashboard, navigate to certificates under secure section. Select the certificate you created previously, and click attach policy from the actions dropdown. Attach the policy you created previously.

l) Select the certificate you created previously again, and click attach thing. Attach the policy you previously created. Attach the thing you created previously.

Step 5: Create a Bucket

a) We will begin with using the search function in AWS management console and search for “s3”.

b) Click on create bucket.

c) Type in a name for the bucket. For this example, we will be using the name “sp-p1703263”. We will be choosing the region “US EAST(N. VIRGINIA)” which is us-east-1. After that is done, click on Create.

d) The new created bucket will appear in the dashboard.

Step 6: Creating DynamoDB Table and Set Rules

a) First, navigate to the AWS servcies by clicking on services, then DynamoDB. Click create table.

b) Enter the table name “iotdata” and the primary key “deviceid” with a sort key “datetimeid”, then click create at the bottom of the page.

c) After that, navigate back to the IoT Core page. Click Act, then click on create a new rule.

d) Create a rule with the name “MyDynamoDBRule”. Under the rule query statement topic, enter “sensors/light”. e) Under Set one or more actions section, click on add action, click on “split message into multiple columns of a database table”. Click on configure action. Under table name, choose the iotdata. Under IAM role name, select the role you created previously which is “dynamodb_role”. Click add action, then create rule.

f) Click on create rule.

Step 7: Expected Outcomes


for the pi representing the outdoor of the room, the scripts and will be runned. If an incorrect card taps on the RFID scanner, the alarm will go off, with the yellow LED light still lit. An SMS will be sent to the home owner's phone to notify of a possible intrusion. Alarm will be sound too. A picture will also be taken and instantly uploaded into S3 Bucket. If the card tapped is authorised, the green LED will light up and the user can enter. The door will be locked again after 15 seconds (Green LED will off and yellow LED lit back up). If the temperature inside the room/home gets too high (To a temperature we deem as home/room potentially on fire), we will send an SMS alert to home owner. Alarm will also be sound with the red LED outside lit.


for the pi representing the indoor of the room, the scripts,, , will be runned. will store the real time values into DynamoDB. when is runned, type in the rpi's ip address:5000 in the browser, you will be directed to our web interface. We have a graph which displays real time light values obtained from our sensors in into DynamoDB. In addition, historical light values will also be displayed in our web interface. will publish temperature values to the outdoor breadboard for fire sensor purposes. will enable user to remotely control the on/off of the LED light in the room/home as well as snap a picture of whats happening inside and uploading the picture into the S3 bucket. For better visualization of how the expected outcome is supposed to look like:

Step 8: Source Codes (Pastebin)

Click on the link. Consists of all needed source codes:

Step 9: Refences

Iotguider. (2019). Send SMS from Raspberry Pi using Python. [online] Available at: [Accessed 21 Aug. 2019].

Be the First to Share


    • Plywood Challenge

      Plywood Challenge
    • Plastic Contest

      Plastic Contest
    • Battery Powered Contest

      Battery Powered Contest