Introduction: Energy Saver 3000

Adrien Green, Huy Tran, Jody Walker

The use of a Raspberry Pi computer and Matlab is a simple and effective way to help homeowners reduce there energy consumption. The best part about the Energy Saver 3000 is that it is very simple to set up and use. The main purpose of the Energy Saver 3000 is to allow homeowners to be able to track their energy bill to see how much they're spending, and to allow home owners to turn off the lights in there homes remotely with a press of a button.

Step 1: Parts Used

1: Raspberry Pi computer

2: Breadboard

3: Jumper wires

4: Push button

5: Mini LED lights

6: 330 ohm, 10 Kohm, and a 300 ohm resistor

7: Ethernet Cable

8: Light photocell

Step 2: Problem Statement

Our project was to design a home energy saver using a Raspberry Pi computer and MATLAB. Our goal was to build a system that allowed users to track their energy bill to see if they can reduce their energy consumption. We also wanted users to be able to turn off their lights while they were gone with a press of a button. To do this, we wired up a photocell to sense when the lights are on. If the lights are on, the MATLAB program will calculate how long they've been on and how much energy and money has been spent since they've been on.

Step 3: Setup

Wire up the breadboard as shown in the Picture above.

Step 4: MATLAB Code for Controlling the Photocell

function control_light()
rpi = raspi();

writeDigitalPin(rpi,12,1)

time = 0

sumcost = 0

Time = 0

Cost = 0

bulb = 100/1000;% kilowatts

for i = 1:2

tic

while true

x = readDigitalPin(rpi,13)

if x == 1

writeDigitalPin(rpi,19,1)

elseif x == 0

writeDigitalPin(rpi,19,0)

toc;

time = time + toc

kwh = toc * bulb

dollars = 0.101

cost = kwh * dollars

sumcost = sumcost + cost

X = linspace(Time,time,10)

Y = linspace(Cost,sumcost,10)

Time = time

Cost = sumcost

disp(['Light has been on for ', num2str(toc),' hours. Cost = $', num2str(cost)])

plot(X,Y,'b') title('Cost Over Time')

xlabel('Time (Hours)')

ylabel('Cost ($Dollars)')

hold on

break

end

end

pause(5)

tic

while true

x = readDigitalPin(rpi,13)

if x == 1

writeDigitalPin(rpi,19,1)

elseif x == 0

writeDigitalPin(rpi,19,0)

toc;

time = Time + toc

kwh = toc * bulb

dollars = 0.101

cost = kwh * dollars

sumcost = Cost + cost

X = linspace(Time,time,10)

Y = linspace(Cost,sumcost,10)

Time = time

Cost = sumcost

disp(['Light has been on for ', num2str(toc),' hours. Cost = $', num2str(cost)])

plot(X,Y,'g')

title('Cost Over Time')

xlabel('Time (Hours)')

ylabel('Cost ($Dollars)')

hold on

break

end

end

pause(5)

end

Step 5: MATLAB Code for Turning Lights Off

function button_controlv1()

rpi = raspi();

condi = 1;

while true % creates an infinite loop to keep the code running

button = readDigitalPin(rpi, 6); % Reads the button press value on pin 6

if button == 0

condi = condi + 1

end

if mod(condi,2) == 0

writeDigitalPin(rpi,17,0)

h = msgbox('You turned the light off. :)') waitfor(h);

break

end

if mod(condi,2) == 1

writeDigitalPin(rpi,17,1)

end

end

Step 6: MATLAB Code for Turning Lights On

function button_controlv2()

rpi = raspi();

condi = 2;

while true % creates an infinite loop to keep the code running

button = readDigitalPin(rpi, 6); % Reads the button press value on pin 6

if button == 0

condi = condi + 1

end

if mod(condi,2) == 0

writeDigitalPin(rpi,17,0)

end

if mod(condi,2) == 1

writeDigitalPin(rpi,17,1)

h = msgbox('You turned the light on. :(')

waitfor(h);

pause(10)

break

end

end

Step 7: MATLAB Code for GUI

function EnergySaver3000()

imgurl='http://clipart-library.com/images/pc585dj9i.jpg';

imgfile='Lightbulb.jpg'; urlwrite(imgurl,imgfile);

imgdata= imread(imgfile);

h=msgbox('Welcome to the Energy Saver 3000!','','custom',imgdata);

waitfor(h);

clear h;

while true

iprogram=menu('Which Program Do You Want to Run?','Bill Calculator','Light Control');

if iprogram==1

control_light() h=msgbox('Done!!!')

close all

elseif

iprogram==2

end

clear h;

ichoice=menu('Light Control','Turn On','Turn Off','Nevermind');

if ichoice == 1

button_controlv2()

h=msgbox('Done!!!')

elseif ichoice ==2

button_controlv1()

h=msgbox('Done!!!')

elseif ichoice==3

h=msgbox('You did nothing :(') waitfor(h);

h=msgbox('Done!!!')

end

waitfor(h);

end

end