Gregorio Aguirre HernandezEthan Pongracz
Published

Plant Greenhouse Monitor MEGR 3171 Spring 2023

This is a sensor combination that can let you know when the temperature, humidity, or light in a greenhouse is too high or too low.

IntermediateFull instructions provided40
Plant Greenhouse Monitor MEGR 3171 Spring 2023

Things used in this project

Hardware components

Argon
Particle Argon
Device used for connecting sensors so that it data can be read and analyzed online
×1
ELEGOO Upgraded 37 in 1 Sensor Modules Kit V2.0
ELEGOO Upgraded 37 in 1 Sensor Modules Kit V2.0
Sensors used from kit - Photoresistor and Temperature/Humidity Sensor
×1
Resistor 220 ohm
Resistor 220 ohm
Used to minimize voltage variation going into photoresistor
×2
Jumper wires (generic)
Jumper wires (generic)
Connects sensor pins to Particle Argon
×1
Micro-USB to USB Cable (Generic)
Micro-USB to USB Cable (Generic)
Gives Particle Argon power
×1
Breadboard (generic)
Breadboard (generic)
Used to create a circuit that can service both Particle Argon and sensors used
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Used for coding particle argon and creating integration so that data can be analyzed on ThingSpeak
ThingSpeak API
ThingSpeak API
Used to create graphs from sensor data

Story

Read more

Schematics

Photoresistor Cicuit

This schematic shows the connections for connecting the Photoresistor to the Particle Argon. A breadboard was used to secure all the electrical components.

Temperature Sensor Circuit

This schematic shows the connections for connecting the Temperature Sensor to the Particle Argon. The sensor has a built in variable resistor so there is no need for an external resistor to control the voltage variation. A breadboard was used to secure all the electrical components.

Code

Photoresistor Code

C/C++
This code reads the photoresistor value every minute and will update the ThingSpeak channel. The data is reversed so that dark is low and light is high.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>

//Photoresistor connected to A0 pin that detects light 
int photoresistor = A0;
int analogValue;
int reverseData;
TCPClient client;
//Used to Connect to ThingSpeak Channel
unsigned long myChannelNumber = 2104686;
const char * myWriteAPIKey = "4T9QIQPIUWPZAP83";

void setup() {
    
    ThingSpeak.begin(client);
    
  pinMode(photoresistor, INPUT);
  Serial.begin(9600);

}

void loop() {
  // Get some data

//Convers analog value to data of photoresistor
  analogValue = 100000/analogRead(photoresistor);
  
    String data = String(analogValue);
    
//if statement below can be changed to adjust how sensitive the photoresistor is to light
    Particle.publish("photoresistor", data, ALL_DEVICES);
    
    ThingSpeak.setField(1,analogValue);

    ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
  // Wait seconds
  delay(60000);

}
 

Temperature Code

C/C++
This code reads the temperature sensor and also subscribes to the photoresistor event. When the photoresistor event occurs, the LED on the Patricle Argon will turn on for 10 minutes and then turn off.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>


int analogvalue = 0;
int temp;
TCPClient client;
//used to connect to ThingSpeak Channel
unsigned long myChannelNumber = 2104686;
const char * myWriteAPIKey = "4T9QIQPIUWPZAP83";

void setup(){

  ThingSpeak.begin(client);
 
  Particle.variable("analogvalue", analogvalue);
  Particle.variable("temp", temp);
  Particle.subscribe("photoresistor", readLight, ALL_DEVICES);
  //When photoresistor happens, do readLight
 
Serial.begin(9600);

  pinMode(A0, INPUT);
}
//For subscribing and talking to other argon
void readLight(const char *event, const char *data){
    
    pinMode(D7, OUTPUT);
    digitalWrite(D7,HIGH);
    delay(10000); //delays for 10 minutes
    digitalWrite(D7,LOW);
 
}
void loop(){
{
 
  analogvalue = analogRead(A0);  // Read the analog value of the sensor
  temp = (analogvalue*-.081+152); //Converts the reading into degrees F
  delay(60000);
}
 
 //Publishes the data to thingspeak
  Particle.publish("temperature is",String (temp), ALL_DEVICES);
  ThingSpeak.setField(2,temp);
  Serial.print(temp);
  Serial.println("temp");
  
  ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
  // Wait 1 second 
  delay(60000);

}



//references 
//https://docs.particle.io/reference/device-os/api/serial/println/
//https://docs.particle.io/reference/device-os/api/cloud-functions/particle-variable/
//https://particle.hackster.io/team-52/iot-temperature-sensor-6117be

Credits

Gregorio Aguirre Hernandez

Gregorio Aguirre Hernandez

1 project • 0 followers
Ethan Pongracz

Ethan Pongracz

1 project • 0 followers

Comments

Add projectSign up / Login