In this project, we aim to learn how to use AWS and MQTT in our setup. Being in the world of technology, how great will it be being able to control your room with just your laptop! Imagine yourself rushing for time to complete your projects, walking over to turn on the switch for your light is just too time consuming!
This portal will:
- Allow you to upload/retrieve images (S3 Bucket)
- Check light values (DynamoDB)
- Turn on/off led
- Check temperature and humidity (phpmyadmin)
From students to elderly, it’s a simple interface that is easy to use and understand!
Step 1: Hardware Checklist
Let’s review the hardware components needed for this tutorial.
- Assorted Jumper Cables
- DHT11 Temperature and Humidity Sensor x1
- 10k ohms resistor x2
- MCP3008 x1
- Light-Dependant Resistor (LDR) x1
- LED Light x1
- 330 ohms resistor x1
- Picamera x1
Step 2: Accessing AWS
- Login to https://awseducate.qwiklabs.com/users/sign_in?locale=en
- Copy the Access Key ID and Secret Access Key for configure purposes later.
- Click "Open Console"
Register your Raspberry Pi as a "Thing"
- Search for AWS IoT
- Under the left navigation bar, click "Manage" and select "Things"
- Write a name for your Thing and create a certificate.
- Save the 4 files generated upon certification creation.
- Create a policy and attach the policy to your Thing.
- Search for DynamoDB
- Create a table for Light
- Search for S3
- Create a bucket for uploading of images
Step 3: Installation for Raspberry Pi
Before you begin running the codes, install these in your Raspberry Pi.
- Open terminal window
- AWSIoTPythonSDK: sudo pip install AWSIoTPythonSDK
- awscli: sudo pip install awscli
- Boto: sudo pip install boto
- Boto3: sudo pip install boto3
- Flask: sudo pip install flask
- mqtt: sudo pip install mqtt
- paho: sudo pip install paho
Run in your terminal window:
and key in the access key and secret access key of your console.
Step 4: Smart Room Control Codes
- InsertIntoDB.py: This will insert temperature and humidity into database
- aws_pubsub.py: This will subscribe to topics such as sensors/light and camera to get the light value and images.
- server.py: This will allow LED to be turned on and off. Temperature and humidity will also be retrieve and displayed on the html page. Light value stored in the dynamoDB will be retrieved.
Step 5: Learning Experiences
Being totally new to Python, we faced a lot of difficulties and troubles during the process of learning this IoT module. However, with the guidance of our teachers and friends, we managed to cope and learn. Through this project, we learnt the importance of IoT devices in the current world, and we also got to have a better knowledge on using AWS.