Info Box

Introduction: Info Box

About: I build projects based around arduino. Colossians 3:17 John 3:16 plz look them up and read them it will change your life!?

This box is capable of displaying: temperature, relative humidity, distance (in centimeters and inches), and gas values such as (smoke, butane, and co). Using only an arduino uno.
Any questions or comments will be responded to.

Supplies

Parts List

(1) arduino uno

(2)breadboard

(3)jumper wires

(4) 220 resistors 2x

(5) leds 2x (green and red)

(6)lcd screen 16x2 with I2C backpack

(7)dht11 humidity sensor

(8)MQ-2 Gas sensor

(9)Ultrasonic distance sensor

Step 1: The Circuit

Second step is putting together the circuit. See diagram.

Step 2: Setting Up the Code

For the last step you need to copy and paste the code into the arduino IDE
and run the code.

Note: you may need to install additional libraries.

#include
#include
#include
#include

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

int pinDHT11 = 6;
SimpleDHT11 dht11;
const int buttonPin = 3;
const int trigPin = 9;
const int echoPin = 10;
long duration;
int distanceCm, distanceInch;
int Analog_Input = A0;
int lpg, co, smoke;
MQ2 mq2(Analog_Input);


int redLed = 4;
int greenLed = 3;


void setup() {

lcd.begin(16,2);
lcd.clear();
lcd.print("Starting Up In:3");
delay(1000);
lcd.clear();
lcd.print("Starting Up In:2");
delay(1000);
lcd.clear();
lcd.print("Starting Up In:1");
delay(1000);
lcd.clear();


pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);

lcd.backlight();
mq2.begin();

pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}

void loop() {

// Create variables for DHT sensor output.
byte temperature = 0;
byte humidity = 0;

// Read sensor data and store results
// in temperature/humidity variables
dht11.read(pinDHT11, &temperature, &humidity, NULL);

// Print first line to LCD
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(round(temperature));
lcd.print("C / ");
lcd.print(round(temperature * 1.8 + 32));
lcd.print("F "); // two extra spaces in case temps drop to single digits

// Print second line to LCD
lcd.setCursor(0,1);
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print("% "); // extra space in case humidity drops to single digit

// Delay 1 second because DHT11 sampling rate is 1HZ.
delay(2000);
lcd.clear();



digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distanceCm= duration*0.034/2;
distanceInch = duration*0.0133/2;

lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("Distance: "); // Prints string "Distance" on the LCD
lcd.print(distanceCm); // Prints the distance value from the sensor
lcd.print("cm");
delay(10);
lcd.setCursor(0,1);
lcd.print("Distance: ");
lcd.print(distanceInch);
lcd.print("inch");
delay(2000);
lcd.clear();



float* values= mq2.read(false); //set it false if you don't want to print the values in the Serial
//lpg = values[0];
lpg = mq2.readLPG();
//co = values[1];
co = mq2.readCO();
//smoke = values[2];
smoke = mq2.readSmoke();
lcd.setCursor(0,0);
lcd.print("LPG:");
lcd.print(lpg);
lcd.print(" CO:");
lcd.print(co);
lcd.setCursor(0,1);
lcd.print("SMOKE:");
lcd.print(smoke);
lcd.print(" PPM");
delay(2000);
lcd.clear();

if (co > 69)
{
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);

} else {
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);

}

}

Sensors Contest

Participated in the
Sensors Contest

Be the First to Share

    Recommendations

    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge
    • Space Contest

      Space Contest
    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge

    Comments

    0
    seamster
    seamster

    2 years ago

    Thanks for sharing! : )