Gas Sensor Reading with Arduino 7 Segment Display

Before combining the gas sensor and 7 segment displays, let's learn about the 7 segment display;

7 What is Segment Display?

gas sensorEach of the 7 LEDsin the structure of the element is called a segment. Because the cutting forms of numerical figures (on the bases of tens and sixteens) are illuminated in pieces for display. In addition, the structure of the 7 Segment Display has an additional 1 LED. This LED is used to show decimal points of redundant numbers in numerical indicators. This additional LED is called DP(Decimal Point),which means decimal point in simulations or on the element's datasheet.

What is the MQ-4 Gas Sensor?

Tin oxide (SnO2) within the operating principle of the MQ-4 gas sensor is a type of alloy that has low conductivity in the fresh air and increased conductivity according to the ratio of certain gases such as methane (CH4), carbon dioxide (CO2), propane, carbon monoxide, and so on. gas sensor gas sensor The types of gases in which tin oxide is sensitive to its component vary. The MQ-4 model we will examine is designed to respond to methane gas to excess and alcohol and carbon dioxide relatively less to other gases. In addition; it gives analog output, can draw current up to 900mA and can heat up during operation, this is because it has a heating circuit, it may not be safe to feed through arduino for healthy projects. You can also read our article here to learn about the other MQ-x and AQ-x Series Gas sensor. Now that we have learned the necessary information on the two sensors, we will write and take data from our Gas sensor and transfer it to our LED with the 7 Segment 4 Digit LED Display with TMT1637 driver chip. Under normal circumstances, we need to use 12 pins to use 4 Digit 7 Segment LEDi, but with the TM1637 driver we can reduce the number of pins to 4Pcs, as well as do the same by using bit-shifting method. It is worth noting that our MQ-4 Gas sensor is used on the circuit with the LM393 opamp comparator. Arduino Library for TM1637 It is worth noting that this library supports up to 8 Segments digits starting with digits 0, i.e. when performing suppression function; 0 1 2 3 — 4 For Segment Displays 0 1 2 3 4 5 6 7 — 8 For Segment Displays

Circuit Diagram;

gas sensor

Project Id;

#include "TM1637.h"
#define CLK 3
#define DIO 2
TM1637 tm1637(CLK, DIO);
int smokeA0 = A0;

void setup() {
  pinMode(smokeA0, INPUT);
  tm1637.set(7);//BRIGHT_TYPICAL = 2.BRIGHT_DARKEST = 0.BRIGHTEST = 7;

void loop() {
  int analogSensor = analogRead(smokeA0);
  Serial.print("Pin A0: ");
 int digitbir = (analogSensor / 100)10%;
 int digitiki = (analogSensor / 10)10%;
 int digituc = analogSensor 10%;
 delay (500); 



Code Description;

I go through the classic identification and pin stating processes, the important thing in this regard is that the gas sensor is necessarily connected to the analog input. tm1637.set(7);  In this line we adjust the brightness of the LED display the maximum value is 7 and the minimum value is 0. The default value comes in at 2. int analogSensor = analogRead(smokeA0);  Here we print it to the valuable analogSensor from our sensor. Our Serial.print and Serial connection is just to test it, so we don't need it in the project. int digitbir = (analogSensor / 100)10%;  In this line, we make a procedure for the first part of our 4 digit LED, that is, for the faces step. int digitiki = (analogSensor / 10)10%;  In this line, we make a transaction for the second part of our LED, that is, they step. int digituc = analogSensor 10%;  Here we have the third part of our LED, the one digit, processed. example for descriptive operations; Whether our analogue value is 436, we find the face digit of this number, divide the number by 100 and give us the step of faces when we get mod10 436/100 = 4.36 mod10 = 4 variables, so we ignore the value after the comma. When they find the step, they divide it by 10 and get mod10, they will give us the step. Because we define int as a 436/10= 43.6 mod10=3 variable, we ignore the value after the comma. We only need to get mod10 for the one digit 436 mod10=6 so we get 6 from 4 second transactions from the first operation and 6 from the third. tm1637.display(0,digitbir); In this line, we print "digitbir" in the 0th digit of ledin with the TM1637 library. tm1637.display(1,digitiki); In this line, we print "digitiki" in the 1st digit of ledin with the TM1637 library. tm1637.display(2,digituc); In this line, we print "digituc" in the 1st digit of ledin with the TM1637 library. finally, we finish our code with the defeat time, i.e. delay, and the final version of our project is as follows; I used Arduino Pro Mini as the card, there is no difference in function with other Arduino cards.

gas sensorclean air value, you can change the resolution with the adjusted resistance behind the sensor

gas sensorWith the release of LPG (liquefied propane gas), the value of the LED display has been increased.