ECE4180 Project: Dancing Groot

ECE 4180: Dancing Groot

Team Members: Geuntae Park, Youngjae Cho


While walking on the campus in rainy day, one can see that sprinklers are turned on for watering the lawn. Most of the watering system of sprinklers are based on the timer setting, not on the humidity level in soil. This results in the huge waste of water. To resolve this problem, our team designs an alarming device which is integrated in a small plant pot.

When a moisture sensor reads low values from the soil inside the pot, our device lets a user to notice the deficit of water by alarming sound. For the purpose of commercialization, our design adds a famous character ‘Baby Groot’ from the movie ‘Guardians of the Galaxy’.

Specifically, when the moisture sensor reads the value of the deficit of water needed, the Baby Groot implanted on the device dances with a background music like the movie scene ‘Dancing Groot’. When enough water is filled in the soil, the baby Groot stops dancing alarming sound.


Parts used


Moisture Sensor

SparkFun Soil Moisture Sensor: https://www.sparkfun.com/products/13637

/media/uploads/gpark65/moisture_sensor.jpg


Servo

SG51R (Sub-micro Servo): http://adafru.it/2201

/media/uploads/gpark65/submicroservo.jpg

HS-422 (Standard Size Servo): https://www.sparkfun.com/products/11884

/media/uploads/gpark65/servo.jpg


Speaker

0.5 W 8 Ohm speaker: https://www.sparkfun.com/products/9151

/media/uploads/gpark65/speaker.jpg


Driver Transistor

2N3904 (NPN General Purpose Amplifier): https://www.digikey.com/products/en?WT.z_header=search_go&lang=en&keywords=2N3904&x=0&y=0&cur=USD

/media/uploads/gpark65/2n3904.jpg


uSD Card Breakout Board

SparkFun microSD Transflash Breakout: https://www.sparkfun.com/products/544

/media/uploads/gpark65/usd.jpg



Code


main.cpp

// ECE 4180 Fall 2019 Project
// Section A: Geuntae Park & Youngjae Cho
// Team name: Dancing Groot

#include "mbed.h"
#include "rtos.h"
#include "SDFileSystem.h"
#include "wave_player.h"
#include "Servo.h"
AnalogIn moisture(p15); // Moisture sensor
SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
AnalogOut DACout(p18);
wave_player waver(&DACout);
volatile bool myspeaker = 0;
Servo myservo(p21);
Servo mymotor(p22);

// Thread controlling a servo motor based on the level of moisture
void thread_servo(void const *args)
{
    while(true) {     // thread loop
        if(moisture<=0.18){
        myservo = -1.0;
        wait(0.1);
        myservo = 1.0;
        wait(0.1);
        }
        Thread::wait(200);        
    }
    
}

// Thread controlling a speaker based on the level of moisture

void thread_speaker(void const *args)
{
    while(true) {       // thread loop
        if(moisture<=0.18 && myspeaker ==0)
        {
            FILE *wave_file;
            wave_file=fopen("/sd/sound.wav","r"); 
            waver.play(wave_file);//        
            myspeaker = 1;
        }
        else if(moisture<=0.18 && myspeaker==1)
        {
            FILE *wave_file;
            wave_file=fopen("/sd/sound.wav","r"); 
            waver.play(wave_file);//
            myspeaker = 0;    
        }
        else if(moisture>0.18 && myspeaker ==0)
        {
              
        }
        else if(moisture>0.18 && myspeaker ==1)
        {
            myspeaker = 0;   
        }
        Thread::wait(1100); //
    }
}

// Thread controlling a DC motor based on the level of moisture

void thread_motor(void const *args)
{
    while(true) {     // thread loop
        if(moisture<=0.18){
        mymotor = -1.0;
        wait(0.5);
        mymotor = 1.0;
        wait(0.5);
        }
        Thread::wait(200);        
    }
    
    
}


int main()
{
    Thread tservo(thread_servo);
    Thread tspeaker(thread_speaker);
    Thread tmotor(thread_motor); //start thread_motor

    
    float value = 0.0f;
 
    while(1) {
        value = moisture;
        printf("Moisture reading is %3.5f\n", value);
        wait(1000);
    }
}

Result


Picture

/media/uploads/gpark65/result.jpg


Video


Please log in to post comments.