Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Wi-Fi Connected Air Quality Monitor with Arduino UNO and ESP32

Image of Wi-Fi Connected Air Quality Monitor with Arduino UNO and ESP32

Circuit Documentation

Summary

The circuit in question is designed to integrate an Arduino UNO with an ESP32 microcontroller, an MQ-3 alcohol sensor breakout, and a Tower Pro SG90 servo motor. The Arduino UNO serves as the primary microcontroller, interfacing with the sensor and the servo motor. The ESP32 is used for wireless communication capabilities, potentially to send sensor data to a remote server. The MQ-3 sensor detects alcohol levels, and the servo motor is likely used for some form of physical response or indication. The circuit is powered through the Arduino UNO's 5V and GND pins, which also provide power to the servo motor and the MQ-3 sensor.

Component List

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P.
  • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13.

ESP32 (30 pin)

  • Description: A microcontroller with Wi-Fi and Bluetooth capabilities.
  • Pins: EN, VP, VN, D34-D35, D32-D33, D25-D27, D14-D15, D12-D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, 3V3.

MQ-3 Breakout

  • Description: An alcohol gas sensor module.
  • Pins: VCC, GND, DO, AO.

Tower Pro SG90 servo

  • Description: A small and lightweight servo motor for RC vehicles and other hobbyist projects.
  • Pins: Signal, +5V, GND.

Wiring Details

Arduino UNO

  • 5V: Provides power to the Tower Pro SG90 servo and the MQ-3 Breakout.
  • GND: Common ground with the MQ-3 Breakout, ESP32, and Tower Pro SG90 servo.
  • A0: Receives analog input from the MQ-3 Breakout AO pin.
  • D9: Sends PWM signal to the Tower Pro SG90 servo Signal pin.
  • D0: Connected to ESP32 TX2 pin for serial communication.
  • D1: Connected to ESP32 RX2 pin for serial communication.

ESP32 (30 pin)

  • GND: Common ground with the Arduino UNO and Tower Pro SG90 servo.
  • RX2: Receives serial data from Arduino UNO D1 pin.
  • TX2: Sends serial data to Arduino UNO D0 pin.

MQ-3 Breakout

  • VCC: Powered by the Arduino UNO 5V pin.
  • GND: Common ground with the Arduino UNO.
  • AO: Sends analog output to Arduino UNO A0 pin.

Tower Pro SG90 servo

  • +5V: Powered by the Arduino UNO 5V pin.
  • GND: Common ground with the Arduino UNO and ESP32.
  • Signal: Receives PWM control signal from Arduino UNO D9 pin.

Documented Code

Arduino UNO Code

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

}

void loop() {
  // put your main code here, to run repeatedly:

}

File: sketch.ino

ESP32 Code

#include <WiFi.h>
#include <HTTPClient.h>

const char* ssid = "YourSSID"; // Your WiFi SSID
const char* password = "YourPassword"; // Your WiFi Password
const char* serverName = "YourServerURL"; // Remote server URL

void setup() {
  Serial.begin(115200); // Serial communication for ESP32
  Serial2.begin(115200, SERIAL_8N1, 16, 17); // Serial communication to Arduino (adjust pins if needed)

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }

  Serial.println("Connected to WiFi.");
}

void loop() {
  if (Serial2.available() > 0) {
    int sensorValue = Serial2.parseInt(); // Read sensor data from Arduino
    Serial.print("Received Sensor Value: ");
    Serial.println(sensorValue);

    if (WiFi.status() == WL_CONNECTED) {
      HTTPClient http;
      String url = String(serverName) + "?status=SensorData&value=" + String(sensorValue);
      http.begin(url.c_str());

      int httpResponseCode = http.GET();

      // Print response
      if (httpResponseCode > 0) {
        String response = http.getString();
        Serial.println("HTTP Response code: " + String(httpResponseCode));
        Serial.println("Server Response: " + response);
      } else {
        Serial.println("Error on HTTP request: " + String(httpResponseCode));
      }

      http.end();
    } else {
      Serial.println("WiFi Disconnected");
    }

    delay(2000); // Delay to avoid overwhelming requests
  }
}

File: sketch.ino