Things used in this project

Hardware components:
Msp exp432p401r msp exp432p401r sidered eoamulng36
TI LaunchPad MSP-EXP432P401R SimpleLink MSP432 LaunchPad
×1
110020004 20100
SeeedStudio Grove Starter Kit for LaunchPad
×1
SeeedStudio Sidekick Launchpad
×1
09590 01
LED (generic)
×9
08377 02 l
Resistor 330 ohm
×9
11026 02
Jumper wires (generic)
×10

Code

Moisture Sensor CodeC/C++
/*
 Grove Moisture Sensor

 The following sketch demonstrates a simple application of sensing 
 the moisture of the soil. You can determine whether a plant needs water 
 or not by observing the results that the sensor outputs.
 
 The circuit:
 * 4-Digit Display attached to Pin 38 and 39 (J14 plug on Grove Base BoosterPack)
 * Moisture Sensor attached to Pin 24 (J6 plug on Grove Base BoosterPack)
 
 * Note:  
 
 This example code is in the public domain.
 
 http://www.seeedstudio.com/depot/Grove-Moisture-Sensor-p-955.html

*/
//4-Digit Display library
#include "TM1637.h"

/* Macro Define */
#define CLK               	39          /* 4-Digit Display clock pin */
#define DIO               	38          /* 4-Digit Display data pin */
#define MOISTURE_PIN      	24          /* pin of Moisture Sensor */
#define THRESHOLD_VALUE   	300         /* threshold for watering the plant */
#define LED 			RED_LED

/* Global Variables */
TM1637 tm1637(CLK, DIO);                  /* 4-Digit Display object */
int analog_value = 0;                     /* variable to store the value coming from Moisture Sensor */
int8_t bits[4] = {0};                     /* array to store the single digits of the value */

/* the setup() method runs once, when the sketch starts */
void setup() 
{
  /* Initialize 4-Digit Display */
  tm1637.init();
  tm1637.set(BRIGHT_TYPICAL);
  /* declare the LED pin as an OUTPUT */
  pinMode(2, OUTPUT);  
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);

}

/* the loop() method runs over and over again */
void loop() 
{
    analog_value = analogRead(MOISTURE_PIN);      /* read the value from the sensor */
    /* if the value is smaller than threshold, turn on LED */
    if(analog_value < 67) 
    {
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    
    } 
    else if(analog_value < 134)
    {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    }
    else if(analog_value < 201)
    {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    }
    else if(analog_value < 268)
    {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    }
    else if(analog_value < 335)
    {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    }
    else if(analog_value < 402)
    {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    }
    else if(analog_value < 469)
    {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    }
        else if(analog_value < 536)
    {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(10, LOW);
    }
        else if(analog_value < 603)
    {
    digitalWrite(2, HIGH);
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);
    digitalWrite(10, HIGH);
    }
    memset(bits, 0, 4);                             /* reset array before we use it */
    for(int i = 3; i >= 0; i--) 
    {
        /* Convert the value to individual decimal digits for display */
        bits[i] = analog_value % 10;
        analog_value = analog_value / 10;  
        tm1637.display(i, bits[i]);                 /* display on 4-Digit Display */
    }
    delay(200);  //small delay so that the number doesn't change too quickly to read
}

Credits

Mjoyqfasn0zslpeg4vrc
Ali Soomar

Student at the University of Texas at Austin

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

E-Ink Display based Static Desktop eCalendar
Easy
  • 8
  • 2

Full instructions

An electronic Desktop Calendar based on Electronic Ink Display controlled by TM4C123 Tiva(ARM) development board & programmed in Energia IDE

MSP432 Fun with IoT Workshop 2016
Easy
  • 3,536
  • 69

Full instructions

Explore the Educational BoosterPack paired with the MSP432 LaunchPad and then take that to the cloud with the CC3100 Wi-Fi BoosterPack!

MIT IAP 2016 Lab
Easy
  • 2,021
  • 47

A collection of the 6 labs for the MIT IAP Texas Instruments LaunchPad Workshop

Texas Instruments MSP-EXP432 - MultiTasking
Easy
  • 708
  • 20

Protip

MultiTasking ultrasonic and color sensor with Texas Instruments MSP-EXP432 and Energia.

Control a CC3200 LaunchPad with your phone using Blynk
Easy
  • 6,345
  • 28

Full instructions

Read sensor data and toggle LEDs with the Blynk mobile app and the TI CC3200 LaunchPad

Mongoose Embedded Networking Library on mbed+CC3100
Easy
  • 651
  • 12

Protip

Mongoose, the most popular open source embedded web server and networking library now supports the mbed platform. See CC3100 example.

Add projectSign up / Login