This is a Rain Alert System, the alarm and LED will activate and warn the user that it is going to rain soon, the target audience for this application is for those people who put out their clothes to dry at home know so can keep their clothes without getting them wet beforehand. (If humidity hits > 70 buzzer will ring, if light value <300 LED lights up)
This application uses a web interface hosted using IBM’s node red which allows the user to control the real time state of the Buzzer & LED, and view the real time state of DHT11 & LDR sensor and also the historical state of the DHT11 & LDR sensor.
We are using DynamoDB to store our LDR’s light value and also our DHT11’s humidity and temperature value. This application uses AWS IoT’s broker service which enables our application to send and receive messages.
Step 1: Materials & Preparations
1 x Raspberry Pi.(16gb microSD)
1 x DHT11.
1 x Light-Dependant Resistor (LDR).
1 x Analog-to-Digital Converter (MCP3008 ADC).
1 x 220 ohms resistor.
3 x 10k ohms resistor.
1 x Buzzer.
1 x LED.
1 x Button.
Will be using Node-RED with MQTT broker on your Raspberry Pi to code the application
Need to have an IBM account and AWS account
Step 2: Setting Up the Hardware
Follow the steps in order to set up your hardware in the breadboard. You can follow the fritzing diagram.
1. Setup the LDR first
2. Setup the DHT11
3. Setup the Button
4. Setup the Buzzer
5. Setup the LED
Step 3: Setting Up IBM and AWS
This application requires you to have an AWS account, an educate account can also be used.
Head to your AWS console and go to AWS IoT service (IoT Core) and follow these steps (skip step 1,6 & 11 if you do not wish to store data in DynamoDB) :
1. Head to DynamoDB to create 3 tables with a sort key timestamp and primary key (light, temperature, humidity)
2. Create a single thing
3. Create a Security Certificate (Download all the certificates needed later)
4. Create a Security Policy
5. Attach the Security Policy and Thing to your Security Certificate
6. Create Rules to insert message to DynamoDB tables based on the Topic sensors/light, sensors/humidity, sensors/temperature. (You will need to create a AWS role and policy to access the database)
7. Go to your Raspberry Pi, create a folder put all the AWS certificate credentials in it and create a python file, copy and paste this to the python file:
8. Set up a IBM Watson IoT app (https://console.bluemix.net/catalog/starters/internet-of-things-platform-starter). Take note of the url of your website.
9. Set up Gateway Device and Device Types (Take note of the authentication token, device id and type after you create this)
10. Install IBM Node-RED in raspberry pi
11. Install aws dynamodb node in IBM Node-RED (node-red-contrib-aws)
Step 4: Setting Up Node-RED in Your Raspberry Pi and IBM Node-RED
In your own Raspberry Pi's Node-RED import this clipboard:
You need to change MQTT, Watson IoT Node and DynamoDB node to your own credentials
In your IBM Node-RED import this clipboard:
You can deploy and the dashboard for IBM should look like the images shown