Things used in this project

Hardware components:
Nodemcu
NodeMCU ESP8266 Breakout Board
×1
1586 00
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
×1
Adafruit DHT11
×1
13285 01
PIR Motion Sensor (generic)
×1
SparkFun LDR
×1
SparkFun PIEZO BUZZER
×1
12002 04
Breadboard (generic)
×1
Mfr 25frf52 1k sml
Resistor 1k ohm
×1
11026 02
Jumper wires (generic)
×1
SparkFun Female Header Pin
×1
Software apps and online services:
Ide web
Arduino IDE
Cayenne logo hi
myDevices Cayenne
Hand tools and fabrication machines:
09507 01
Soldering iron (generic)
Pro dmm box 600  26129.1449785766.500.659
Digilent Mastech MS8217 Autorange Digital Multimeter

Custom parts and enclosures

Download the files for laser cutting enclosure
the is the files you needed to cut out the enclosure parts.

Schematics

Wire Diagram
This is the Wire diagram of GLO
Glo bb rhafeea4xt
Schematics
This is the Schematics of GLO
Glo schem cezlz80xeb

Code

Arduino Code For GLOArduino
this the code you need to upload into your ESP8266 board using arduino IDE.
/*
===============================================================================
|                     GLO: IoT Smart Light   by suhail_jr                     |
===============================================================================
*/
// libraries

#include <CayenneMQTTESP8266.h>
#include <ESP8266WiFi.h>
#include <DHT.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif


#define DHTPIN 4 // setting dht11 pin
#define DHTTYPE DHT11// setting type of the dht

#define PIN D5 // neopixel pin conected to d5
#define NUMPIXELS 12 // number of leds in neopixel ring
#define buzzer D7// set buzzer pin



DHT dht(DHTPIN, DHTTYPE);// object for dht11
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);// object for neopixel


 
char ssid[] = "your ssid"; 
char password[] = "wifi password";
char username[] = "cayenne-username"; 
char mqtt_password[] = "cayenne-mqtt-password";
char client_id[] = "cayenne-client-id";


const int LDRpin = A0;// ldr pin
const int PIRpin = D0;// pir pin
int LDRval = 0;// for reading ldr value
int PIRval = 0;// for reading pir value 
int temp;// for reading temperature value from dht11
int hum;// for reading humidity value from dht11

int r,g,b;// variables for storing red green and blue led mix values
int Cmode;// variable for storing security mode activate or deactivate
int TURN;// variable for manuale mode
int SAFE_MODE;// variable for false safe mode


void setup() 
  { 
pinMode(LDRpin,INPUT);// .....|
pinMode(PIRpin,INPUT);//......| Seting sensors and modules input or output
pinMode(buzzer,OUTPUT);//.....|
dht.begin();// starting dht11 sensor
Serial.begin(9600);
Cayenne.begin(username,mqtt_password,client_id,ssid,password);// starting cayenne 
pixels.begin(); // start neopixel ring
Serial.println("FIRE FLY BOOTED");
  
   }

  
void loop() 
{ 
   Cayenne.loop(); 
  
   // checking secuirity mode activated!
   
   if(Cmode==1)
  {
    buglerMode();// if secuirity mode active will call bugler mode function
  }
  else if(Cmode<1){
    setLight();// if not active then call setlight function
    
  }
  
hum = dht.readHumidity();// storing humidity value to hum variable
temp = dht.readTemperature();//storing temperature value to temp variable
LDRval = analogRead(LDRpin);// read and store ldr value
PIRval = digitalRead(PIRpin); // read and store pir value
Serial.println(PIRval);

// send all sensor values to cayenne
       Cayenne.virtualWrite(0,temp);
       Cayenne.virtualWrite(1,hum);
       Cayenne.virtualWrite(2,LDRval);
       Cayenne.virtualWrite(3,PIRval);
       
       
// checking temperature or humidity is in dangerous level       
if(hum>85&&hum<15){
  digitalWrite(buzzer,HIGH);
}
 if(temp>40&&temp<10)
  {
    digitalWrite(buzzer,HIGH);
  }

 // checking false safe mode      
 if(SAFE_MODE==1)
  {
    digitalWrite(buzzer,LOW);
  }
  
}

void setColor(int red,int green,int blue)
{
  for(int i =0;i<=NUMPIXELS;i++)// set every led into the color
  {
    pixels.setPixelColor(i,pixels.Color(red,green,blue));// seting color neopixel
 
    pixels.show();// activate neopixel
  }
}


void setLight()// checking manual mode active or not
{

if(TURN==1)
{
  manual();
}

  else
  {
     if(PIRval>0)
{
  setColor(r,g,b);
}
else if(LDRval<30)
{
  setColor(r,g,b);
}

else if(PIRval<1&&LDRval>10)
{
  setColor(0,0,0);
}

}
}


void buglerMode()// bugler mode's function
{

  if(SAFE_MODE==1)
  {
    digitalWrite(buzzer,LOW);
  }

  
  if(PIRval>0)

{
  
  digitalWrite(buzzer,HIGH);
  Serial.println("bugler on");
}

 
}


 void manual()// manual mod's function
 {

   setColor(r,g,b);
 }

//recieve values from cayenne
 
    CAYENNE_IN(4)
{

  r= getValue.asInt();// recieve red value for neopixel from cayenne
   
 
}
CAYENNE_IN(5)
{

  g= getValue.asInt();// recieve green value for neopixel from cayenne
  
   
}


 CAYENNE_IN(6)
{

  
   
    b= getValue.asInt();// recieve blue value for neopixel from cayenne

}

CAYENNE_IN(7)
{
  Cmode =getValue.asInt();// recieve commands for security mode
Serial.println(Cmode);
}

CAYENNE_IN(8)
{
  TURN = getValue.asInt();// recieve commands for manual mode
}

CAYENNE_IN(9)
{
  SAFE_MODE = getValue.asInt();// recieve commands for false safe
}

//------------------------GLO -v1.0---------------------------------------------- 

  

Credits

30271451 htqifi9hfd
suhail jr

Maker and electronics enthusiast

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

Add projectSign up / Login