GillyWeed

Made by Shrey Agrawal

UNLISTED (SHOWN IN POOLS)

The goal of the project is to enchant a plant and give a magical experience to users while interacting with the plant. This is a mock-up of GillyWeed - a fictional enchanted plant from the Harry Potter series.

0

Core Requirements: 

Components used:

Force Sensor: Force Sensor will be installed in the apparatus of watering the plant. When the user holds the button to water the plant, the force sensor will generate some output, usually greater than 1000 units. This activates the coded piezo play music and generates the effect that the plant is singing for the user. This acts as a positive reinforcement for the user and conditions it to water the plant. 

Temperature Sensor (TMP 36): This sensor is used to sense the temperature around the plant. All plants have a range of temperatures in which they can survive. To show the emotion of the plant feeling temperature, an RGB LED is used.
If the temperature is too cold, the RBG LED turns Blue
If the temperature is too hot, the RGB LED turns Red

If the temperature is optimum, the RGB LED turns Green. 

Soil Moisture Sensor: Sparkfun Soil Moisture sensor is used to sense the moisture in the soil. If the moisture level of the soil goes below a minimum threshold, then an LED blinks which indicate that plant needs water. This is deliberate to keep the human-plant interaction intact.

Connectivity Requirements: 

The connectivity is provided using the IFTTT platform. The plant sends text messages to the user about its status- if it's feeling hot/cold or thirsty. A thank you message is also sent after the user waters the plant. 

Approach:

The iterative approach of rapid prototyping and testing was used to build this project. Individual components were prototyped and tested before they were assembled into the final circuit. 

I started building and testing the individual sensors and estimating the range of operation for respective sensors. 

After the range was established, I went ahead with combining these different sensors and reached the final solution

Finally, it was connected to IFTTT to get real-time updates. 

Process:

Discovery: Researched different IoT based solutions for plants. 

Conceptualization: Decided the work-flow and desired functionality

Build: Made the circuit in small steps and added functionality

IFTTT: Connected plant to IFTTT and created applet to get real-time information 

Piezo: Added the desired tune to play when an event takes place. 

Testing: Tested the solution and calibrated to work.  

Technical Requirements:

Materials were used to complete the project. 

1. Piezo 
2. fsr sensor

3. TMP 36
4. A SparkFun Soil Moisture sensor

5. RGB Anode LED

6. Blue LED
7. Red LED
8. Resistors (220K.ohm) -  6nos. 

9. Capacitor  10nF - 1nos. 

10. Jumper Wires

11. Particle Argon kit


Next Steps: 

Improve the IFTTT functionality and receive updates only in case of special events. 

Incorporate the watering system upon actuating the fsr sensor.

Make the circuit more robust and suitable for outdoor use

Calibrate the tmp36 sensor and making it more versatile. 

Reflection: 

Implementing IoT using particle is very powerful. It enables to give life to everyday objects like a plant and enables it to communicate and share its requirements and expectations. It opens a whole new world of connecting to things in your life like never before! 
During this project, I have developed a deep understanding of taking inputs using sensors. I would apply this knowledge to build more valuable products consisting of outputs than just LEDs. 

0
// Project ideated and created by Shrey Agrawal 
// References: http://diotfall2019.daraghbyrne.me/assignments/internet-of-plants/

// Project code starts ***************
int buzzer = D5;            //define output pin for peizo
int fsrledPin = D0;         //define pin for the red LED
int redPin = D2;            //to represent if the plant feels hot
int bluePin = D4;           //to represent if the plant feels cold
int greenPin = D3;          //to represent the optimim temperature for the plant
int brightness = 0;         //variable required to activate the RGB LED
int soilledPin = D6;        //define the pin for LED of soil sensor
int tempPin = A5;           //define the pin for the temperature sensor
int soilPin = A3;           //define pin for soil moisture sensor
int fsrPin = A1;            //define pin for photosensor
int fsrReading = 0;         //declare a variable to store the value of photosensor
int soilReading = 0;        //declare a value to store the value of soil moisture sensor
double temperature = 0.0;   //Variable to store the value of temperature. 


// ***************Code for defining the notes and song************************

// change this to make the song slower or faster
int tempo = 144;
	
// notes of the melody followed by the duration.
int melody[] = {
// a 4 means a quarter note, 8 an eighteenth , 16 sixteenth, so on
// !!negative numbers are used to represent dotted notes,
// so -4 means a dotted quarter note, that is, a quarter plus an eighteenth!!
	

	

	  // Hedwig's theme fromn the Harry Potter Movies

	  REST, 2, NOTE_D4, 4,
	  NOTE_G4, -4, NOTE_AS4, 8, NOTE_A4, 4,
	  NOTE_G4, 2, NOTE_D5, 4,
	  NOTE_C5, -2, 
	  NOTE_A4, -2,
	  NOTE_G4, -4, NOTE_AS4, 8, NOTE_A4, 4,
	  NOTE_F4, 2, NOTE_GS4, 4,
	  NOTE_D4, -1, 
	  NOTE_D4, 4,
	

	  NOTE_G4, -4, NOTE_AS4, 8, NOTE_A4, 4, //10
	  NOTE_G4, 2, NOTE_D5, 4,
	  NOTE_F5, 2, NOTE_E5, 4,
	  NOTE_DS5, 2, NOTE_B4, 4,
	  NOTE_DS5, -4, NOTE_D5, 8, NOTE_CS5, 4,
	  NOTE_CS4, 2, NOTE_B4, 4,
	  NOTE_G4, -1,
	  NOTE_AS4, 4,
	     
	  NOTE_D5, 2, NOTE_AS4, 4,//18
	  NOTE_D5, 2, NOTE_AS4, 4,
	  NOTE_DS5, 2, NOTE_D5, 4,
	  NOTE_CS5, 2, NOTE_A4, 4,
	  NOTE_AS4, -4, NOTE_D5, 8, NOTE_CS5, 4,
	  NOTE_CS4, 2, NOTE_D4, 4,
	  NOTE_D5, -1, 
	  REST,4, NOTE_AS4,4,  
	

	  NOTE_D5, 2, NOTE_AS4, 4,//26
	  NOTE_D5, 2, NOTE_AS4, 4,
	  NOTE_F5, 2, NOTE_E5, 4,
	  NOTE_DS5, 2, NOTE_B4, 4,
	  NOTE_DS5, -4, NOTE_D5, 8, NOTE_CS5, 4,
	  NOTE_CS4, 2, NOTE_AS4, 4,
	  NOTE_G4, -1, 
	  
	};
	
// sizeof gives the number of bytes, each int value is composed of two bytes (16 bits)
// there are two values per note (pitch and duration), so for each note there are four bytes
int notes = sizeof(melody) / sizeof(melody[0]) / 2;

// this calculates the duration of a whole note in ms (60s/tempo)*4 beats
int wholenote = (60000 * 4) / tempo;

int d = 0, noteDuration = 0;

// ********************* Tune code end************************************



//defining the function playnotes. This function is called whenever the force sensor senses force above some threshold.  
void playNotes() {
	  // iterate over the notes of the melody. 
	  // Remember, the array is twice the number of notes (notes + durations)
	  
	  //we need the music to stop is we are not pressing the force sensor.
	  for (int thisNote = 0; (thisNote < notes * 2), fsrReading>1000; thisNote = thisNote + 2) {
	   
	    fsrReading = analogRead(fsrPin);// to ensure that the latest value of the foce is updated, include it in the loop;
	    
	    if (fsrReading>200){
	    // calculates the duration of each note
	    d = melody[thisNote + 1];
	    if (d > 0) {
	      // regular note, just proceed
	      noteDuration = (wholenote) / d;
	    } else if (d < 0) {
	      // dotted notes are represented with negative durations!!
	      noteDuration = (wholenote) / abs(d);
	      noteDuration *= 1.5; // increases the duration in half for dotted notes
	    }
	

	    // we only play the note for 90% of the duration, leaving 10% as a pause
	    tone(buzzer, melody[thisNote], noteDuration*0.9);
	

	    // Wait for the specief duration before playing the next note.
	    delay(noteDuration);
	    // stop the waveform generation before the next note.
	    noTone(buzzer);
	  }
	  }
	}
//******************* Defining Function Ends *****************


// ************* defining the input and output pins********************
void setup() {
    pinMode (buzzer, OUTPUT);
    pinMode(soilledPin, OUTPUT);
    pinMode(fsrledPin, OUTPUT);
    pinMode(redPin, OUTPUT);
    pinMode(bluePin, OUTPUT);
    pinMode(greenPin, OUTPUT);
    pinMode(tempPin, INPUT);
    Particle.variable("force", &fsrReading, INT);
    Particle.variable("Moisture", &soilReading, INT);
    Particle.variable("temperature", &temperature, DOUBLE);
}


void loop() {
    //Determining the temperature from the voltage obtained from the sensor
    int reading = analogRead(tempPin);
    double voltage = (reading * 3.3) / 4095.0;
    int temperaturetemp = (voltage - 0.5) * 100;
    int temp = 0;
    for (int i=0;i<10;i++){
        temp = temp + temperaturetemp;
    }
    temperature = temp/10;
    //input the voltage reading for the photocell 
    fsrReading = analogRead(fsrPin);



// ***************** Code to react to temperature change*****************
// if the plant feels hot then Red LED glows
// if the plant feels cold then Blue LED glows
// if the plant feels good then Green LED glows. 

   if (temperature<-30){
        analogWrite(bluePin, 0);
        analogWrite(redPin, 255);
        analogWrite(greenPin, 255);
    }
    else if ( -30 <= temperature && temperature <-20 ){
        analogWrite(bluePin, 255);
        analogWrite(redPin, 255);
        analogWrite(greenPin, 0);
    }
    else if (temperature > -20) {
        analogWrite(bluePin, 255);
        analogWrite(redPin, 0);
        analogWrite(greenPin,255);
    }
    
    
//*********************** end temperature********************************


//***************** Code to play music when watering the plant******************

        
    if (fsrReading < 200){
        digitalWrite(fsrledPin, LOW); // if the light is not sufficient, then the led is set to high
            
    } else {
        digitalWrite(fsrledPin, HIGH);// if the light is sufficient, turn off the LED
        playNotes();
    } 

//****************** To check the moisture level of the soil ******************


    soilReading = analogRead(soilPin);
    if (soilReading < 500){
        digitalWrite(soilledPin, HIGH); // if the soil moisture level is low, LED glows
    } else {
        digitalWrite(soilledPin, LOW);// when there is sufficient water in the soil, the LED goes off
    }
    
    delay(100);
log_to_message(  );
log_to_spreadsheet(  );
}
//*********************** end ******************************

//*************************** END OF THE CODE THANK YOU*******************


//***************** doclaring all the notes to play the song****************//
//defining all the notes for the song
	int NOTE_B0 = 31;
	int NOTE_C1 = 33;
	int NOTE_CS1= 35;
	int NOTE_D1 = 37;
	int NOTE_DS1= 39;
	int NOTE_E1 = 41;
	int NOTE_F1 = 44;
	int NOTE_FS1= 46;
	int NOTE_G1 = 49;
	int NOTE_GS1 =52;
	int NOTE_A1  =55;
	int NOTE_AS1= 58;
	int NOTE_B1 = 62;
	int NOTE_C2 = 65;
	int NOTE_CS2= 69;
	int NOTE_D2 = 73;
	int NOTE_DS2= 78;
	int NOTE_E2 = 82;
	int NOTE_F2 = 87;
	int NOTE_FS2= 93;
	int NOTE_G2 = 98;
	int NOTE_GS2= 104;
	int NOTE_A2 = 110;
	int NOTE_AS2 =117;
	int NOTE_B2  =123;
	int NOTE_C3  =131;
	int NOTE_CS3 =139;
	int NOTE_D3  =147;
	int NOTE_DS3 =156;
	int NOTE_E3  =165;
	int NOTE_F3  =175;
	int NOTE_FS3 =185;
	int NOTE_G3  =196;
	int NOTE_GS3 =208;
	int NOTE_A3 = 220;
	int NOTE_AS3= 233;
	int NOTE_B3 = 247;
	int NOTE_C4 = 262;
	int NOTE_CS4= 277;
	int NOTE_D4  =294;
	int NOTE_DS4 =311;
	int NOTE_E4  =330;
	int NOTE_F4  =349;
	int NOTE_FS4 =370;
	int NOTE_G4  =392;
	int NOTE_GS4 =415;
	int NOTE_A4  =440;
	int NOTE_AS4 =466;
	int NOTE_B4  =494;
	int NOTE_C5  =523;
	int NOTE_CS5 =554;
	int NOTE_D5  =587;
	int NOTE_DS5 =622;
	int NOTE_E5  =659;
	int NOTE_F5  =698;
	int NOTE_FS5 =740;
	int NOTE_G5  =784;
	int NOTE_GS5 =831;
	int NOTE_A5  =880;
	int NOTE_AS5 =932;
	int NOTE_B5  =988;
	int NOTE_C6  =1047;
	int NOTE_CS6 =1109;
	int NOTE_D6  =1175;
	int NOTE_DS6 =1245;
	int NOTE_E6  =1319;
	int NOTE_F6  =1397;
	int NOTE_FS6 =1480;
	int NOTE_G6  =1568;
	int NOTE_GS6 =1661;
	int NOTE_A6  =1760;
	int NOTE_AS6 =1865;
	int NOTE_B6  =1976;
	int NOTE_C7  =2093;
	int NOTE_CS7 =2217;
	int NOTE_D7  =2349;
	int NOTE_DS7 =2489;
	int NOTE_E7  =2637;
	int NOTE_F7  =2794;
	int NOTE_FS7 =2960;
	int NOTE_G7  =3136;
	int NOTE_GS7 =3322;
	int NOTE_A7  =3520;
	int NOTE_AS7 =3729;
	int NOTE_B7  =3951;
	int NOTE_C8 = 4186;
	int NOTE_CS8= 4435;
	int NOTE_D8 = 4699;
	int NOTE_DS8= 4978;
	int REST =0;

int last_published1 = -1;
int last_published = -1; 
	
void log_to_spreadsheet(  ){

  // check if 1 minute has elapsed
	if( last_published + 60000 < millis() ){
		Particle.publish( "log_to_spreadsheet", String( soilReading) );
		last_published = millis();
	}

}

void log_to_message(  ){

  // check if 1 minute has elapsed
	if( last_published1 + 60000 < millis() ){
		Particle.publish( "log_to_message", String( soilReading) );
		last_published1 = millis();
	}

}
Click to Expand
x
Share this Project

This project is only listed in this pool. Be considerate and think twice before sharing.



Focused on
Skills
About

The goal of the project is to enchant a plant and give a magical experience to users while interacting with the plant.
This is a mock-up of GillyWeed - a fictional enchanted plant from the Harry Potter series.

Created

November 6th, 2019