Omar Cruz
Published © GPL3+

Monitoring of Indoor environmental conditions

Internal environmental conditions in an office are crucial for the health of employees, with this project you will discover how check them.

IntermediateFull instructions providedOver 1 day14
Monitoring of Indoor environmental conditions

Things used in this project

Hardware components

Grove - Air quality sensor v1.3
Seeed Grove - Air quality sensor v1.3
×3
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×2
The Things Uno
The Things Network The Things Uno
×3
The Things Network The Things Indoor Gateway
×1

Software apps and online services

Ubuntu Operative System
Arduino IDE
Arduino IDE
myDevices

Story

Read more

Schematics

Schematic - Node

Code

Code for each one of the nodes

Arduino
#include <TheThingsNetwork.h>
#include <CayenneLPP.h>
#include <DHT.h>

// Set your AppEUI and AppKey
const char *appEui = "TO COMPLETE WITH YOUR VALUE";
const char *appKey = "TO COMPLETE WITH YOUR VALUE";

#define loraSerial Serial1
#define debugSerial Serial

// Replace REPLACE_ME with TTN_FP_EU868 or TTN_FP_US915
#define freqPlan TTN_FP_EU868
#define DHTPIN 2

//Choose your DHT sensor moddel
#define DHTTYPE DHT11
//#define DHTTYPE DHT21
//#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

TheThingsNetwork ttn(loraSerial, debugSerial, freqPlan);
CayenneLPP lpp(51);

void setup()
{
  loraSerial.begin(57600);
  debugSerial.begin(9600);

  // Wait a maximum of 10s for Serial Monitor
  while (!debugSerial && millis() < 10000)
    ;

  debugSerial.println("-- STATUS");
  ttn.showStatus();

  debugSerial.println("-- JOIN");
  ttn.join(appEui, appKey);

  dht.begin();
  
  delay(5000);
}

void loop()
{
  debugSerial.println("-- LOOP");
  lpp.reset();

  // false: Celsius (default)
  // true: Farenheit
  uint16_t temperature = dht.readTemperature(false) * 1;
  uint16_t humidity = dht.readHumidity(false) * 1;

  uint16_t airquality;
  airquality=analogRead(A0);
  // And as the analog pin will expect an input from 0 to 5
  // aut the sensor will provide outputs between 0 and 3,5
  // a small escalation factor should be applied (with value of 1,43)
  Serial.println(airquality);
  Serial.println(airquality*1.43);
  airquality = (int) (airquality*1.43);
  Serial.println(airquality);  

  lpp.addTemperature(1, temperature);
  lpp.addRelativeHumidity(2, humidity);
  lpp.addLuminosity(3, airquality);
  
  ttn.sendBytes(lpp.getBuffer(), lpp.getSize());

  debugSerial.print("Temperature: ");
  debugSerial.println(temperature);
  debugSerial.print("Humidity: ");
  debugSerial.println(humidity);
  debugSerial.print("AirQuality: ");
  debugSerial.println(airquality);

  delay(600000);
}

Credits

Omar Cruz

Omar Cruz

0 projects • 0 followers
Passionate about IoT.

Comments

Add projectSign up / Login