Raspberry Pi - Smart Office

2,254

20

1

Published

Introduction: Raspberry Pi - Smart Office

What is the application about?

OfficeHelperBOT is an application targeted towards a smart office setting. 2 Raspberry Pi 3 Model B would be setup for this.

Raspberry Pi 1 would be the main machine which will take in all the values from the sensors, publishing the data via MQTT, storing data into cloud database which we are using DynamoDB and running the web portal server.

Raspberry Pi 2 would be used at the door. It would require the employee to verify their identity before they are allowed access into the office. There are two methods to do so which are via a pin code sequence and a QR code verification. In the cases that the verification may be misused, we would take picture of whoever is having failed verification and store the person’s image onto AWS S3 Bucket.

A webpage would be able to view DHT, light, motion detected photos and video of the office. The webpage would also be able to control the office lights and also view a live stream of CCTV of the office.

There would also be a Telegram bot which allow control to the LED lights in the office, check value of sensor values such as the temperature and also allowing employee to get their QR code image if they happen to lose their QR code image or forgot their pin by requesting and getting their QR code image from AWS S3 Bucket.

Step 1: Let's Look at the Overview!

System Architecture Diagram

How the machines will communicate with one another

Hardware Outcome

Look at how the two Raspberry Pi would look like in the end

Web Portal

View the web portal that is made using Python via Flask

Telegram Bot

Finding the Bot we created

Livestream

Using 1 of the PiCam as a CCTV and streaming live footage

Hardware Requirement

  • 2x Raspberry Pi
  • 2x GPIO Board
  • 1x LDR
  • 1x DHT11
  • 1x Motion Sensor
  • 4x LED
  • 7x Button
  • 2x Buzzer
  • 2x LCD Display
  • 1x Webcam

Step 2: Set Up for Raspberry Pi 1 (Office)

  1. Create a folder to store your html called templates
  2. Create a folder to store your css/javascript files called static
  3. Create a folder to store your camera files called camera with 3 sub folder capture_photos, motion_photos, motion_videos

mkdir ~/ca2

mkdir ~/ca2/templates

mkdir ~/ca2/static

mkdir ~/ca2/static/camera

mkdir ~/ca2/static/camera/capture_photos

mkdir ~/ca2/static/camera/motion_photos

mkdir ~/ca2/static/camera/motion_Videos

Step 3: Set Up for Raspberry Pi 2 (Door)

  1. Create a folder to store your files called door
  2. Create a folder to store your QR Code images called qr_code

mkdir ~/door

mkdir ~/door/qr_code

Step 4: Set Up Telegram Bot

  1. Open Telegram
  2. Find "BotFather"
  3. Type "/start"
  4. Type "/newbot"
  5. Follow the instructions, name for bot, username for bot, jot down bot authentication token

Step 5: Set Up DynamoDB

  1. Sign up for AWS
  2. Search DynamoDB in AWS Service
  3. Click "Create table"
  4. Fill in table name
  5. Set Partition key as 'id'(String) and Add Sort Key as 'datetime'(String)
  6. Do it for the 4 tables, dht, lights, gallery, employee

Preview of the 4 Tables

Step 6: Set Up AWS S3 Bucket

  1. Search for AWS S3
  2. Click on "Create bucket"
  3. Follow the rules to name the bucket
  4. Follow screenshots
  5. Create Bucket

How do I even upload into S3 bucket?

We do not have an admin portal so we would be manually importing the QR Code image via AWS graphic user-interface. Follow the screenshots to create the bucket. The snippet of the code is the logic required to upload the image onto S3 Bucket

Step 7: Set Up AWS SNS

  1. Search for AWS SNS
  2. Follow Topic Tag
  3. Create new Topic
  4. Set topic name and display name
  5. Edit policy to allow everyone to publish
  6. Subscribe to the topic that is created
  7. Set email in the endpoint field to receive email when the value reaches a certain value

Step 8: Creating a Rule

  1. Click on "Create a rule"
  2. Write name and brief description
  3. Choose the latest SQL version to send the entire MQTT message
  4. The rule engine uses the topic filter to determine which rules to trigger when MQTT message is recieved
  5. Click on "Add action"
  6. Select sending a message via SNS push notification

Step 9: Creating Web Interface

Create these new html files called

  • head
  • login
  • logs
  • dht
  • light
  • gallery
  • motion
  • led

Copy and paste from the Google Drive file into the respective html.

https://drive.google.com/file/d/1zd-x21G7P5JeZyPGZp1mdUJsfjoclYJ_/view?usp=sharing

Step 10: Main Scripts

There are 3 main scripts

  • server.py - Create a Web Portal
  • working.py - Logic for Raspberry Pi 1 (Office)
  • door.py Logic for Raspberry Pi 2 (Door)

We simply run all 3 codes to get the result we want

We can get it from Google drive under the Main.zip

https://drive.google.com/open?id=1xZRjqvFi7Ntna9_KzLzhroyEs8Wryp7g

Share

    Recommendations

    • Water Contest

      Water Contest
    • Oil Contest

      Oil Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    Discussions