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
Look at how the two Raspberry Pi would look like in the end
View the web portal that is made using Python via Flask
Finding the Bot we created
Using 1 of the PiCam as a CCTV and streaming live footage
- 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)
- Create a folder to store your html called templates
- Create a folder to store your camera files called camera with 3 sub folder capture_photos, motion_photos, motion_videos
Step 3: Set Up for Raspberry Pi 2 (Door)
- Create a folder to store your files called door
- Create a folder to store your QR Code images called qr_code
Step 4: Set Up Telegram Bot
- Open Telegram
- Find "BotFather"
- Type "/start"
- Type "/newbot"
- Follow the instructions, name for bot, username for bot, jot down bot authentication token
Step 5: Set Up DynamoDB
- Sign up for AWS
- Search DynamoDB in AWS Service
- Click "Create table"
- Fill in table name
- Set Partition key as 'id'(String) and Add Sort Key as 'datetime'(String)
- Do it for the 4 tables, dht, lights, gallery, employee
Preview of the 4 Tables
Step 6: Set Up AWS S3 Bucket
- Search for AWS S3
- Click on "Create bucket"
- Follow the rules to name the bucket
- Follow screenshots
- 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
- Search for AWS SNS
- Follow Topic Tag
- Create new Topic
- Set topic name and display name
- Edit policy to allow everyone to publish
- Subscribe to the topic that is created
- Set email in the endpoint field to receive email when the value reaches a certain value
Step 8: Creating a Rule
- Click on "Create a rule"
- Write name and brief description
- Choose the latest SQL version to send the entire MQTT message
- The rule engine uses the topic filter to determine which rules to trigger when MQTT message is recieved
- Click on "Add action"
- Select sending a message via SNS push notification
Step 9: Creating Web Interface
Create these new html files called
Copy and paste from the Google Drive file into the respective html.
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