You are on page 1of 11

African Leadership University

Course Name: Internet of Things


Course Code: COMS-RW-51515-1
Year of Study: 2021
Term: 2
Academic year: 4
Student name: Nathan Kudakwashe Kuchena
Task1
1. Context description and advantages of the system described in
scenario one

The task gives us the directive to design and implement a burglar alarm system
given the mentioned list of resources. The job of the system is to;

a) Detect an intruder

This is done through the use of an ultrasonic sensor that sends out and
receives sound waves. If the waves bounce off an object in this case an
intruder the sensor picks this up. The system is meant to pick up any object
that comes within two meters of the house

b) Warn the occupants of the house

This is done through the use of three output devices; an LED light, buzzer and
LCD screen. When an intruder comes within two meters of the house the red
LED light and the buzzer will go off every two seconds and the LCD will tell the
occupants of the house how far away the intruder is.

Advantages of having this system in place include:


A. Deter a break-in before it happens. Once the intruder hears the buzzer
and sees the light go on and off they will know their presence has been
detected and they usually run away.
B. Protect your home from theft. The average household has a lot of
valuables that people would not want to lose.
C. Increases the value of the property. If you were to potentially sell the
house, if it has a good security system it would sell for more on the
market. Buyers would want a house where they feel safe and secure.
D. Can be relocated or moved. The system is not a permanent feature of
the property and can be moved to another location/house/property if
the need arises.

2. Design (design of the whole circuit)


Notes
The buzzer and LED share the same Digital pin (D2) since their output
and code is the same.

3. Code that will operate the hardware

// Libraries
#include <LiquidCrystal.h>

int rs = 12, e = 11, d4 = 4, d5 = 5, d6 = 6, d7 = 7;


LiquidCrystal lcd(rs,e,d4,d5,d6,d7);

// Set pin numbers and global variables


#define LEDBUZZ 2
#define TRIGPIN 10
#define ECHOPIN 9
long duration = 0;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
lcd.begin(16,2);
pinMode(LEDBUZZ, OUTPUT); // initialise the LED/Buzzer pin
as output
pinMode(TRIGPIN, OUTPUT); // initialise the trigger pin as
output
pinMode(ECHOPIN, INPUT); // initialise the echo pin as input
}

void loop() {
// put your main code here, to run repeatedly:
// Setup ultrasonic sensor
digitalWrite (TRIGPIN,LOW);
delayMicroseconds(10);
digitalWrite (TRIGPIN,HIGH);
delayMicroseconds(7);

duration = pulseIn(ECHOPIN,HIGH);

long distanceCm = Distance(duration);

Serial.print("Distance = ");
Serial.print(distanceCm);
Serial.print("cm");

// Check if distance is less than 2M and trigger LED and Buzzer


if(distanceCm < 200){
digitalWrite(LEDBUZZ,HIGH); // turn on LED and Buzzer
delay(2000);
digitalWrite(LEDBUZZ,LOW); // turn off LED and Buzzer
delay(2000);

// Output to LCD
lcd.setCursor(0,0);
lcd.print("Intruder alert!");
lcd.setCursor(0,1);
lcd.print("Dist: ");
lcd.print("distanceCm");
}
}

// Calculate distance
long Distance (long time)
{
long calc;
calc = ((time * 0.034) / 2);
return calc;
}

Task2:
1. Context description and advantages of the system described in scenario two.

Task 2 presents us with the task of monitoring the lighting inside a house.
Using a LDR/photocell we keep track of the light intensity inside the house
and we can then switch on the light. The above two coupled with connecting
the system to the internet and ThingSpeak means all these operations can be
conducted remotely. The house owner can monitor the light intensity
remotely or see that the light(LED) turns on when it gets dark. Advantages of
the system include but not limited to;

A. Peace of mind for the house owner. Human beings generally feel much
safer when they are aware of everything going on with their
possessions even if it is as simple as the light intensity in the home.
B. Improved security for the property. Having the lights turn on when it
gets dark even if no one is around may deter potential thieves since if
they see the lights they will assume someone is home.
C. Electricity savings. Having the lights on when they actually need to be
on saves a lot in the long run in electricity bills for the homeowner as
the consume less electricity. This also translates into environmental
benefits.

2. Design (design of the whole circuit)


3. Code

// Libraries
#include <ESP8266WiFi.h>

// Write API key from ThingSpeak


String apiKey = "QAWYBMEJUKCCD42O";

// Internet connection details


const char *ssid = "CANALBOX-4149";
const char *pass = "1941950139";
const char* server = "api.thingspeak.com";

// Pin mappings
#define LDR A0
static const uint8_t D0 = 16;

int ledPin = D0;

WiFiClient client;

void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
delay(10);

// Connect to the internet

Serial.println("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, pass);

while (WiFi.status() != WL_CONNECTED)


{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

void loop()
{

// Setup light sensor


int lightIntensity = analogRead(A0);
Serial.println(lightIntensity);
delay(150);

// Automatically switch LED on/off when it gets dark


if (lightIntensity < 150){
digitalWrite(ledPin,HIGH);
}
else{
digitalWrite(ledPin,LOW);
}
// Upload to ThingSpeak
if (client.connect(server,80)) // "184.106.153.149" or
api.thingspeak.com
{
String postStr = apiKey;
postStr +="&field1=";
postStr += String(lightIntensity);
postStr += "\r\n\r\n";

client.print("POST /update HTTP/1.1\n");


client.print("Host:
api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY:
"+apiKey+"\n");
client.print("Content-Type:
application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);

Serial.print("Light: ");
Serial.print(lightIntensity);
Serial.println("%. Send to Thingspeak.");
}

client.stop();

Serial.println("Waiting...");

delay(1000);
}

4. Plot data on the app and display on the gauge.


5. Show LED status on the cloud using the lamp indicator.
6. IoT Deployment level.

As a home system without the need for any complex calculations or analysis the
above system falls into
Task3:
1. Describe embedded systems as an enabling technology in IoT

2. Describe cloud computing as an enabling technology in the IoT

Task 4:
1. Describe physical security and the importance it stands in IoT.

Task 5: References (IEEE format)

You might also like