Week 16 - Final Project Documentation (Plant Care System)

Plant Care System

by Team 3: Lina Storfors (2019319203) and Han Seoyeong (2016312108)
Interactive Art 2019, Sungkyunkwan University


The Plant Care System is designed to help people care for their potted plants by providing information about how much light the plant recieves and how much moisture its soil has. To do that, we used a photoresistor/photocell and a soil hygrometer detection module soil moisture sensor. The Arduino circuit looks like this:

First, (in Processing) the user picks what species of plant they have (as ideal light and moisture levels differ between plants). In our prototype you can choose between 3 different types, but if we were to develop this project more, we would of course include more types of plants.
After choosing the plant, the user is redirected to a page that shows how the soil moisture level is and the amount of sunlight it recieves, based on the needs of the specific plant.

The sensor values are showed in Processing on a sliding scale in 4 levels:
1. thirsty (soil is too dry)/dark (the plant recieves too little light)
2. good (the amount of light and moisture in the soil is good)
3. perfect (the amount of light and moisture in the soil is perfect)
4. too wet/too much (the soil is too wet or the light recieved is too intense)


We also included a happy/sad emoticon to make it possible to quickly see if the plant needs your attention or not; when both values are either 'good' or 'perfect', the emoticon is happy. However, when one or both of the values are thirsty/dark or too wet/too much, the emoticon is sad.

The code

Arduino:
int lightPin = A0;
int moisturePin = A1;
const int averageCount = 16;
float averageBuffer[averageCount];

void setup() {
Serial.begin (9600);
//pinMode(buttonPin, INPUT);
}

void loop() {
int lightVal = analogRead(lightPin);
int moistureVal = analogRead(moisturePin);
Serial.print(lightVal);
Serial.print(","); // use comma as delimiter/separator
Serial.print(moistureVal);
Serial.println();
delay(50); }


Processing:
import processing.serial.*;
Serial myPort;
int ligVal = 0;
int moistVal = 0;
int mode = 0;
/*mode
0 = first page
1 = cactus
2 = flower
3 = tree (fiddle leaf fig)
*/

int x = mouseX;
int y = mouseY;

void setup(){
size(1800,1000);
printArray(Serial.list());
String portname = Serial.list()[0]; // <- change the number according to your port setup
myPort = new Serial(this, portname, 9600);
myPort.bufferUntil('\n');
}

void mouseClicked(){
  x = mouseX;
  y = mouseY;
}

void draw(){
background(255,216,216);
PImage page;
PImage thirsty;
PImage good;
PImage perfect;
PImage tooWet;
PImage dark;
PImage good2;
PImage perfect2;
PImage tooMuch;
PImage sad;
PImage happy;

stroke(255);
strokeWeight(5);
noFill();
rect(50,100,1700,800);

//make first page
if(mode == 0){
page = loadImage("page.JPG");
page.resize(1000,600);
image(page, 350, 200);
}

//go to each main page
if( x >= 490 && x <= 632
    && y >= 409 && y <= 729){
    mode = 1;   
    }else if (x >= 788 && x <= 930
    && y >= 409 && y <= 729){
    mode = 2;
    }else if(x >= 1079 && x <= 1243
    && y >= 409 && y <= 729){
    mode = 3;}
    else{
      mode = 0;} 

//make cactus page
if(mode ==1){
stroke(255);
strokeWeight(3);
line(300,300,700,300);

  //about moisture sensor
  if (800 < moistVal && moistVal <= 1023){
    thirsty = loadImage("thirsty.PNG");
    thirsty.resize(200,300);
    image(thirsty,220,160);
  }  else if(580 < moistVal && moistVal <= 800){
    good = loadImage("good.PNG");
    good.resize(200,300);
    image(good,410,160);
  } else if(350 < moistVal && moistVal <= 580){
    perfect = loadImage("perfect.PNG");
    perfect.resize(200,300);
    image(perfect,600,160);
  } else{
    tooWet = loadImage("too wet.PNG");
    //tooWet.resize(300,300);
    image(tooWet,300,260);
  }

  //about light sensor
  stroke(255);
  line(300,500,700,500);
  if (900 < ligVal && ligVal <= 1023){
    dark = loadImage("dark.PNG");
    dark.resize(200,300);
    image(dark,220,350);
  }  else if(600 < ligVal && ligVal <= 900){
    good2 = loadImage("good2.PNG");
    good2.resize(200,300);
    image(good2,400,350);
  } else if(440 < ligVal && ligVal <= 600){
    perfect2 = loadImage("perfect2.PNG");
    perfect2.resize(200,300);
    image(perfect2,600,350);
  } else{
    tooMuch = loadImage("too much.PNG");
    //tooMuch.resize(300,300);
    image(tooMuch,300,450);
  }

   //happy smile
  if(440 < ligVal && ligVal <= 900
  && 350< moistVal && moistVal <= 800){
    happy = loadImage("happy.PNG");
    happy.resize(700,700);
    image(happy,900,150);
  }else
  { sad = loadImage("sad.PNG");
  sad.resize(700,700);
  image(sad,900,150);
  }
}

//make flower page
if(mode ==2){
stroke(255);
strokeWeight(3);
line(300,300,700,300);

  //about moisture sensor
  if (650 < moistVal && moistVal <= 1023){
    thirsty = loadImage("thirsty.PNG");
    thirsty.resize(200,300);
    image(thirsty,220,160);
  }  else if(512 < moistVal && moistVal <= 650){
    good = loadImage("good.PNG");
    good.resize(200,300);
    image(good,410,160);
  } else if(256 < moistVal && moistVal <= 512){
    perfect = loadImage("perfect.PNG");
    perfect.resize(200,300);
    image(perfect,600,160);
  } else{
    tooWet = loadImage("too wet.PNG");
    //tooWet.resize(300,300);
    image(tooWet,300,260);
  }

  //about light sensor
  stroke(255);
  line(300,500,700,500);
  if (900 < ligVal && ligVal <= 1023){
    dark = loadImage("dark.PNG");
    dark.resize(200,300);
    image(dark,220,350);
  }  else if(600 < ligVal && ligVal <= 900){
    good2 = loadImage("good2.PNG");
    good2.resize(200,300);
    image(good2,400,350);
  } else if(440 < ligVal && ligVal <= 600){
    perfect2 = loadImage("perfect2.PNG");
    perfect2.resize(200,300);
    image(perfect2,600,350);
  } else{
    tooMuch = loadImage("too much.PNG");
    //tooMuch.resize(300,300);
    image(tooMuch,300,450);
  }

   //happy smile
  if(440 < ligVal && ligVal <= 900
  && 256< moistVal && moistVal <= 650){
    happy = loadImage("happy.PNG");
    happy.resize(700,700);
    image(happy,900,150);
  }else
  { sad = loadImage("sad.PNG");
  sad.resize(700,700);
  image(sad,900,150);
  }



//make tree page
if(mode == 3){
stroke(255);
strokeWeight(3);
line(300,300,700,300);

  //about moisture sensor
  if (400 < moistVal && moistVal <= 1023){
    thirsty = loadImage("thirsty.PNG");
    thirsty.resize(200,300);
    image(thirsty,220,160);
  }  else if(300 < moistVal && moistVal <= 400){
    good = loadImage("good.PNG");
    good.resize(200,300);
    image(good,410,160);
  } else if(250 < moistVal && moistVal <= 300){
    perfect = loadImage("perfect.PNG");
    perfect.resize(200,300);
    image(perfect,600,160);
  } else{
    tooWet = loadImage("too wet.PNG");
    //tooWet.resize(300,300);
    image(tooWet,300,260);
  }

  //about light sensor
  stroke(255);
  line(300,500,700,500);
  if (900 < ligVal && ligVal <= 1023){
    dark = loadImage("dark.PNG");
    dark.resize(200,300);
    image(dark,220,350);
  }  else if(600 < ligVal && ligVal <= 900){
    good2 = loadImage("good2.PNG");
    good2.resize(200,300);
    image(good2,400,350);
  } else if(440 < ligVal && ligVal <= 600){
    perfect2 = loadImage("perfect2.PNG");
    perfect2.resize(200,300);
    image(perfect2,600,350);
  } else{
    tooMuch = loadImage("too much.PNG");
    //tooMuch.resize(300,300);
    image(tooMuch,300,450);
  }

   //happy smile
  if(440 < ligVal && ligVal <= 900
  && 250< moistVal && moistVal <= 400){
     happy = loadImage("happy.PNG");
    happy.resize(700,700);
    image(happy,900,150);
  }else
  { sad = loadImage("sad.PNG");
  sad.resize(700,700);
  image(sad,900,150);
  }
}}}

void serialEvent(Serial port)
{
String myString = myPort.readStringUntil('\n');
if (myString != null) {
// remove whitespaces (spacebar)
String trimmed = trim(myString);
// separate signals into multiple values with delimiter(comma)
String[] vals = split(trimmed, ',');

// makes sure we received all 2 values
if (vals != null && vals.length == 2){
println(vals[0] + " " + vals[1]);

// 1st value is light value
ligVal = int(vals[0]);
// 2nd valus is moistqure value
moistVal = int(vals[1]);
}
}
}

From idea to final version

Our inital idea looked like this:



We made some revisions before the final version (as it's presented here) was finished:
The third sensor
A third sensor was initially included. We planned to either use a microphone sensor, proximity sensor or IR distance sensor. The microphone sensor was considered because research have showed that talking to or playing music to plants can help them florish. It was also considered because we thought one of us had the sensor already, which we later discovered was not the case. Therefore we switched over to the proximity sensor, to measure how close the plant owner was to the plant when talking to it. However, we decided to remove this sensor as well as the proximity sensor we used was not very good; it was very finnicky and measured and didn't measure well beyond 16 cm. Our third and last option was the IR distance sensor which worked very well, but was also removed as the professor advised us that more than two sensors is very difficult to use for our skill level.

LED-lights
The LED lights was supposed to work in the same way as the smile emoticon: When all sensor values are good or perfect, the green light would light up. Otherwise, if one or all value was not good or perfect, the red light would light up. However, this was also removed as it felt uneccessary when the emoticon in the processing window already did the same thing.

Conclusion

What we have learned during this project is mainly how to get two sensor signals from arduino into to processing and using the values seperately. But it was also interesting to try so many sensors, most of them that we had not used before, and to make (most of) them work sucessfully.

What could be done to improve this project is to work on the design outside of the processing window; making a flower pot that has the light and moisture sensor built in and protects the breadboard from dirt from the plant and spilled water when watering it. What could also improve it would be to add an additional sensor; perhaps a temperature sensor? When doing research about how to care for the plant we bought we discovered that the temperature that you keep the plant in also affects it wellbeing. Therefore it could be good to include it as a part of the Plant Care System as well.

Kommentarer

Populära inlägg