Arduino UNO Based Smart Diaper Moisture and Gas Monitoring System
View and Edit Project In Cirkit Designer
Smart Diaper Management System Circuit Documentation
Summary
The Smart Diaper Management System is designed to monitor moisture and gas levels using an Arduino UNO as the central processing unit. The system integrates a soil moisture sensor (SparkFun gator:soil) and a gas sensor (MQ-5) to detect the respective levels. The moisture sensor's signal is connected to the Arduino's analog input A0, while the gas sensor's analog output is connected to A1 and its digital output to digital pin D2. The Arduino reads the sensor values and outputs the data to the Serial Monitor. If the moisture or gas levels exceed predefined thresholds, an alert is triggered.
Component List
Arduino UNO
- Microcontroller board based on the ATmega328P
- It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.
SparkFun gator:soil
- Soil moisture sensor
- It measures the volumetric content of water inside the soil and outputs the reading as an analog signal.
MQ-5 Gas Sensor
- Gas sensor for detecting LPG, natural gas, and coal gas
- It has both digital and analog outputs.
XBee Pro S2C
- Wireless communication module
- Not connected in the current circuit configuration.
Wiring Details
Arduino UNO
- 5V pin is connected to the VCC pins of both the SparkFun gator:soil and MQ-5 sensors.
- GND pin is connected to the GND pins of both sensors.
- A0 pin is connected to the SIG pin of the SparkFun gator:soil sensor.
- A1 pin is connected to the Analog out pin of the MQ-5 sensor.
- D2 pin is connected to the Digi Out pin of the MQ-5 sensor.
SparkFun gator:soil
- VCC pin is connected to the 5V output from the Arduino UNO.
- GND pin is connected to the ground (GND) on the Arduino UNO.
- SIG pin is connected to the A0 analog input on the Arduino UNO.
MQ-5 Gas Sensor
- VCC pin is connected to the 5V output from the Arduino UNO.
- GND pin is connected to the ground (GND) on the Arduino UNO.
- Analog out pin is connected to the A1 analog input on the Arduino UNO.
- Digi Out pin is connected to the D2 digital input on the Arduino UNO.
Documented Code
/*
* Smart Diaper Management System
* This Arduino sketch interfaces with a soil moisture sensor and a gas sensor
* to monitor moisture and gas levels in a smart diaper. The soil moisture
* sensor is connected to analog pin A0, and the gas sensor is connected to
* analog pin A1 (analog output) and digital pin 2 (digital output). The system
* reads the sensor values and prints them to the Serial Monitor. If moisture or
* gas levels exceed certain thresholds, an alert is triggered.
*/
const int moistureThreshold = 500; // Example threshold for moisture level
const int gasAnalogThreshold = 300; // Example threshold for gas level (analog)
const int gasDigitalThreshold = HIGH; // Example threshold for gas level (digital)
void setup() {
Serial.begin(9600);
pinMode(A0, INPUT); // Soil moisture sensor
pinMode(A1, INPUT); // Gas sensor analog output
pinMode(2, INPUT); // Gas sensor digital output
}
void loop() {
int moistureValue = analogRead(A0); // Read moisture level
int gasAnalogValue = analogRead(A1); // Read gas level (analog)
int gasDigitalValue = digitalRead(2); // Read gas level (digital)
// Print values to Serial Monitor
Serial.print("Moisture Level: ");
Serial.println(moistureValue);
Serial.print("Gas Level (Analog): ");
Serial.println(gasAnalogValue);
Serial.print("Gas Level (Digital): ");
Serial.println(gasDigitalValue);
// Check if moisture level exceeds threshold
if (moistureValue > moistureThreshold) {
Serial.println("Alert: Moisture level too high!");
}
// Check if gas level (analog) exceeds threshold
if (gasAnalogValue > gasAnalogThreshold) {
Serial.println("Alert: Gas level (analog) too high!");
}
// Check if gas level (digital) exceeds threshold
if (gasDigitalValue == gasDigitalThreshold) {
Serial.println("Alert: Gas level (digital) too high!");
}
delay(1000); // Wait for 1 second before next reading
}
This code is designed to be uploaded to the Arduino UNO microcontroller. It initializes the sensor inputs and continuously reads the moisture and gas levels, comparing them against set thresholds. If the readings exceed these thresholds, the system outputs an alert to the Serial Monitor.