Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino and ESP8266 Based Environmental Monitoring System with LoRa Communication

View and Edit Project In Cirkit DesignerImage of Arduino and ESP8266 Based Environmental Monitoring System with LoRa Communication

Circuit Documentation

Summary

The circuit in question is a multifunctional system designed to interface with various sensors and communication modules. It includes an Arduino 101 microcontroller as the central processing unit, interfacing with a DHT11 temperature and humidity sensor, a GP2Y1010AU0F dust sensor, a LoRa Ra-02 SX1278 module for long-range communication, an ESP8266 NodeMCU for Wi-Fi capabilities, and a buzzer for audible alerts. The circuit is powered by a 3.3V supply, which is distributed to the necessary components, and a 5V supply for specific sensors. The Arduino 101 also communicates with the ESP8266 NodeMCU via serial connection for data exchange.

Component List

DHT11 Sensor V2

Arduino 101

GP2Y1010AU0F

Resistor

LoRa Ra-02 SX1278

ESP8266 NodeMCU

Buzzer

Wiring Details

DHT11 Sensor V2

Arduino 101

GP2Y1010AU0F

LoRa Ra-02 SX1278

ESP8266 NodeMCU

Buzzer

Documented Code

Arduino 101 Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <RTClib.h>
#include <SPI.h>
#include <LoRa.h>
#include <SoftwareSerial.h>

// LCD Setup
LiquidCrystal_I2C lcd(0x27, 16, 2);

// DHT Sensor Setup
#define DHTPIN 7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

// Dust Sensor Setup
#define measurePin A0
#define ledPower 7
int samplingTime = 280;
int deltaTime = 40;
int sleepTime = 9680;
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;

// RTC Setup
RTC_DS1307 rtc;

// LoRa and ESP8266 Setup
#define NSS  10
#define RST  9
#define DIO0 8
SoftwareSerial espSerial(0, 1);  // RX, TX for ESP8266

// Buzzer Setup
const int buzzer = 9;

// Variables
int num = 0;

void setup() {
  Serial.begin(115200);

  // LCD Init
  lcd.init();
  lcd.backlight();

  // DHT Init
  dht.begin();

  // RTC Init
  if (!rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }

  // LoRa Init
  LoRa.setPins(NSS, RST, DIO0);
  if (!LoRa.begin(433E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }

  // ESP8266 Init
  espSerial.begin(9600);

  // Buzzer Init
  pinMode(buzzer, OUTPUT);

  // Dust Sensor Init
  pinMode(ledPower, OUTPUT);

  // Initial Display on LCD
  lcd.setCursor(0, 0);
  lcd.print("System Starting");
  delay(2000);
}

void loop() {
  // Time from RTC
  DateTime now = rtc.now();

  // Temperature and Humidity from DHT
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  // Dust Sensor Reading
  digitalWrite(ledPower, LOW);
  delayMicroseconds(samplingTime);
  voMeasured = analogRead(measurePin);
  delayMicroseconds(deltaTime);
  digitalWrite(ledPower, HIGH);
  delayMicroseconds(sleepTime);
  calcVoltage = voMeasured * (5.0 / 1024.0);
  dustDensity = 170 * calcVoltage - 0.1;

  // Buzzer Alert
  tone(buzzer, 1000);
  delay(1000);
  noTone(buzzer);
  delay(1000);

  // Display on LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Time: ");
  lcd.print(now.hour());
  lcd.print(":");
  lcd.print(now.minute());
  lcd.print(":");
  lcd.print(now.second());

  lcd.setCursor(0, 1);
  lcd.print("Temp: ");
  lcd.print(t);
  lcd.print(" C");

  lcd.setCursor(0, 2);
  lcd.print("Humidity: ");
  lcd.print(h);
  lcd.print(" %");

  lcd.setCursor(0, 3);
  lcd.print("Dust: ");
  lcd.print(dustDensity);

  // LoRa Communication
  LoRa.beginPacket();
  LoRa.print("Data: Temp=");
  LoRa.print(t);
  LoRa.print(", Humidity=");
  LoRa.print(h);
  LoRa.print(", Dust=");
  LoRa.print(dustDensity);
  LoRa.endPacket();

  // ESP8266 Data Reception
  if (espSerial.available()) {
    String data = espSerial.readString();
    Serial.println("Data from ESP8266: " + data);
  }

  // Update every 2 seconds
  delay(2000);
}

DHT11 Sensor V2 Code

void setup() {
  // put your setup code here, to run