Jacob BerryAndy MedinaDaniel Alvarez
Published

Lane of Things

Helping aquaponic classes by measuring CO2, light, temperature, and humidity, when all 4 are in prime range, our led will light up.

IntermediateFull instructions provided7 days980
Lane of Things

Things used in this project

Hardware components

Adafruit NeoPixel Jewel - 7 x 5050 RGB LED with Integrated Drivers
×1
SainSmart MQ135 Sensor Air Quality Sensor Hazardous Gas Detection
×1
SparkFun Atmospheric Sensor Breakout - BME280
SparkFun Atmospheric Sensor Breakout - BME280
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Breadboard (generic)
Breadboard (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×20

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Fritzing

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Custom parts and enclosures

Enclosure

It is a clear acrylic box with the dimensions 7"x 4" x 3". We used it to hold the node inside so it didn't get damaged inside of the aquaponics lab. We left holes on the top and sides so the air could come through for the temperature, humidity, and co2. The clear acrylic let the light come through the box. Sketched on the front side is our group number, 707, and there is nothing on the box so we can adhesive it to a surface. Finally, on the top there is a little box opening so we can insert a power chord to the node.

Enclosure Illustrator File

Enclosure File image

Schematics

Fritzing Diagram

This is our fritzing diagram. We use this to push out the data from each different sensor.

Fritzing

Code

Group 707

JavaScript
This is our code that was used to determine the Temperature, Humidity, CO2, and amount of light in the room, along with some bits of code to flash the NeoPixel if the Humidity in the room is idle/safe to be in.
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_TSL2561_U.h>

// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h> //jewel sensor
#include <neopixel.h>
#define PIXEL_PIN D4        //location
#define PIXEL_COUNT 7       //Amount of leds
#define PIXEL_TYPE WS2812B  //Type of LED
#include <Wire.h>

Adafruit_NeoPixel strip = Adafruit_NeoPixel(7, PIXEL_PIN, PIXEL_TYPE);

//Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
void rainbow(uint8_t wait);
uint32_t Wheel(byte WheelPos);
SYSTEM_MODE(AUTOMATIC);


// This #include statement was automatically added by the Particle IDE.
#include <MQ135.h> //CO2 Sensor

// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h> //Temp+Hum Sensor
#include "application.h"

#define DHTPIN 3  //Using #define to open communication with that pin
// If connecting the Temp+Hum sensor, make sure to include it's model number " DHT 22 (AM2302) " So the arduino knows what it is dealing with.
#define DHTTYPE DHT22 // DHT22 is the model of the Temp+Hum sensor

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2561_U.h>

/* This driver uses the Adafruit unified sensor library (Adafruit_Sensor),
   which provides a common 'type' for sensor data and some helper functions.
   
   To use this driver you will also need to download the Adafruit_Sensor
   library and include it in your libraries folder.

   You should also assign a unique ID to this sensor for use with
   the Adafruit Sensor API so that you can identify this particular
   sensor in any data logs, etc.  To assign a unique ID, simply
   provide an appropriate value in the constructor below (12345
   is used by default in this example).
   
   Connections
   ===========
   Connect SCL to analog 5
   Connect SDA to analog 4
   Connect VDD to 3.3V DC
   Connect GROUND to common ground

   I2C Address
   ===========
   The address will be different depending on whether you leave
   the ADDR pin floating (addr 0x39), or tie it to ground or vcc. 
   The default addess is 0x39, which assumes the ADDR pin is floating
   (not connected to anything).  If you set the ADDR pin high
   or low, use TSL2561_ADDR_HIGH (0x49) or TSL2561_ADDR_LOW
   (0x29) respectively.
    
   History
   =======
   2013/JAN/31  - First version (KTOWN)
*/
   
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);

/**************************************************************************/
/*
    Displays some basic information on this sensor from the unified
    sensor API sensor_t type (see Adafruit_Sensor for more information)
*/
/**************************************************************************/
void displaySensorDetails(void)
{
  sensor_t sensor;
  tsl.getSensor(&sensor);
  Serial.println("------------------------------------");
  Serial.print  ("Sensor:       "); Serial.println(sensor.name);
  Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" lux");
  Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" lux");
  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" lux");  
  Serial.println("------------------------------------");
  Serial.println("");
  delay(500);
}

/**************************************************************************/
/*
    Configures the gain and integration time for the TSL2561
*/
/**************************************************************************/
void configureSensor(void)
{
  /* You can also manually set the gain or enable auto-gain support */
  //tsl.setGain(TSL2561_GAIN_1X);      /* No gain ... use in bright light to avoid sensor saturation */
   tsl.setGain(TSL2561_GAIN_16X);     /* 16x gain ... use in low light to boost sensitivity */
  //tsl.enableAutoRange(true);            /* Auto-gain ... switches automatically between 1x and 16x */
  
  /* Changing the integration time gives you better sensor resolution (402ms = 16-bit data) */
  tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);      /* fast but low resolution */
  // tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_101MS);  /* medium resolution and speed   */
  // tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_402MS);  /* 16-bit data but slowest conversions */

  /* Update these values depending on what you've set above! */  
  Serial.println("------------------------------------");
  Serial.print  ("Gain:         "); Serial.println("Auto");
  Serial.print  ("Timing:       "); Serial.println("13 ms");
  Serial.println("------------------------------------");
}

DHT dht(DHTPIN, DHTTYPE);

double hum;         //Hum levels
double temp;        //Temp levels
double light;       //Light (Lumilosity) Amount of light coming in in number

//CO2 Stuff
int number = 0;
int state = 0;
MQ135 gasSensor = MQ135(0);
int led = D7;
float rzero = gasSensor.getRZero();
int ppm = gasSensor.getPPM();         //Amount of CO2 levels coming in


void setup() 
{
    Serial.begin(9600);
    pinMode(DHTPIN, INPUT);
    strip.begin();          //Initialize pixels to be in ready mode
    strip.show(); // Initialize all pixels to 'off'
    Particle.variable("hum", hum);
    Particle.variable("temp", temp);
    Particle.variable("light", light);
    Particle.variable("CO2", ppm);
     Serial.println("Light Sensor Test"); Serial.println("");
  
  /* Initialise the sensor */
     if(!tsl.begin())
     {
      /* There was a problem detecting the TSL2561 ... check your connections */
      Serial.print("Ooops, no TSL2561 detected ... Check your wiring or I2C ADDR!");
      while(1);
     }
  
     /* Display some basic information on this sensor */
      displaySensorDetails();
     
     /* Setup the sensor gain and integration time */
     configureSensor();
  
      /* We're ready to go! */
    Serial.println("");
    
}

void loop() {
    
    //rainbow(30);
    //CO2 Sensor
    ppm = analogRead(0);       // read analog input pin 0
    Serial.println(ppm, DEC);  // prints the value read
    
    //More CO2 Stuff
    float rzero = gasSensor.getRZero();
    digitalWrite(led,HIGH);             // turn the ledPin on
    //delay(100);                         // stop the program for some time
    //digitalWrite(led, LOW);             // turn the ledPin off
    //delay(100);                         // stop the program for some time

    int co2_ppm = gasSensor.getPPM();
    int ppm = co2_ppm / 4;
    Spark.variable("ppm", & ppm, INT);                    

    //delay(10000);                       //No Delay Remove later, here for now
    
    //Temp+Hum Sensor
    double checkHum = dht.getHumidity();                //Seperate from light and CO2 inputs
    double checkTemp = dht.getTempFarenheit();
    
    if (checkHum > 0 && checkHum < 100)
        hum = checkHum;
        
    if (checkTemp > 32 && checkTemp < 100)
        temp = checkTemp;
    
    Serial.println("Temp: " + String(checkTemp));
    Serial.println("Hum: " + String(checkHum));
    
     /* Get a new sensor event */ 
      sensors_event_t event;
      tsl.getEvent(&event);
          
     //   Particle.variable("light", light);
 
      /* Display the results (light is measured in lux) */
      if (event.light)
      {
        Serial.print(event.light); 
        Serial.println(" lux");
        light = (event.light);
      }
      else
      {
        /* If event.light = 0 lux the sensor is probably saturated
           and no reliable data could be generated! */
        Serial.println("Sensor overload");
      }
      //delay(250);
      
      if(checkHum <= 50)
        {
            strip.setBrightness(10);
            strip.setPixelColor(0,0,255,0);
            strip.setPixelColor(1,0,255,0);
            strip.setPixelColor(2,0,255,0);
            strip.setPixelColor(3,255,0,0);
            strip.setPixelColor(4,0,255,0);
            strip.setPixelColor(5,0,255,0);
            strip.setPixelColor(6,0,255,0);
            strip.show();
            //delay(250);
        }
        else
        {
            strip.setBrightness(100);
            strip.setPixelColor(0,255,0,0);
            strip.setPixelColor(1,255,0,0);
            strip.setPixelColor(2,255,0,0);
            strip.setPixelColor(3,255,0,0);
            strip.setPixelColor(4,255,0,0);
            strip.setPixelColor(5,255,0,0);
            strip.setPixelColor(6,255,0,0);
            strip.show();
            //delay(250);
        }
}

Credits

Jacob Berry

Jacob Berry

1 project • 0 followers
I am a male teenager. I am using this for my innovation and creation class at the moment.
Andy Medina

Andy Medina

1 project • 0 followers
I like guitar. I wear glasses and enjoy long walks on the beach.
Daniel Alvarez

Daniel Alvarez

1 project • 0 followers
Group 707

Comments