Plant Health Monitor

Made by Stephen Krotseng

I have an Epipremnum plant sitting in my window, which is often open during the winter because my apartment is too warm. The plant needs sunlight, but it also needs to be in a temperature range of 65-80 degrees Fahrenheit in order to stay healthy. I decided to create a sensor that would tell me, at a quick glance, whether or not my plant was in the right temperature range. With red and green LEDs, I programmed the Spark core to light the green LED when the temperature is within 65-80 degrees, and to light the red LED when the temperature is outside that range. I also set up the temperature as a cloud variable so I could keep track of it when I'm not at home. Additionally, I wanted to be able to monitor the sunlight amount the plant is receiving. I installed a photoresistor and set it up as a cloud variable in order to remotely monitor whether or not the plant is receiving enough sunlight.

Created: January 27th, 2015

0

The Scenario

I have an Epipremnum plant sitting in my window, which is often open during the winter because my apartment is too warm. The plant needs sunlight, but it also needs to be in a temperature range of 65-80 degrees Fahrenheit in order to stay healthy.


The Project

I decided to create a sensor that would tell me, at a quick glance, whether or not my plant was in the right temperature range. With red and green LEDs, I programmed the Spark core to light the green LED when the temperature is within 65-80 degrees, and to light the red LED when the temperature is outside that range. I also set up the temperature as a cloud variable so I could keep track of it when I'm not at home.

Additionally, I wanted to be able to monitor the sunlight amount the plant is receiving. I installed a photoresistor and set it up as a cloud variable in order to remotely monitor whether or not the plant is receiving enough sunlight.

Materials Used

Spark Core

Extended Breadboard

Green LED

Red LED

Two 1000 Ohm resistors

One 10000 Ohm resistor

One Photoresistor

One TMP36 Temperature Sensor

One 10nF capacitor

 

0
// Define a pin that we'll place the photocell and temp pins on
// Remember to add a 10K Ohm pull-down resistor too (photocell only).
int photoCellPin = A0;
int tempPin = A1;

// Create a variable that will store the temperature value
double temperature = 0.0;
double temperatureF = 0.0;

// Create a variable to hold the light reading
int photoCellReading = 0;

// Define pins we'll place an LED on
int ledPinR = D0;
int ledPinG = D1;

// Create a variable to store the LED brightnesses
int ledBrightnessR = 0;
int ledBrightnessG = 0;

int lightOutput;

void setup(){

  // Register a Spark variable here
  Spark.variable("temperature", &temperature, DOUBLE);
  Spark.variable("temperatureF", &temperatureF, DOUBLE);

  // Create a cloud variable of type integer
  // called 'light' mapped to photoCellReading
  Spark.variable("light", &photoCellReading, INT);

  // Connect the temperature sensor to A1 and configure it
  // to be an input
  pinMode(tempPin, INPUT);
  pinMode(lightOutput, INPUT);

  // Set up the LEDs for output
  pinMode(ledPinG, OUTPUT);
  pinMode(ledPinR, OUTPUT);

}

void loop() {

  // Keep reading the sensor value so when we make an API
  // call to read its value, we have the latest one
  int reading = analogRead(tempPin);

  // The returned value from the Core is going to be in the range from 0 to 4095
  // Calculate the voltage from the sensor reading
  double voltage = (reading * 3.3) / 4095.0;

  // Calculate the temperature and update our static variable
  temperature = (voltage - 0.49) * 100;

  // Now convert to Farenheight
  temperatureF = ((temperature * 9.0) / 5.0) + 32.0;

  // Use analogRead to read the photo cell reading
  // This gives us a value from 0 to 4095
  photoCellReading = analogRead(photoCellPin);

  if(temperatureF > 65 && temperatureF < 80){
    digitalWrite(ledPinG, HIGH);
    digitalWrite(ledPinR, LOW);
  }
  else
  {
    digitalWrite(ledPinG, LOW);
    digitalWrite(ledPinR, HIGH);
  }

  // wait 1/10th of a second and then loop
  delay(50);

}
Click to Expand
0
0

The Outcome

The outcome of the project was positive. The LEDs accurately reflected the temperature reading of the TMP sensor. Unfortunately, the sensor was slightly unreliable, and seemed a bit inaccurate. It was improved by changing some of the code, but it remains less than stellar in terms of accuracy. The biggest challenge came when designing the "if" statement in my coding. I had to enter a boolean "&&" symbol in order to communicate to the Spark core that there was a temperature range, rather than use two inequality signs around one variable, which threw an error.

Next Steps

Moving forward, I would like to use a temperature sensor with more advanced accuracy. Additionally, I would like to learn how to write coding that would take samples of the light level throughout the day and populate a spreadsheet, so that I could have data that I could graph to view the curve of daily sunlight value.

x
Share this Project


About

I have an Epipremnum plant sitting in my window, which is often open during the winter because my apartment is too warm. The plant needs sunlight, but it also needs to be in a temperature range of 65-80 degrees Fahrenheit in order to stay healthy.

I decided to create a sensor that would tell me, at a quick glance, whether or not my plant was in the right temperature range. With red and green LEDs, I programmed the Spark core to light the green LED when the temperature is within 65-80 degrees, and to light the red LED when the temperature is outside that range. I also set up the temperature as a cloud variable so I could keep track of it when I'm not at home.

Additionally, I wanted to be able to monitor the sunlight amount the plant is receiving. I installed a photoresistor and set it up as a cloud variable in order to remotely monitor whether or not the plant is receiving enough sunlight.