Mali FreemanPrescott Little
Published

MEGR 3171L IOT Project: Greenhouse Multi-Sensor

We are Prescott Little, Mali Freeman, and Tyler Pace. We're using a Sparkfun BME280 to measure atmospheric factors and compare plant growth.

BeginnerFull instructions provided32
MEGR 3171L IOT Project: Greenhouse Multi-Sensor

Things used in this project

Hardware components

SparkFun Atmospheric Sensor Breakout - BME280
SparkFun Atmospheric Sensor Breakout - BME280
×1
Argon
Particle Argon
×3
Breadboard (generic)
Breadboard (generic)
×3

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Schematics

Particle Argon Circuit Diagram

One particle argon connects to the BME sensor and the light sensor. The other 2 have their own LEDs.

Flowchart

Code

IOT 2

C/C++
Run it baby
#define BLYNK_TEMPLATE_ID "TMPLbwBk_tqd"
#define BLYNK_DEVICE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "1fQEu6uCaSZ2Yu3BSlci2-4PDmHDSiz0"
#define PIXEL_PIN D6 
#define PIXEL_COUNT 1
#define PIXEL_TYPE WS2812B 
#define BLYNK_PRINT Serial
#define SEALEVELPRESSURE_HPA (1013.25) 

#include <neopixel.h>
#include <blynk.h>
#include <CE_BME280.h>

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

SYSTEM_MODE(AUTOMATIC); 
int light = D7;
int led = D8;
char auth[] = BLYNK_AUTH_TOKEN;
CE_BME280 bme;
int brightness = 50; 
float bmeTemperature; 
float bmePressure; 
float bmeHumidity; 
float Light; 
float dewpoint; 
int wifiStrength; 
float startTime; 
float sensorValue; 
float Temp;
void setup() 
{ 
   pinMode(led, OUTPUT);
   digitalWrite(led, LOW);
   pinMode(light, OUTPUT);
   digitalWrite(light, LOW);
   Particle.subscribe("Argon_1_connected", myHandler, MY_DEVICES);
   Particle.subscribe("Argon_2_connected", myHandler1, MY_DEVICES);
   
   strip.begin(); 
   strip.setBrightness(brightness); 
   strip.show(); // Initialize all pixels 
   Serial.begin(9600);
   Blynk.begin(auth); 
   delay(2000); 
   if(bme.begin()){ 
       String errorMessage; 
       errorMessage = "Not found"; 
       Spark.publish("BME280 Error", errorMessage); 
       } 
   startTime = millis(); 
}
void loop(){ 
   Blynk.run(); 
   if (millis() > startTime + 2000){ 
       startTime = millis(); 
       wifiStrength = map(WiFi.RSSI(), -100, 0, 0, 100); 
       Blynk.virtualWrite(V20, wifiStrength);         
       getLight(); 
       getBME280Data(); 
       Particle.publish("WiFi_Sent","WiFi");
       Particle.publish("Temp_Sent","Temp");
       
            
       
       delay(2000);
   } 
}
void getLight(){ 
   for(int x = 0; x <= 2; x++){      //3 point averaging filter
       sensorValue = sensorValue + analogRead(A0); 
   } 
   sensorValue = sensorValue / 3; 
   Light = float(sensorValue) * 100 / 4095; 
   Blynk.virtualWrite(V11, Light); 
}
void getBME280Data(){ 
   bmeTemperature = bme.readTemperature() - 3; 
   Blynk.virtualWrite(V12, bmeTemperature); 
   bmeHumidity = bme.readHumidity(); 
   if (bmeHumidity > 1){ 
   Blynk.virtualWrite(V13, bmeHumidity); 
   } 
   bmePressure = (bme.readPressure()/100) - 3; 
   Blynk.virtualWrite(V14, bmePressure); 
   dewpoint = bmeTemperature - ((100 - bmeHumidity)/5); 
   Blynk.virtualWrite(V15, dewpoint);
}
void myHandler(const char *event, const char *data){
    digitalWrite(led,HIGH);
    }

void myHandler1(const char *event, const char *data){
    digitalWrite(light,HIGH);
    }

Temp Response

C/C++
int led = D7;

void setup()
{
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);

  Particle.subscribe("Temp_Sent", myHandler, MY_DEVICES);
  Particle.subscribe("Temp_Not_Sent", myHandler1, MY_DEVICES);
}
void loop(){
     Particle.publish("Argon_2_connected","Argon_2");
}
void myHandler(const char *event, const char *data){
    digitalWrite(led,HIGH);
    }

void myHandler1(const char *event, const char *data){
    digitalWrite(led,LOW);
    }
    

Wifi Response

C/C++
int led = D7;

void setup()
{
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);

  Particle.subscribe("WiFi_Sent", myHandler2, MY_DEVICES);
  Particle.subscribe("WiFi_Not_Sent", myHandler3, MY_DEVICES);
}
void loop(){
     Particle.publish("Argon_1_connected","Argon_1");
}
void myHandler2(const char *event, const char *data){
    digitalWrite(led,HIGH);
    }

void myHandler3(const char *event, const char *data){
    digitalWrite(led,LOW);
    }

Credits

Mali Freeman

Mali Freeman

1 project • 0 followers
Prescott Little

Prescott Little

0 projects • 0 followers
Thanks to John Macalpine.

Comments

Add projectSign up / Login