Smart Home System

This instructable will help to explain how to set up and use our Smart Home System by using the Matlab software and the Raspberry Pi hardware. At the end of this instructable, you should be able to fully use our product with ease!

Step 1: Step 1: Parts and Materials Needed

  • Raspberry Pi
  • Breadboard (x2)
  • PIR Motion sensor
  • LCD Module
  • LED Light
  • Capacitor
  • Raspberry Pi Camera
  • Micro Servo Motor
  • Double Ended Wires (20)

Step 2: Step 2: Problem Statement

The issues that our product is trying to address are manual light controls, indoor temperature control, and energy efficiency. We focused on the amount of energy that the average home uses, and we wanted to find ways to reduce energy usage. Lights being left on and unnecessary thermostat temperatures account for very high unnecessary energy usage. The light will be motion activated to where they shut off when a room is vacant, and the thermostat adjusts to a environmentally efficient temperature based on the reading of the outdoor temperature.

Step 3: Step 3: Motion Sensor Configuration

The motion sensor is connected to a 3.3V power pin, ground pin, and a digital pin of your choosing. They are connected to the VCC, GND, and OUT ports on the motion sensor, respectively. The motion sensor will detect when someone is near and activates the LED to indicate that the lights are turned on. Once motion is no longer detected, the LED will turn itself off. The code is as follows:

while true

motionDetected = readDigitalPin(rpi, 3);

if motionDetected == 1

writeDigitalPin(rpi,16,1)

else

writeDigitalPin(rpi,16,0)

end

end

Step 4: Step 4: LCD Module Display

The LCD takes the temperature data from the live weather information provided from the internet. The LCD module then displays the current temperature reading. In Matlab, the temperature is read and then goes through an if loop to determine how much to adjust the temperature setting in the home. The code is as follows:

url='https://forecast.weather.gov/MapClick.php?lat=35.9606&lon=-83.9207&FcstType=json';

data = webread(url);

a = data.currentobservation.Temp;

fprintf('The outdoor temperature is %s\n', a)

x = str2num(a);

if x > 80

fprintf('Turn the thermostat down 15 degrees')

writeDigitalPin(rpi,26,1) %turns on lights

elseif x > 75 && x < 80

fprintf('Turn thermostat off \n')

writeDigitalPin(rpi,26,1) %turns on lights

elseif x < 74 && x > 55

fprintf('Turn the thermostat up 10 degrees \n')

writeDigitalPin(rpi,26,0) %turns off lights

elseif x < 55 && x > 45

fprintf('Turn the thermostat up 20 degrees \n')

writeDigitalPin(rpi,26,0) %turns off lights

elseif x < 45 && x > 40

fprintf('Turn the thermostat up 25 degrees \n')

writeDigitalPin(rpi,26,0) %turns off lights

elseif x < 40 && x > 30

fprintf('Turn the thermostat up 35 degrees \n')

else

fprintf('Turn the thermostat up to 65 degrees \n')

end

Step 5: Step 5: Motor Servo Module

The Motor Servo Module is to represent the ability to open and close the blinds. When the home needs to be cooled, the blinds will close as to let less heat in. When the home needs to be warmed, the blinds will open in order to warm it up faster. The servo decides which to do by receiving input from the user interacting with a menu of options. The code for the motor is as follows:

s = servo( rpi,3 )

writeDigitalPin(rpi,4,1)

writePosition(s,45)

temp_sys = menu( 'How are you feeling?') %temp adjustor

if temp_sys == 1 %hot

writeDigitalPin(rpi,26,1) %turns on lights

writePosition(s,0) %turns motor CW/CCW

close blinds, turn off lights

elseif temp_sys == 2 %cold

writeDigitalPin(rpi,26,0) %turns off lights

writePosition(s,180) %turns motor CCW/CW

open blinds, turn on lights

elseif temp_sys == 3 %just right

fprintf('Maintaining temperature status.\n')

end

Step 6: Step 6: Motion Sensor Camera

The motion sensor camera takes a photo of those who enter or leave a room. We chose this as an added security feature for those who are curious about who has been in their home. When the motion sensor detects motion, the Matlab code tells the camera to take an image and display it. The code is as follows:

i=0

clear cam

cam = cameraboard(rpi);

while i==0

snapshot(cam); %clear image buffer

img = snapshot(cam);

imagesc(img);

end

Share

    Recommendations

    • Frozen Treats Challenge

      Frozen Treats Challenge
    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • 1 Hour Challenge

      1 Hour Challenge

    Discussions

    0
    None
    seamster

    3 months ago

    Good info, thank you! : )