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

ESP8266 NodeMCU-Based Environmental Monitoring and Health Tracking System with Wi-Fi Connectivity

View and Edit Project In Cirkit DesignerImage of ESP8266 NodeMCU-Based Environmental Monitoring and Health Tracking System with Wi-Fi Connectivity

Circuit Documentation

Summary

The circuit in question is designed to monitor environmental parameters such as temperature, humidity, gas levels, and also includes health monitoring features like heart rate and blood oxygen saturation (SpO2) measurement. It utilizes an ESP8266 NodeMCU as the central microcontroller unit, interfaced with various sensors including a DHT11 for temperature and humidity, an MQ6 gas sensor, a MAX30102 sensor for heart rate and SpO2, and additional components like a buzzer, a vibration motor, and motor drivers for actuation purposes. The circuit is powered by a Polymer Lithium Ion Battery and includes a motor driver to control DC motors, presumably for a mobile platform.

Component List

Wiring Details

ESP8266 NodeMCU

MAX30102 HR + SpO2 Sensor

DHT11

MQ6 Gas Sensor

Buzzer Module

PWM Vibration Motor Sensor Module Switch

Polymer Lithium Ion Battery - 850mAh

L298N DC Motor Driver

Gearmotor DC Wheels

2 x AA Battery Mount

Alligator Clip Cables

Rocker Switch

Documented Code

Main Sketch (sketch.ino)

#define BLYNK_TEMPLATE_ID "TMPL308E2KguH"
#define BLYNK_TEMPLATE_NAME "Tempruture and Humidity"
#define BLYNK_AUTH_TOKEN "Lt4kGTEKtDbmMKvszIJ2ACijS7lG3LpN"

#define BLYNK_PRINT Serial
#include <DHT.h>
#include <Wire.h>
#include <Blynk.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#include <MAX3010x.h>
#include "filters.h"

char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Ananda"; // Change your Wifi/ Hotspot Name
char pass[] = "123456789"; // Change your Wifi/ Hotspot Password

BlynkTimer timer;

#define DHTPIN D5          // What digital pin we're connected to
// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

int motorPin = D6; // vibration Motor
DHT dht(DHTPIN, DHTTYPE); //dht11 Sensor
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).

#define MQ5 A0
#define buzzer  D7
int MQ5_Val = 0;

WidgetLED led(V8);

// Sensor (adjust to your sensor type)
MAX30102 sensor;
const auto kSamplingRate = sensor.SAMPLING_RATE_400SPS;
const float kSamplingFrequency = 400.0;

// Finger Detection Threshold and Cooldown
const unsigned long kFingerThreshold = 10000;
const unsigned int kFingerCooldownMs = 500;

// Edge Detection Threshold (decrease for MAX30100)
const float kEdgeThreshold = -2000.0;

// Filters
const float kLowPassCutoff = 5.0;
const float kHighPassCutoff = 0.5;

// Averaging
const bool kEnableAveraging = false;
const int kAveragingSamples = 5;
const int kSampleThreshold = 5;

void setup()
{
  // Debug console
  Serial.begin(9600);
  
  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  pinMode(motorPin, OUTPUT );
  pinMode(buzzer, OUTPUT);

  if(sensor.begin() && sensor.setSamplingRate(kSamplingRate)) { 
    Serial.println("Sensor initialized");
  }
  else {
    Serial.println("Sensor not found");  
    while(1);
  }

  
  dht.begin();
  
  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
  delay(2000);
  timer.setInterval(1000L, mySensor);
}

// Filter Instances
LowPassFilter low_pass_filter_red(kLowPassCutoff, kSamplingFrequency);
LowPassFilter low_pass_filter_ir(kLowPassCutoff, kSamplingFrequency);
HighPassFilter high_pass_filter(kHighPassCutoff, kSamplingFrequency);
Differentiator differentiator(kSamplingFrequency);
MovingAverageFilter<kAveragingSamples> averager_b