Smart Hob by Alex Ross-Martin & Chris Cobb

Overview:

Many houses use electric hobs, these are quite inefficient and waste a lot of energy by over-heating and then stay hot for a long time after being switched off. They are present in 31% (Gov Report 9: Domestic appliances, cooking &
cooling equipment) of homes all over the uk and so a small energy saving would equate to big net savings.

On of the inherent inefficiency of the hob when it is being carefully used, a large amount of energy is wasted by users who are not using their hobs properly, such as boiling over or maintaining a temp that is above what is needed.

Project Aim:

To produce a device capable of monitoring and controlling the temperature of a hob to ensure that it is operating at its most efficiently. As well as the sustainability benefits, it should enhance the users cooking experience and be easy to use.

Research:

Stats:

The average house uses 1.5kwh per day cooking.

How much energy does it take to boil 1 litre of water on the hob?

Our experiments showed that bringing a pan of water to the boil over 10 minutes used 0.2Kwh.

Additionally we found that after bringing water to a boil, we could continue to boil water for 4 minutes after switching it off due to the retained heat in the ring.

How will our project help users?

Evidence shows that telling people alone is not enough to make them change their habits, that is why our project will aim to automatically improve energy usage without the user having to do anything. Additionally it should make the cooking process easier which will encourage them to use it.

Components:

-Arduino R3 Uno

-DS18B20 waterproof temperature sensor

-Max6675 breakout board

-K type thermocouple

-LCD display

-i2c board for LCD

-Buttons

-240v relay (5v input)

Using sensors to plot temperature

Our first step was using both our sensors to read the temperature of the hob and the water.

IMG_20180409_173821

Both sensors use their own libraries to convert data to a useable format, you need to use the correct functions to call the data from the sensors in order to use it.

Hob&water1

Once we had both sensors working together we could easily record the temps on the serial plotter like this.

Relay control of the hob

hot plate guts

This hob is very simple, having essentially only on/off switches. This meant we could control it using a relay inline in the positive feed.

Simple on or off relay control is as simple as writing pins high or low, but for more accurate control “time proportioning control” is used, this is where a window of maximum on time is created, then the relay can be turned on for a proportional of that window equivalent to the desired output.

ie if 50% power is required relay is on for 1/2 the window.

This system is very easy to set up and can be good for use with relays due to the fact it doesn’t produce excessive switching.

Control system

The bulk of this project has been spent on understanding and applying control to the hob. We started with a very simple “bang-bang” control, however this proved completely unusable due to the large thermal lag in the system.

We needed something better, hence we started investigating PID control.

This highly tuneable method is an industry standard for maintaining tight control over closed-loop systems. It uses 3 terms to compute the output needed to get a measured variable to a set value and keep it there, the first is proportion, which means increasing the output in proportion to the gap (error) between the measued and desired variables. It also takes account of the previous errors in the integral term and uses these to try to address consistent errors, this makes it adaptive to change in the system. The final term is the differential, which tries to predict what the next error will be based on how the error is changing, this can be used to make the system react quickly to upsets.

Writing an entire controller from scratch would be time consuming, luckily there is an arduino library available for the job. However implementing the library is not the easiest task, it requires careful tuning and a good knowledge of the underlying system.

https://create.arduino.cc/editor/AlexRossMartin/87a0c311-3678-44ac-bf07-eadfa69ec2b1/preview?embed

After several hours attempting to tune it, the controller was only able to be kept within 15* of the setpoint. However this could be improved with additional tuning time.

The user inteface

A key part of the project has been trying to add benefit to the user experience of cooking on the hob. Inspiration came from the simple interface on a microwave, where an lcd displays time and input is given by buttons.

IMG_20180419_151759[1]

Bringing it all together

The final version contains 2 sequential PID controllers, setup to feed into one another. Using this method, the stabilisation temperature of the water was improved significantly, now being stable to within a few degrees.

https://create.arduino.cc/editor/AlexRossMartin/f4c363ca-7c6d-43a6-a0f7-c628da934096/preview?embed

updated code, 23/04/2018:

https://create.arduino.cc/editor/AlexRossMartin/df786638-a882-4350-b65a-650b23975ed3/preview?embed

IMG_20180419_153307[1].jpg

Conclusion

In conclusion, this project has demonstrated the use of PID control to reduce the energy consumption of a hob.

With some careful tuning it could have a very good impact on reducing as well as benefiting the cooking experience.

Advertisements

Smart Shower Head – Lizzie Spinks & Liam Hopkins

Introduction

For our project on sustainability we decided to look at ways in which to save water whilst showering. The two main issues focused on are the wastage of water and heat before the user has even begun to shower and opportunities, during the shower, in which the water need not be running. Can we make significant reductions to the environmental impact of showering, without implementing considerable behavioural change?

Research

To decipher if simple sensors and coding can make a difference, a survey was taken outlining the showering behaviour of the average person. From this survey it was discovered that the average shower takes 48.1 seconds to get warm, taking in account the activities these people do whilst waiting for the shower to heat up, this means that the water is running, already hot, for 32.6 seconds unnecessarily. Once in the shower the participants were spending 2.1 minutes away from the water; again, letting in run without need.

Taking an average ml/s reading of various showers – a shower runs 77ml of water per second. From various energy and water supply companies it was found that 1kWh costs an average of 18.01p (in the Bristol area) and 1 litre of water will cost you 0.3p. Knowing that a 7.5kW shower uses 1.25kW in 10 minutes, it is possible to calculate just how much water and energy is wasted when we shower.

Over a year (12.2*365 = 4453) 4453 LITERS of water and (0.33*365 = 120.5) 120.5kWh of energy are being wasted by just ONE person wasting water whilst showering

Hypothesis

By halting the flow of water once it has reached the desired temperature, alerting the user that the shower is ready and disallowing the stream to continue when no one is underneath the showerhead; we can significantly reduce the amount of energy and water wasted whilst showering.

Experiment

We endeavoured to create a shower head that reduces energy and water consumption. To achieve this our product would stop the flow of water once it has reached the optimal temperature and only release water once a person is detected to be underneath the shower head.

fritz avec relay.jpg

This is the first look at our circuit. There are 4 main components;

  • Solenoid valve
  • Thermistor
  • Ultra-sonic sensor
  • Relay switch

The solenoid valve is the part that can control the flow of water, once power is passed through the component the valve opens. As ours is a 12v solenoid (Arduino Uno’s use 5v), we also plugged in a separate 12v power supply. The relay switch protects the Arduino from the extra power but bypassing it straight to the solenoid, this means that it does not affect any of the other components. Thus, controlling the solenoid valve without jeopardising the rest of the circuit. An ultra-sonic sensor can detect the distance of the nearest object, informing the s product that the user is within range. Finally, the thermistor measures the temperature of the water, which kickstarts the code.

https://www.youtube.com/watch?v=udJDDaaR-6c

 

Here you can see our circuit working (in this video we have used a red LED to represent the solenoid valve for a clearer display). The valve stays open as the shower turns on – this is to allow time for the water to warm up before requiring the user to stand underneath it (no one wants to stand under freezing cold water). Once the thermistor recognised the required temperature has been met, the solenoid valve closes. After this point the water will only flow if the user is detected below the ultra-sonic sensor. Therefore, you can see in the video that the valve opens and closes as motion passes past the sensor. If the water runs cold again, the thermistor will sense this, the valve will open and water will flow.

https://www.youtube.com/watch?v=u1DxXLQrffU This shows the same circuit with the solenoid added, if you listen carefully you can hear the valve opening and closing.

circuit n prototyp (2)

In our display unit we angled the ultra-sonic sensor to represent the placement of the sensor in the actual product, which would be just below the shower head.

circuit n prototyp (1)

At this stage we had the all of the components working, apart from our solenoid valve was reading the wrong way around – we have a video of this, with the intention to switch the code later to have the correct solenoid function https://youtu.be/M8W7rpvQq4k

From this point we needed to change the code regarding the distance of the ultra-sonic reading, the solenoid function and the temperature gage (purely just for ease of presentation purposes).

https://youtu.be/a8tL8i9ux5U

Here is a flow chart of our code and the code itself

SMART SHOWER HEAD

https://create.arduino.cc/editor/liamhoppy/807fad4f-ae5a-41b3-a697-74c7fc421496/preview?embed

Analysis

Seeing as the most power consuming part of our circuit is the solenoid valve, we will base our calculations upon this. The Arduino itself and the sensors do not take up a lot of power, therefore, in comparison to the solenoid valve they are negligible.

From looking at the specs on the solenoid valve we are using, we can see that it takes 8.5 watts of power. The solenoid valve only consumes power when the valve is open (when someone is standing under the shower and when the water is running cold)

Taking results from the earlier background research we can analyse whether our product will save more energy than it consumes.

Average shower time – 10mins

Average time away from water – 2.1mins

Average time under water – 7.9mins

Average heating up time – 48.1s

Time spent with the solenoid open = (7.9*60) +48.1 = 522.1 seconds of 8.5 watts

Energy = Power x Time. Therefore 8.5 * 522.1 = 4437.85 Joules (J)

4437.85J = 0.0012327361111 kWh or 1.23×10^-3 kWhs

The wastage we are saving (in energy alone) is 0.33kWh per shower – therefore, adding in the energy cost of our product – it will save you 0.329kWhs per shower, 120kWhs per year and 480kWhs per household per year

To properly analyse the data we took from our earlier survey, we took a look at two specific candidates; one that wasted a lot of water and one that didn’t waste much at all. As this survey was anonymous the names have been fabricated.

cartoon lasyChloe

Age: 18-24

Sex: Female

Time taken for shower to warm up: 30 seconds

Activity done whilst waiting: Phone scrolling for 1 minute

Shower length: 17.5 minutes

Time spent out of the water: 5 minutes

Total time of water flow wasted: 5.5minutes (330 seconds)

77ml/s. (77*330 = 25410ml) 25.4l of water wasted per shower. Showering uses 1/480kWh in energy per second. (330*(1/480) = 0.69kWh per shower.

Year-long: (0.69*365 = 250.9kWh) (25.4*365 =9271l) (250.9*(18.01p per kWh) = 4518.7) (9271*(0.3p per litre) = 2781.3) (2781.3 + 4581.7 =  7363)

In a year, Chloe will save 259kWhs of energy, 9271 litres of water and £73.63 – Very cost and energy effective

middle ages lady


Jackie

Age: 45 – 54

Sex: Female

Time taken for shower to warm up: 120 seconds

Activity done whilst waiting: Brush teeth 2.5 minutes

Shower length: 9 minutes

Time spent out of the water: 0 minutes

Total time of water flow wasted: 30 seconds

77ml/s. (77*30= 107ml) 0.12l of water wasted per shower. Showering uses 1/480kWh in energy per second. (30*(1/480) = 0.06kWh per shower.

Year-long: (0.06*365 = 22.8kWh) (0.12*365 =43.8l) (22.8*(18.01p per kWh) = 410.6) (0.12*(0.3p per litre) = 0.036) (0.036+ 410.6 =  410.6)

In a year, Jackie will save 22.8Kwh of energy, 0.12 litres of water and £4.10 – Not very cost and energy effective

 Conclusion

Adding extra energy saving features to a shower head can dramatically reduce the environmental impact of taking a shower.

We would look to build this product into excising electric shower units; as they already contain solenoid valve and a power supply, only the shower head . Again, reducing the energy and material consumption of the product. It uses considerably less energy than the vast amount saved, especially in a house-hold which uses the shower 4 time daily.

 

Week 10 – Limbs and Things Model – Emily, Thomas and Lukasz

How best to model the design?

The group took time to consider the best route to take when displaying the design without losing any features of the design. We did some initial sketches to try and visualise the thoughts we were generating.

Capture3Our first thoughts were to encase each design in a rectangle casing, like a box almost. On reflection, after chatting to it within the group and with the lecturers, we realised that if we were to model the design in this way would be would lose the realism regards the products from Limbs and Things.

Model Sketches

plan

The sketch on the left shows how we were thinking of displaying the design on the plinth.

Key things we wanted –

Model speaks for itself

Neat wiring, however the Arduino on show

Display boards that were clear and concise
Capture5Capture2Capture4Capture1

#

 

 

 

These are the quick sketches we draw to have an idea of how the parts will all come together. We went with a polystyrene semi – cylinder tube, as we thought it was more representative of the human arm / leg. Each sensor has a different ‘limb’, this therefore ensures that the person viewing the display or using one of the sensors, won’t get confused with what the input and outputs are.

Model

After deciding on the polystyrene as the visual for the limb the student was assessing, we wanted to mount it in a position that again, was more realistic. Clear plastic piping allowed us to get the model in the position we wanted and to keep a crisp clean look. Some of the wiring could also be feed through the piping to keep it tidy. The plastic boxing at the front of the display is housing for the Arduino without the risk of wires being pulled lose or damage being done.

IMG_20180419_113710

 

Last job to do is to place the circuit into the model.

 

 

By  Emily Mortimore, Thomas Elwes, Lukasz Staszewski

 

Agriculture Water – Ali Rostam and Suleyman Akbulut

Over watering of agricultural fields is a problem that is happening all around the world. Globally agriculture usage of water takes up around 70 % of the worlds accessible fresh water. And with this countries are starting to reach there renewable water resource limits. This mainly comes down to poor watering systems and wrong methods of watering. A lot of it is as well as crops are being over watered. This is just not a waste of water it can also cause damage to plants. If watered too much plants can drown or salt crystals can form on the surface of the soil which can cause harm to the plants and makes it hard for the ground to be fertile.

Image result for over watering of agriculture fields

The aim of our project is to prevent the over watering of the large agricultural fields. We wanted to design a product that could control how much water the plants get and that they only get the amount they need. No more no less! To achieve this we developed an arduino system with a soil moisture sensor and a solenoid valve which are connected to each other. The filed will have sensors at regular intervals through out the field, which will send the readings of the moisture in the soil to the arduino micro controller. Through the micro controller solenoid valve receives the soil moisture readings. If there is not enough moisture in the soil then the solenoid will release water until the moisture sensor reads that the plant has enough water. The solenoid will release the water for set times until there is enough moisture in the soil for the plant.

 

Step 1 Moisture Sensor

Crop

The first thing we did was set up the moisture sensor and to test. We tested the sensor so we could make sure we were getting the correct readings of the soil and that we knew what values the soil would be for which state it was in. The way we tested the Moisture sensor was by setting up in different soils which all had different moister levels in it. After we had the results we would then use them in the code.

Step 2 Solenoid valve

SparkFun Hardware Solenoid Valve 12V  - 3/4"

The next thing was setting up the solenoid valve to work when the moister sensor read that the soil needs more water. So from the results we got from the moisture sensor we set up the code on the arduino to have thresh holds that would make the solenoid valve turn on when there is not enough water in the soil.

Step 3 Setting up the LED’s

Moisture Level Measurement

 

After we got the moister sensor and the solenoid working we looked into ways of showing the moisture from the circuit. So we set up a LED bar graph that indicates how much moisture the soil has. There are 5 LED’s one if all five are on then the plant has the perfect amount of water. If none are on then the moister level is too low and the solenoid will turn on to allow water to flow to the crops.

After this we then set up the code. We took the values we got from the moister sensor and implemented them into the code. We had to set up the code that the moisture senor would control when the solenoid valve would turn on and turn off. And for the LED’s to show what the moister levels are.

 

int rainPin = A0;
int solenoid = 7;
int sensorValue;
// you can adjust the threshold value
int thresholdValue = 1050;
int thresholdValue1 = 1000;
int thresholdValue2 = 850;
int thresholdValue3 = 700;
int thresholdValue4 = 550;
int thresholdValue5 = 400;

void setup() {
for(int i=2; i<=6; i++){ // sets up LEDs from pin 2 to pin 6
pinMode(i,OUTPUT);
}
pinMode(rainPin, INPUT);

pinMode(7, OUTPUT);// connected to S terminal of Relay;
Serial.begin(9600);
}

void loop() {
// read the input on analog pin 0:
sensorValue = analogRead(rainPin);
Serial.println(sensorValue);
checkMoisture(thresholdValue, LOW, 2, 6);
checkMoisture(thresholdValue1, HIGH, 2, 2); //checks moisture(your threshold value, LED HIGH or LOW, starting LED pin, ending LED pin)
checkMoisture(thresholdValue1, LOW, 3, 6);
checkMoisture(thresholdValue2, HIGH, 2, 3);
checkMoisture(thresholdValue2, LOW , 4, 6);
checkMoisture(thresholdValue3, HIGH, 2, 4);
checkMoisture(thresholdValue3, LOW, 5, 6);
checkMoisture(thresholdValue4, HIGH, 2, 5);
checkMoisture(thresholdValue4, LOW, 6, 6);
checkMoisture(thresholdValue5, HIGH, 2, 6);

if(sensorValue < thresholdValue){
digitalWrite(7,HIGH);// turn relay ON;
}
else {
digitalWrite(7, LOW);// turn relay OFF;
}
delay(2000);
}

void checkMoisture(int threshold, bool ledLevel, int startingPin, int endingPin) { //checks moisture(your threshold value, LED HIGH or LOW, starting LED pin, ending LED pin)
if(sensorValue < threshold) {
for (startingPin; startingPin<=endingPin; startingPin++){
digitalWrite(startingPin,ledLevel);
}
}

}

 

We set up the curcuit of the board to the correct way. fritzing chart-APRIL 19

Because we needed a 12v power supply for the solenoid valve but we wanted to control it with the arduino which only runs at 5v we had to use a relay. The relay allows the switch between the power supplies with out over loading the board.

Flow Chart Capture A18

We set up the circuit and and code and tested to see if the model would work.

Are aim for this project was to lower the amount of water wasted in agricultural fields and try and make them as sustainable as possible. We have tried to do this by monitoring how much water is in the soil and when it needs to be watered and when it does not. We have done this by using a moisture sensor to read the moisture in the soil and a solenoid valve to control when to release the water to the plants.

With the model we made there was a couple of restrictions. the solenoid valve we used needs a mains water supply or a water supply with pressure behind it to push the water through. And because for are mini model we used a water bottle that the  pressure was gravity fed, there was not enough pressure to push a lot of water through at once and it only dribbled out slowly. This model is designed for a large scale design. So we designed it that it would be used with a mains water supply behind it to give more pressure.

By having this product it would help with the over watering problem as it would only water the plants when they need to be watered and not until then. There would be no over watering and would save a lot of time, money and water that is getting more and more reserved.

Final Design for Sustainability Project

The Project;

The aim of this project is to prevent the  over watering of the large agricultural fields. To achieve this we developed an Arduino system with soil moisture sensor and solenoid valve which are connected to each other. The agricultural field has sensors at regular intervals throughout the field which send the soil moisture data to the Arduino microcontroller. Through the microcontroller solenoid valve receives the soil soil moisture  data  and releases enough water to replenish the moisture in soil for a set of time. This process continues until the soil have enough water for the crop.

We strongly believe this system will help to reduce the over watering of crops and therefore save water and produce higher, healthier yield.

These improvements to water usage will lead to greater Sustainability.

Coding of the Project;

int rainPin = A0;
int solenoid = 7;
int sensorValue;
// you can adjust the threshold value
int thresholdValue = 1050;
int thresholdValue1 = 1000;
int thresholdValue2 = 850;
int thresholdValue3 = 700;
int thresholdValue4 = 550;
int thresholdValue5 = 400;

void setup() {
for(int i=2; i<=6; i++){ // sets up LEDs from pin 2 to pin 6
pinMode(i,OUTPUT);
}
pinMode(rainPin, INPUT);

pinMode(7, OUTPUT);// connected to S terminal of Relay;
Serial.begin(9600);
}

void loop() {
// read the input on analog pin 0:
sensorValue = analogRead(rainPin);
Serial.println(sensorValue);
checkMoisture(thresholdValue, LOW, 2, 6);
checkMoisture(thresholdValue1, HIGH, 2, 2); //checks moisture(your threshold value, LED HIGH or LOW, starting LED pin, ending LED pin)
checkMoisture(thresholdValue1, LOW, 3, 6);
checkMoisture(thresholdValue2, HIGH, 2, 3);
checkMoisture(thresholdValue2, LOW , 4, 6);
checkMoisture(thresholdValue3, HIGH, 2, 4);
checkMoisture(thresholdValue3, LOW, 5, 6);
checkMoisture(thresholdValue4, HIGH, 2, 5);
checkMoisture(thresholdValue4, LOW, 6, 6);
checkMoisture(thresholdValue5, HIGH, 2, 6);

if(sensorValue < thresholdValue){
digitalWrite(7,HIGH);// turn relay ON;
}
else {
digitalWrite(7, LOW);// turn relay OFF;
}
delay(2000);
}

void checkMoisture(int threshold, bool ledLevel, int startingPin, int endingPin) { //checks moisture(your threshold value, LED HIGH or LOW, starting LED pin, ending LED pin)
if(sensorValue < threshold) {
for (startingPin; startingPin<=endingPin; startingPin++){
digitalWrite(startingPin,ledLevel);
}
}

}

Fritzing Chart of The Project

 

fritzing chart-APRIL 19

 

Photos of the Project;

 

Moisture Level Measurement

 

portfol-1

Solenoid System

Sensor-Soil Moisture

Tab-Solenoid

Water Tank

Video of the Project; Testing the Solenoid Valve

Testing of the solenoid Valve

 

Testing of the system

 

SMART BLINDS 12 – Stepper Motor Integration & Prototype

Setup: Same as last 2 blogs but with motor driver signal pins plugged into logic board (left):

fritzing.PNG

This is our current wiring. Unfortunately we ran into a few problems with our arduino running out of memory. The Arduino on the left is responsible for all the logic, this takes up a substantial amount of code, over 430 lines!! The meant that we hit over 93% memory usage before even integrating the code for the stepper motor. As seen here:memoryerror

our next stage is to try and reduce memory usage so we can add in the stepper motor to our logic board. Even the Simplest motor code takes over 10% of memory to function. We estimate around a further 15% will need to be freed up for our use case.

User interface improvements:

While we were working on this i also changed the code so that when the user changes wither the mode or user temp then it would output this to the LCD. Then when the next set of temps comes round it defaults back to displaying the In and Out temperature readings. This means that after initial set-up the arduino can run quite happily by itself, independent of any PC.

usermodeuser temp

Working prototype:

This is our final Working prototype! We integrated our existing code used in the stepper motor blog before and ran into a few problems, however after some tinkering and adding of some new code:Newcode

We were able to get the motor runing when it was suppose to! as seen here:

The next stage was to mount the motor to our ‘window frame’  and test to see if it could pull the blind. we used a 2nd hand blind found for free on the internet.

Final Model.jpg

Below is the mounting for the motion sensor and the LDR. Thermo sensors were mounted at the top of the frame as shown in picture above.

motion.jpg

Final Code:


 

// First we include the libraries
#include 
#include 
#include 
#include 

#define ONE_WIRE_BUS A5

const int stepsPerRevolution = 360; // Number of steps
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// Assign the addresses of the 1-Wire temp sensors.
DeviceAddress TempIn = { 0x28, 0xFF, 0x3A, 0xAB, 0xC2, 0x17, 0x04, 0xB3 };
DeviceAddress TempOut = { 0x28, 0xFF, 0x16, 0xA5, 0xC3, 0x17, 0x05, 0x8A };

LiquidCrystal lcd(13, 12, 7, 6, 5, 4);

const int Interval = 10000;
unsigned long previousMillis = 0;

 

#define LDR A0
#define PIR A1
#define LeftSwitch 2
#define RightSwitch 3

int LDRRead = 0;
int PIRRead = 0;

int userTemp = 0;
float InsideTemp = 0;
float OutsideTemp = 0;

bool BlindOpen = true;
int BlindState = 0;
int Set_Mode = 2;
bool SetUpComplete = false;

bool UserInRoom = false;
bool Night = false;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Smart Blind Version 0.420");
// Start up the library
sensors.begin();
sensors.setResolution(TempIn, 10);
sensors.setResolution(TempOut, 10);
lcd.begin(16, 2);
lcd.setCursor (0, 0);
lcd.print("SmartBlind v4.20");
lcd.setCursor (0, 1);
lcd.print("Initializing...");
pinMode(LDR, INPUT);
pinMode(PIR, INPUT);
delay(1500);
pinMode(LeftSwitch, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(LeftSwitch), LeftDigit, FALLING);
pinMode(RightSwitch, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(RightSwitch), RightDigit, FALLING);

myStepper.setSpeed(42); // set the speed at 60 rpm:

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void loop(void) {

if (SetUpComplete == false) {

ModeChoice();
Serial.println();
SetTemp();
Serial.println();
SetUpComplete = true;
}
else {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > Interval) {
previousMillis = currentMillis;

 

if (Set_Mode == 1) {
Serial.println();
Serial.println("----------------------Start Of Sensing----------------------");
//PIR_Sense();
//NightOrDay();
CallTemp();
AssignTemp();
LcdPrintTemp();
SavingsMode();
ForwardOrBackwards();
}
if (Set_Mode == 2) {
Serial.println();
Serial.println("Smart Mode");
PIR_Sense();
NightOrDay();
CallTemp();
AssignTemp();
LcdPrintTemp();
SmartMode();
ForwardOrBackwards();
}
if (Set_Mode == 3) {
SetUpComplete = false;
}

}
else {
Serial.print("");
}

}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void ForwardOrBackwards (){
Serial.println(BlindOpen);
Serial.println(BlindState);
if ((BlindOpen == true) && BlindState == 1) {}
if ((BlindOpen == true) && BlindState == 0) {
myStepper.step(stepsPerRevolution);
BlindState = 1;
}
if ((BlindOpen == false) && BlindState == 1) {
myStepper.step(-stepsPerRevolution);
BlindState = 02
231;
}
if ((BlindOpen == false) && BlindState == 0) {}

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void LeftDigit ()
{ if (SetUpComplete == false) {}
if (SetUpComplete == true) {
Set_Mode = Set_Mode + 1;
Serial.print(Set_Mode);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("User Mode: ");
lcd.print(Set_Mode);
if (Set_Mode > 1 ) {
Set_Mode = 0;
}
else {}
}
}

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void RightDigit ()
{
if (SetUpComplete == false) {
}
if (SetUpComplete == true) {
userTemp = userTemp + 1;
Serial.println(userTemp);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("User Temp: ");
lcd.print(userTemp);
if (userTemp > 38) {
userTemp = 10;
}
else {}
}
}

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void SmartMode() {

//----------------------------------------Scenario 1: Warming----------------------------------------

if ((((InsideTemp < userTemp) && InsideTemp < OutsideTemp) && UserInRoom == false) && Night == false)
{
Serial.print("Day: Inside is Too Cold, Outside is Warmer - Opening blinds to let in heat");
Serial.println();
BlindOpen = true;
// BlindState = 1;
}
if ((((InsideTemp < userTemp) && InsideTemp < OutsideTemp) && UserInRoom == true) && Night == false)
{
Serial.print("User in room during Day: opening blinds for light");
Serial.println();
BlindOpen = true;
// BlindState = 1;
}
if ((((InsideTemp < userTemp) && InsideTemp < OutsideTemp) && UserInRoom == false) && Night == true)
{
Serial.print("Night: Inside is Too Cold, Outside is Warmer - Opening blinds to let in heat");
Serial.println();
BlindOpen = true;
// BlindState = 1;
}
if ((((InsideTemp < userTemp) && InsideTemp  userTemp) && InsideTemp  userTemp) && InsideTemp  userTemp) && InsideTemp  userTemp) && InsideTemp < OutsideTemp) && UserInRoom == true) && Night == true)
{
Serial.print("Night: User in room: Closing blinds for privacy");
Serial.println();
BlindOpen = false;
// BlindState = 0;
}

//----------------------------------------Scenario 3: Too Cold----------------------------------------

if ((((InsideTemp  OutsideTemp) && UserInRoom == false) && Night == false)
{
Serial.print("Day: Inside is Too Cold, Outside is Cooler: Closing blinds to save heat");
Serial.println();
BlindOpen = false;
// BlindState = 0;
}
if ((((InsideTemp  OutsideTemp) && UserInRoom == true) && Night == false)
{
Serial.print("Day: User in room during Day: opening blinds for light");
Serial.println();
BlindOpen = true;
// BlindState = 1;
}
if ((((InsideTemp  OutsideTemp) && UserInRoom == false) && Night == true)
{
Serial.print("Night: Inside is Too Cold, Outside is Cooler: Closing blinds to save heat");
Serial.println();
BlindOpen = false;
// BlindState = 0;
}
if ((((InsideTemp  OutsideTemp) && UserInRoom == true) && Night == true)
{
Serial.print("Night: User in room: Closing blinds for privacy");
Serial.println();
BlindOpen = false;
// BlindState = 0;
}

//----------------------------------------Scenario 4: Cooling----------------------------------------

if ((((InsideTemp > userTemp) && InsideTemp > OutsideTemp) && UserInRoom == false) && Night == false)
{
Serial.print("Day: Inside is Too Hot, Outside is Cooler: Opening blinds to let out heat");
Serial.println();
BlindOpen = true;
// BlindState = 1;
}
if ((((InsideTemp > userTemp) && InsideTemp > OutsideTemp) && UserInRoom == true) && Night == false)
{
Serial.print("Day: User in room during Day: opening blinds for light");
Serial.println();
BlindOpen = true;
// BlindState = 1;
}
if ((((InsideTemp > userTemp) && InsideTemp > OutsideTemp) && UserInRoom == false) && Night == true)
{
Serial.print("Night: Inside is Too Hot, Outside is Cooler: Opening blinds to let out heat");
Serial.println();
BlindOpen = true;
// BlindState = 1;
}
if ((((InsideTemp > userTemp) && InsideTemp > OutsideTemp) && UserInRoom == false) && Night == true)
{
Serial.print("Night: User in room: Closing blinds for privacy");
Serial.println();
BlindOpen = false;
// BlindState = 0;
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void SavingsMode() {
if ((InsideTemp < userTemp) && InsideTemp  userTemp) && InsideTemp < OutsideTemp)
{
Serial.print("*Inside is Too Hot, Outside is Warmer: Closing blinds to reduce heat transfer*");
Serial.println();
BlindOpen = false;
// BlindState = 0;
}
if ((InsideTemp  OutsideTemp)
{
Serial.print("*Inside is Too Cold, Outside is Cooler: Closing blinds to save heat*");
Serial.println();
BlindOpen = false;
// BlindState = 0;
}
if ((InsideTemp > userTemp) && InsideTemp > OutsideTemp)
{
Serial.print("*Inside is Too Hot, Outside is Cooler: Opening blinds to let out heat*");
Serial.println();
BlindOpen = true;
// BlindState = 1;
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void ModeChoice () {
if (SetUpComplete == false) {
Serial.println();
Serial.print("Do you want 'Smart' mode [2] Or 'Maximum Savings' mode? [1]... ");

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Smart / Savings?");

while (Serial.available() == 0) {}
if (Serial.available() > 0) {
Set_Mode = Serial.parseInt();
Serial.print(Set_Mode);
lcd.clear();
}
}
// else {
// if (Set_Mode == 2) {
// Serial.println();
// Serial.println("Manual Mode Enabled:");
// lcd.clear();
// }
if (Set_Mode == 2) {
Serial.println();
Serial.println("Smart Mode Enabled:");
lcd.clear();
}
if (Set_Mode == 1) {
Serial.println();
Serial.println("Savings Mode Enabled:");
lcd.clear();
}
}

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void PIR_Sense () {
PIRRead = digitalRead(PIR);
if (PIRRead == HIGH) {

Serial.println("----------------------Start Of Sensing----------------------");
Serial.println("Motion detected!");
UserInRoom = true;

}
else {
Serial.println("----------------------Start Of Sensing----------------------");
Serial.println("Motion stopped!");
UserInRoom = false;
}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void NightOrDay () {
LDRRead = analogRead(LDR);
if (LDRRead  0) {
userTemp = Serial.parseInt();
Serial.print(userTemp);
lcd.clear();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void printTemperature(DeviceAddress deviceAddress)
{

float tempC = sensors.getTempC(deviceAddress);

if (tempC == -127.00)
{
Serial.print("Error getting temperature ");
}
else
{
Serial.print(tempC);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void CallTemp() {
Serial.println();
Serial.println("Getting temperatures... ");
Serial.println();
sensors.requestTemperatures();
Serial.print("Inside Temp in Degrees C: ");
Serial.println();
printTemperature(TempIn);
Serial.println();
Serial.print("Outside Temp in Degrees C: ");
Serial.println();
printTemperature(TempOut);
Serial.println();

}

Week 9 – Limbs and Things Final Products – Thomas, Emily and Lukasz

Vibration Model Test:

Made sure the vibration module could detect the vibration of the plasters being removed from the model and that it would output the sound at the appropiate time (Sound for when the bandages are removed too slowly)

received_605539333138445.jpeg

Pressure Model Test:

The pressure sensor should be able to detect the pressure applied to the surface, beneath the model. The servo attached should also react with the pressure and “twitch” the model visably.

Pressure

Swipe Model Test:

The photoresistors should be open to light and be able to be swiped smoothly. There should not be any interferance either

LRD

All the codes combined to work on a single Arduino Uno:

Link to code

IMG_20180419_113710

BLOOD LEVEL SENSOR WAS DROPPED

By ThomasElwes, Emily Mortimore and Lukasz Staszewski

SMART BLINDS 11: functioning logic & User Modes.

In this blog we will be going through our code so far, and explaining the choices and variables that will affect the output of the code.

Components:

1 x Arduino Uno

1 x l298n stepper motor driver

1 x  Stepper motor (17HD34008-22B)

1 x 9V battery

1 x LCD

1 x PIR sensor

2 x Momentary buttons

2 x Thermisters

1 x LDR

1 x Variable Resistor

Jumper cables.

Diagram:

 

Real World:

 

Code:Variables

Above is the Variables and Initialisation for our Libraries.

  • “OneWire” is responsible for data readings from our Temp sensors. Using OneWire also allows us to run 2 Temp sensors off of the same pin on the Arduino.
  • “DallasTemperature” allows for the conversion of raw data from the Temp Sensors, and outputs in degrees C or F.
  • “LiquidCrystal” Runs our 2 x 16 LCD display.

 

  • Next we start to assign values to our Temp sensor pin A5. Then pas the OneWire values to DallasTemperature for conversion so it knows where to look.
  • We assign DeviceAdresses to each of the Temp sensors, each has its own unique interal callsign. We found these by writing a program stated in an earlier blog.
  • Next is to tell our arduino which pins to output for the LCD display.
  • Finally we get to the integers, floats and boolean variables that make our logic run. The most imprtant is probably “BlindOpen” this is the boolean that will tell the arduino whether or not the blinds are open / clossed.

 

Below is the Setup:

Here we assign the resolution of our temp sensors to 10 bit. We begin our LCD, print our messages to the LCD. And finally define our button interupts to pins 2 & 3. (The only 2 pins on the arduino that can run the interrupt function).setup.jpg

Loop: 

This is the most important part of the code. We have used many different functions (which i will go through in a second) and simply call on them when needed. This way of doing it can save valuable memory space as you don’t have to re-write the same code every time you want to use it. LOOP

Getting Rid of Delay:
There used to be a delay in the loop that would refresh the temps every 6000 millis, however we got rid of this as it hung up the code and made the inputs buggy. Instead we measure time past with current time and if it is over 6000 milliseconds then it will refresh the temps. This frees up the code to do other things and allows multi-tasking.

  • It is worth noting that there are 2 discrete “Modes” functioning in this Code. The first of which is:

Savings Mode: This is the simplest of the 2 modes and allows the decisions that will result in the most energy savings for your house. However it does not take into account whether or not the user is in the Room or if it is Night or day. This mode would be useful if you knew you were going to be out all day. or perhaps went on holiday.Savignsmode

Smart Mode: This mode takes into account 5 different variables in order to make an informed guess as to whether or not the blinds should be open or closed. We measure Inside, Outside and the user desired Temperatures. Then cross reference that with if the user is in the room and if the time of day is say or night. WE feel that this gives us enough information to get the blinds to be fully automated.Smart mode

Smartmode2

smartmode3

Next we have our interrupt code. The top on cycles through the mods and the other adjusts the user temp. This allows of full functionality of the arduino without a connected PC. We were going to use a Keypad but it started outputting characters not in the english language and even when we weren’t touching the pad!! so we opted to simplify the input methods. Also this allowed us to free up 12% of the arduino memory, which is important as we would have run out otherwise.

 

Below is the code that determins if the arduino needs to be set up. If Setup has not been run before the arduino will ask the user which mode they want to be in. else it will output the mode it is currently set to in the serial monitor.

modechoie

Next up we have the USP of our blinds. We measure if the user is in the room or not and then what time of day it is. This allows us to keep the user privacy at night and let in light during the day, but ONLY when there is a user in the room, otherwise it will do whats best for the energy savings.PIRNIGHTDAY

Below we have the code that outputs the Temperatures to the LCD screen, this is important as it allows the user to monitor what is going on with temps and then make an informed decision based on that. Also we have ‘AssignTemp’ here we take the readigns from the tempreature sensors and assign them to variable integers. This allows us to compare them and output decisions. without this code we could not do this as the temp sensors output in weird ways. Next is ‘SetTemp’ this allows the user to input the tempreature they want the room to be. we use the serial monitor for this. If the user inputs nothing this function will not let the arduino do anything until there is a value assigned to this variable.LCDprint ASSIGNTEMP Settemp

Last but not least we have the functions that actually measure and write the temperatures from the sensors. We included an error message when the sensor reads -127 degrees C as this normally means that the wires are not plugged in correct. ‘Call temp’ uses simple comands to output the Temps to the Serial monitor.

Serial monitor:

Here i put my hand on the inside temp sensor to simulate a warm house and in the 2nd set of temps i put my hand over the LDR to simulate night. You can see the outputs change dependent on the variables.

Capture

Video Demonstration:

Week 7 – Display model – Josh Milkins & Richard Channing

This week our aim was to get our prototype to a point where it could be displayed while showing off its functionality.

We wanted to keep it simple so that it could display the different types of lighting found in the Warwick arms. We purchased a simple desk lamp and some smaller LED lights representing the ceiling lights and ambient wall lighting respectively.

PROTOYPE 3

No lights on

Main &amp; Wall On

Main and wall lights on

Main On

Main light on, wall lights off

Wall On

Main light off, wall lights on

 

Only 2 of the relays are in use for the model, representing section one, but the code will still work for sections two, three and four but the only visual feedback is an audible click and an illuminated LED from the respective relay.

The first relay switches the main light with the command “alexa, turn on section one main lights”

The second relay switches the wall lights with the command “alexa, turn on section one main lights.

The remaining relays can be activated using the command “alexa, turn on section (2, 3 or 4) (main/wall) lights”

 

The Node MCU, Relay module and amazon echo are positioned to the side of the model to show how it works as well as enabling the user to see the relays actuate when commands are given.

Smart Kettle – Prototype

 

The idea:


IMG_20180419_0001.jpg

1 = User blows into straw 1 which is fed into Flow sensor 1 in order to mimic water being poured into the kettle.

2 = User blows into straw 2 which is fed into Flow sensor 2 in order to mimic water being poured out the kettle.

This prototype deliberately uses no water. This is because i did not want to risk the potential of water damaging the components while it is out on display for people to use.

Substituting Air for Water still allows the flow sensors to collect data and can be used to show that the LCD, buzzer and LEDs all function as they should.

 

20180419_124551.jpg

20180419_124604.jpg

20180419_124613.jpg

20180419_124617.jpg

20180419_124622.jpg