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

Arduino and ESP8266-Based Smart Monitoring System with Wi-Fi Connectivity

View and Edit Project In Cirkit DesignerImage of Arduino and ESP8266-Based Smart Monitoring System with Wi-Fi Connectivity

Circuit Documentation

Summary

This circuit integrates an Arduino UNO, an ESP8266 NodeMCU, various sensors (temperature, vibration, current, and IR), a DC motor, and a motor driver. The Arduino UNO reads data from the sensors and controls the motor driver, while the ESP8266 NodeMCU handles Wi-Fi communication and uploads sensor data to ThingSpeak.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. Temperature Sensor (LM35)

    • Description: A precision centigrade temperature sensor.
    • Pins: +Vs, Vout, GND
  3. SW-420 Vibration Sensor

    • Description: A vibration sensor module.
    • Pins: vcc, Ground, Digital output
  4. ACS712 Current Sensor 5A 20A 30A

    • Description: A current sensor module.
    • Pins: 1, 2, GND, OUT, VCC
  5. IR Sensor

    • Description: An infrared sensor module.
    • Pins: out, gnd, vcc
  6. ESP8266 NodeMCU

    • Description: A low-cost Wi-Fi microchip with full TCP/IP stack and microcontroller capability.
    • Pins: D0, D1, D2, D3, D4, 3V3, GND, D5, D6, D7, D8, RX, TX, A0, RSV, SD3, SD2, SD1, CMD, SD0, CLK, EN, RST, VIN
  7. L298N DC Motor Driver

    • Description: A dual H-bridge motor driver.
    • Pins: OUT1, OUT2, 12V, GND, 5V, OUT3, OUT4, 5V-ENA-JMP-I, 5V-ENA-JMP-O, +5V-J1, +5V-J2, ENA, IN1, IN2, IN3, IN4, ENB
  8. DC Motor

    • Description: A simple DC motor.
    • Pins: pin 1, pin 2
  9. Power Supply

    • Description: A power supply module.
    • Pins: +, -

Wiring Details

Arduino UNO

ESP8266 NodeMCU

SW-420 Vibration Sensor

Temperature Sensor (LM35)

ACS712 Current Sensor 5A 20A 30A

IR Sensor

L298N DC Motor Driver

DC Motor

Power Supply

Documented Code

Arduino UNO Code

#include <SoftwareSerial.h>

// NodeMCU Communication
SoftwareSerial NodeMCU(2, 3); // RX, TX

// Sensor Pins
const int tempPin = A0;
const int vibrationPin = 2;
const int currentPin = A1;
const int speedPin = 3;

// Variables
float temperature;
int vibration;
float current;
int speed;

void setup() {
  Serial.begin(9600);
  NodeMCU.begin(9600);

  pinMode(vibrationPin, INPUT);
  pinMode(speedPin, INPUT);

  Serial.println("System Initialized");
}

void loop() {
  // Read temperature
  temperature = analogRead(tempPin) * (5.0 / 1023.0) * 100;

  // Read vibration
  vibration = digitalRead(vibrationPin);

  // Read current
  current = analogRead(currentPin) * (5.0 / 1023.0);

  // Read speed
  speed = pulseIn(speedPin, HIGH);

  // Send data to NodeMCU
  String data = "T:" + String(temperature) + ",V:" + String(vibration) + ",C:" + String(current) + ",S:" + String(speed);
  NodeMCU.println(data);

  // Debug
  Serial.println(data);

  delay(1000);
}

ESP8266 NodeMCU Code

#include <ESP8266WiFi.h>
#include <ThingSpeak.h>

// Wi-Fi credentials
const char* ssid = "Your_SSID";
const char* password = "Your_PASSWORD";

// ThingSpeak API
unsigned long channelID = YOUR_CHANNEL_ID;
const char* apiKey = "YOUR_API_KEY";
WiFiClient client;

void setup() {
  Serial.begin(9600);
  WiFi.begin(ssid, password);

  Serial.println("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }
  Serial.println("\nConnected to Wi-Fi");

  ThingSpeak.begin(client);
}

void loop() {
  if (Serial.available()) {
    String data = Serial.readString();
    Serial.println("Data received: " + data);

    // Parse data
    int tIndex = data.indexOf("T:") + 2;
    int vIndex = data.indexOf("V:") + 2;
    int cIndex = data.indexOf("C:") + 2;
    int sIndex = data.indexOf("S:") + 2;

    float temperature = data.substring(tIndex, data.indexOf(",V:")).toFloat();
    int vibration = data.substring(vIndex, data.indexOf(",C:")).toInt();
    float current = data.substring(cIndex, data.indexOf(",S:")).toFloat();
    int speed = data.substring(sIndex).toInt();

    // Upload to Thing