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

Arduino UNO and ESP8266 Based Smart Food Monitoring System

View and Edit Project In Cirkit DesignerImage of Arduino UNO and ESP8266 Based Smart Food Monitoring System

Circuit Documentation

Summary

This circuit is designed to monitor environmental parameters such as light intensity, gas concentration, temperature, and humidity. It utilizes an Arduino UNO as the main microcontroller to process sensor data and control a 16x2 LCD display for output. The circuit includes an LDR module for light sensing, an MQ-3 breakout module for detecting alcohol gas levels, a DHT22 sensor for measuring temperature and humidity, and a rotary potentiometer to adjust the LCD contrast. An ESP8266 NodeMCU is also included, potentially for wireless communication capabilities.

Component List

Arduino UNO

LDR Module 3 pin

MQ-3 Breakout

DHT22

16X2 LCD

Rotary Potentiometer

ESP8266 NodeMCU

Wiring Details

Arduino UNO

LDR Module 3 pin

MQ-3 Breakout

DHT22

16X2 LCD

Rotary Potentiometer

ESP8266 NodeMCU

Documented Code

Arduino UNO Code (sketch.ino)

#include <LiquidCrystal.h>
#include "DHT.h"  // Include DHT sensor library

LiquidCrystal lcd(10, 9, 5, 4, 3, 2);  // Initialize the LCD: RS, E, D4, D5, D6, D7
#define DHTTYPE DHT11
#define LDR_PIN A1
#define MQ3_PIN A0
DHT dht(8, DHTTYPE);  // Initialize DHT sensor on pin 8

// Variables to store sensor readings
float t = 0;  // Temperature
float h = 0;  // Humidity
int ldr_read = 0;  // LDR sensor value
int gas_read = 0;  // MQ3 sensor value

void setup() {
  lcd.begin(16, 2);  // Initialize the LCD with 16 columns and 2 rows
  dht.begin();  // Initialize the DHT sensor
  
  // Display initial message on the LCD
  lcd.setCursor(0, 0);
  lcd.print(" IoT Based Smart");
  lcd.setCursor(0, 1);
  lcd.print(" Food Monitoring");

  Serial.begin(9600);  // Initialize Serial communication for debugging
  delay(2000);  // Wait for 2 seconds before starting sensor readings
}

void loop() {
  lcd.clear();  // Clear the LCD screen

  // Read LDR and MQ3 sensor values
  ldr_read = 1023 - analogRead(LDR_PIN);  // LDR sensor reading
  gas_read = analogRead(MQ3_PIN);  // MQ3 sensor reading

  // Display LDR and MQ3 sensor values on the LCD
  lcd.setCursor(0, 0);
  lcd.print("LDR-");
  lcd.setCursor(4, 0);
  lcd.print(ldr_read);

  lcd.setCursor(0, 1);
  lcd.print("MQ3-");
  lcd.setCursor(4, 1);
  lcd.print(gas_read);

  // Read temperature and humidity from DHT sensor
  t = dht.readTemperature();  // Temperature in Celsius
  h = dht.readHumidity();  // Humidity percentage

  // Display temperature and humidity on the LCD
  lcd.setCursor(8, 0);
  lcd.print("Tem-");
  lcd.setCursor(12, 0);
  lcd.print(t);

  lcd.setCursor(8, 1);
  lcd.print("Hum-");
  lcd.setCursor(12, 1);
  lcd.print(h);

  // Debugging: Print sensor values to the Serial monitor
  Serial.print("Temperature = ");
  Serial.println(t);
  Serial.print("Humidity = ");
  Serial.println(h);
  Serial.print("LDR = ");
  Serial.println(ldr_read);
  Serial.print("MQ3 = ");
  Serial.println(gas_read);

  delay(2000);  // Wait for 2 seconds before updating the screen again
}

This code is responsible for reading sensor data from the LDR, MQ-3, and DHT22 sensors, displaying the readings on the 16x2 LCD, and outputting the data to the serial monitor for debugging purposes. The LCD is initialized with the appropriate pins, and the DHT sensor is set up with its type and connected pin. The loop function continuously reads sensor values, updates the LCD, and prints the data to the serial monitor.