Week 13: Final project idea & progress

For our final project, we (Lina Storfors and Han Seoyeong) want to make a Plant Care System that helps people who struggle to keep their plants alive take care of their plants. We will help them by having the Plant Care System in people’s homes - measuring the plant’s surroundings and inform and remind the plant owner of the plant’s needs.

This is how we want the result to look like:



Initally, we wanted to use 3 sensors:
Soil Hygrometer Detection Module Soil Moisture Sensor - detects moisture in soil, so that the Plant Care System can remind the plant owner to water the plant.
Photoresistor/Photocell - To detect how much sunlight the plant gets, and can warn the plant owner if the light is too intense or too dark for the plant.
Sound sensor - since research indicates that talking to plant or playing music can help plants grow. (Source)

We chose the sound sensor because we thought we had it; however, we didn’t. So we decided to use a Proximity sensor instead, to detect if the plant owner is close enough to the plant when talking to it.

This week we have been focusing on testing the sensors to see if and how we can make them work. We managed to get the photoresistor/photocell work well! We found code that we used to try the sensor here: https://blog.naver.com/nasu0210/221506801811 & https://pe7pe.blog.me/220684706943 and here is the code:

Arduino code:
void setup(){
Serial.begin(9600);
}

void loop(){
 int value = analogRead(A0);
 Serial.println(value);
delay(100);
}


Processing code:
import processing.serial.*;
int i;
Serial myPort;
float data;
public static int ON = 1;
public static int OFF = 0;

void setup(){
  size(1000,800);
  delay(3000);
 
  String portName = Serial.list()[0];
 
  println(Serial.list());
  myPort = new Serial(this, portName, 9600);
}

void draw(){
 
  background(255);
  if (data > 400){
  pushMatrix();
  translate(500 - (data/2),0);
  noStroke();
  ellipse(500,400,50,50);
  fill(240,140,100);
  popMatrix();
  }else
  { textSize(25);
    fill(255,0,0);
    text("Too much :(",width/2,height/2);;
 
  }
}
void serialEvent(Serial p) {
  String message = myPort.readStringUntil(10);
  if (message != null){
    print("Received: ");
    println(message);
    data = float(message);
  }
}


Here is how it worked for us:

The Soil Moisture Sensor also worked well! We used a paper cup with soil in it and put the sensor in the soil, and then gradually put water in to see how the value in the serial monitor changed. The value changed from 250 to close to 0 when pouring water in. We also found a code to try the sensor here: https://blog.naver.com/simjk98/221632217745 & https://www.dummies.com/computers/arduino/how-to-send-multiple-signals-from-the-arduino-to-processing/ and here is the code:

Arduino code:
void setup() {
  Serial.begin(9600);
  //pinMode(3,INPUT);
}

void loop() {
  int sensor_value = analogRead(A1);
  Serial.println(sensor_value);
  //Serial.println(digitalRead(3));
  delay(500);
}


Processing code:
import processing.serial.*;
int i;
Serial myPort;
float data;
public static int ON = 1;
public static int OFF = 0;

void setup(){
  size(1000,800);
  delay(3000);
 
  String portName = Serial.list()[0];
 
  println(Serial.list());
  myPort = new Serial(this, portName, 9600);
}

void draw(){
 
  background(255);
  if (data > 100){
  pushMatrix();
  translate(250 - data,0);
  noStroke();
  ellipse(500,400,50,50);
  fill(240,140,100);
  popMatrix();
  }else
  { ellipse(650,400,50,50);
    textSize(25);
    text("enough :)",600,450); 
  }
}
void serialEvent(Serial p) {
  String message = myPort.readStringUntil(10);
  if (message != null){
    print("Received: ");
    println(message);
    data = float(message);
  }
}


Here is how it works:

Proximity sensor
We had more struggles with the proximity sensor. We made the same circuit we learnt in class during week 10 but we didn’t get it to work as well as how it worked in class, despite double-checking and rebuilding the circuit several times and measuring in several different rooms and buildings.

Arduino Code (we recieved code from the professor to help with outliers in the results, but it doesn’t seem to have helped us much as we still get some outliers):

int trigPin = 7;    // Trigger
int echoPin = 8;    // Echo
long dist;

const int numReadings = 10;

int readings[numReadings];      // the readings from the analog input
int readIndex = 0;              // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average

void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }
}

void loop() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(5);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  long duration = pulseIn(echoPin, HIGH);

  dist = (duration/2) * 0.0343;

  //Serial.println(dist);
  //Serial.println(" cm");

  // subtract the last reading:
  total = total - readings[readIndex];
  // read from the sensor:
  readings[readIndex] = dist;
  // add the reading to the total:
  total = total + readings[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;

  // if we're at the end of the array...
  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;
  }

  // calculate the average:
  average = total / numReadings;
  // send it to the computer as ASCII digits
  Serial.println(average);

  delay(60);
}



What we learned about the sensor is that it's quite finicky - it’s easily affected by environment and temperature. The sensor also seems to be affected by the light in the room and color of the object in front of it, even though it shouldn’t work this way.

When placing a hand in front of the sensor, the sensor managed to sense the hand until it was about 16 cm away from the sensor, but not further  it would show a value around 3000 cm, as if it’s measuring the distance to the wall). But when covering the hand with the sleeve of my black sweater, the sensor would not sense the hand even though the hand was the same distance from the sensor as earlier. We think this might be because the color black is not particularly reflective, unlike white and brighter colors.

Larger objects also seemed to be detected better, as my beige laptop sleeve could be sensed by the sensor for up to around 35 cm on average, and up to around 45 cm when we also used the cellphone light shining directly towards the sensor. 

Given these results, the proximity sensor might not work as we have intended for our project (will it measure the distance of the face to the flower accurately?). We have decided that the Soil Moisture Sensor and Photocell are more essential to our project and we should focus on them foremost; if we have time left in the end, we can try and incorporate the Proximity Sensor (or another sensor to replace it).


Our next challenge will be to bring multiple signals to processing and make them control specific seperate things on the processing screen.
 


Kommentarer

Populära inlägg