Tuesday, November 27, 2012

Moving Water!

Our pump officially works! We have moved water from one cup to another!  We got more flexible tubing to make the pumping easier for the motor and we figured out how to power the motor correctly.  Our biggest challenge right now is making a housing for the pump that locks the motor in place.

Tuesday, November 13, 2012

Sensors Controlling Sensors

Now our moisture sensor controls when to power the motor to turn the peristaltic pump. It works!

Thursday, November 8, 2012

Pump Assembly!



We've been working really hard on the pump, so here's an update!

This Monday, Sam machined our parts for our motor, so we were all set to put the pieces together! She made an arm to hold the bearings, two shoulder bolts, and a shaft to put over the motor.  


This Thursday we were finally able to put everything together and test it! Here's Gracie getting the motor ready to run for our first test.  



Unfortunately, we have to make a few adjustments to the pump before it will work, but it's on its way! Our pump was able to spin the bearings without the tubing, but with the tubing in place it was not strong enough.  This may be for several reasons.  One thing we're going to look at is whether we're giving the motor enough current.  Second, we're going to get some different tubing that is a little less stiff so that there is less resistant against the motor.  Hopefully by the end of this weekend we should have some of these motors addressed.

Don't forget to water your plants today!

Wednesday, November 7, 2012

More Electrical Things!

DC Motor Controller!
With this little setup we can power the peristaltic pump when the moisture sensor sense that the water level is low in the plant pot. Just working on making the software side integrated!

Monday, October 29, 2012

Moisture Sensor Tested in Soil: Success!

Before today, we had only tested the leads in air (touching and not touching). Today we tested the moisture sensor in soil with varying degrees of water added. The test confirmed that the system is functional. The values that we obtain from the arduino (via serial) are as follows:

In air, not touching: ~0
In air, touching: ~1023
In soil,
--very wet: ~900
--optimal: 700-800
--needs water: ~650
--definitely needs water: <625

Leads (moisture sensor) in soil.

Python code to do something with the values read from serial is given below:
#import libraries
import serial
import math

#open serial communication
arduino = serial.Serial('/dev/ttyACM0', 9600)

if serial.Serial.inWaiting >= 5:
#control corresponds to 100% light transmittance (in absence of any #petri dish); each respective sample reading corresponds to the light #transmittance through that petri dish.
    val1       = float(arduino.readline())
    val2       = float(arduino.readline())
    val3       = float(arduino.readline())
    val4       = float(arduino.readline())
    val5       = float(arduino.readline())

#calculate soil moisture reading
moistureValue = float((val1 + val2 + val3 + val4 + val5)/5)

if moistureValue < 625:
    print("omg so thirsty so thirsty need water")
elif moistureValue > 625 and moistureValue < 700:
    print("I'm starting to get thirsty")
elif moistureValue > 700 and moistureValue < 800:
    print("I feel so hydrated!")
elif moistureValue > 800:
    print("Gross, I feel bloated")

#print out absorbance values in neat table     
print "moisture value: " + str(moistureValue)




Parenting Style mode selector complete and integrated with moisture sensor

The mode selector is now complete! The button switches through the three LEDs (modes). After five seconds, the LED fades away to a dim setting so that we can conserve power in the long run.

Cleaned-up LED and pushbutton system.

The last step will be to clean up the code (for modularity).

Arduino code for the LED system integrated with the moisture sensor reading is given below:

//initialize constants
const int buttonPin = 2;
const int LED1 = 11;
const int LED2 = 10;
const int LED3 = 9;
const int moistureSensor = 0;
const unsigned long deBounceDelay = 200;
const unsigned long moistureDelay = 5000;

//initialize variables
int buttonState = 0;
int lastButtonState = 0;
int mode=1;
int fadeValue;
int moistureReading = 0;
unsigned long deBounceTimer = 0;
unsigned long moistureTimer = 0;
unsigned long startTime;

//set-up interrupt

void setup() {
  //initialize each of the three LED pins as outputs
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
 
  //initialize the pushButton pin as an input
  pinMode (buttonPin, INPUT);
 
  //initialize serial communication; mid-range data rate 9600 bps
  Serial.begin(9600);
 
  //attachInterrupt(0, off, RISING);
}

void loop() {
  buttonCheck();
  switch (mode) {
    case 1:
      off();
      digitalWrite(LED1, HIGH);
      startTime = millis();
      fadeValue = 255;
      while(mode==1) {
        buttonCheck();
      readMoisture(); 
        if((fadeValue>55)&&((millis()-startTime) > 5000)) {
          for(fadeValue = 255; fadeValue >=50; fadeValue -=5) {
           analogWrite(LED1, fadeValue);
          delay(30);
          }
        }
      }
      break;
     
    case 2:
      off();
      digitalWrite(LED2, HIGH);
      startTime = millis();
      fadeValue = 255;
      while(mode==2) {
        buttonCheck(); 
        readMoisture();
        if((fadeValue>55)&&((millis()-startTime) > 5000)) {
          for(fadeValue = 255; fadeValue >=50; fadeValue -=5) {
           analogWrite(LED2, fadeValue);
          delay(30);
          }
        }
      }
      break;
     
    case 3:
      off();
      digitalWrite(LED3, HIGH);
      startTime = millis();
      fadeValue = 255;
      while(mode==3) {
        buttonCheck(); 
        readMoisture();
        if((fadeValue>55)&&((millis()-startTime) > 5000)) {
          for(fadeValue = 255; fadeValue >=50; fadeValue -=5) {
           analogWrite(LED3, fadeValue);
          delay(30);
          }
        }
      }
      break;
  }
}

void buttonCheck() {
  buttonState = digitalRead(buttonPin);
 
  if (!buttonState&&lastButtonState&&(millis()-deBounceTimer)>deBounceDelay){
    mode++;
    if(mode>3)mode=1;
    lastButtonState = buttonState;
    deBounceTimer = millis();
  }
 
  if (buttonState&&!lastButtonState&&(millis()-deBounceTimer)>deBounceDelay){
    lastButtonState = buttonState;
    deBounceTimer = millis();
  }
}

void readMoisture() {
  if ((millis()-moistureTimer)>moistureDelay){
    moistureReading = analogRead(moistureSensor);
    moistureTimer=millis();
    Serial.print("moisture sensor reads ");
    Serial.println( moistureReading); 
}
}
 

void off() {
  digitalWrite(LED1, LOW);
  digitalWrite(LED2, LOW);
  digitalWrite(LED3, LOW);
}

Thursday, October 25, 2012

Parenting Style--Mode Switching working

We've modified the blinky lights lab in order to blink through three LEDs (one for each parenting style mode). What do we mean by parenting style? As previously posted, we want the user to be able to choose how often they are notified by the system. He or she will be able to choose one of the following modes:
* Hands-off
* Active
* Helicopter

Working blinky light system (switches through three lights for each button press).

The next step is to expand the functionality so that the LEDs dim over time (to save power in the long run). We are also in the process of creating a mini prototype to show how the system will look in the plastic body of our system.