In this tutorial, we will integrate Surilli WiFi with MQ135 Gas Sensor and the changing values of the sensor will be recorded in Excel using a tool named "Tera Term."
Required Hardware- Surilli WiFi.
- MQ135 Gas Sensor Module
- Connecting wires
- Arduino IDE software
- Tera Term Tool: This software will be used to read the values from MQ135 Sensor and then store these values in Excel
The MQ135 Sensor Module consists of a steel exoskeleton under which a sensing element is housed. This sensing element is subjected to current through connecting leads. This current is known as heating current through it, the gases coming close to the sensing element get ionized and are absorbed by the sensing element. This changes the resistance of the sensing element which alters the value of the current going out of it.
The MQ-135 gas sensor senses the gases like ammonia nitrogen, oxygen, alcohols, aromatic compounds, sulfide and smoke. The operating voltage of this gas sensor is from 2.5V to 5.0V. MQ-135 gas sensor can be implementation to detect the smoke, benzene, steam and other harmful gases.
Working PrincipleThe MQ-135 alcohol sensor consists of a tin dioxide (SnO2), a perspective layer inside Aluminium Oxide micro tubes (measuring electrodes) and a heating element inside a tubular casing. The end face of the sensor is enclosed by a stainless steel net and the back side holds the connection terminals. Ethyl alcohol present in the breath is oxidized into acetic acid passing through the heat element. With the ethyl alcohol cascade on the tin dioxide sensing layer, the resistance decreases. By using the external load resistance the resistance variation is converted into a suitable voltage variation.
It has lower conductivity compare to clean air and due to air pollution the conductivity is increases. The air quality sensor detects ammonia, nitrogen oxide, smoke, CO2 and other harmful gases. The air quality sensor has a small potentiometer that permits the adjustment of the load resistance of the sensor circuit.
The air quality sensor is a signal output indicator instruction. It has two outputs: analog output and TTL output. The TTL output is low signal light which can be accessed through the IO ports on the microcontroller. The analog output is an concentration, i.e. increasing voltage is directly proportional to increasing concentration. The resistance of the sensor decreases as the concentration of the target gas is increased in PPM while for clean air its resistance remains constant.
The analog output voltage from the sensor can be assumed directly proportional to the concentration of CO2 gas in PPM under standard conditions. The analog voltage is sensed from the sensor and converted to a digital value in range from 0 to 1023 by the inbuilt ADC channel of the controller. The digitized value is hence equal to the gas concentration in PPM.
When no gas digital output is 1 and analog output gives 1023 max value. When gas is present digital output is 0 and analogue output is much less than 1023. Using potentiometer on chip we can control the turning OFF point of digital pin at some value of analog pin. The sensor needs a load-resistor at the output to ground. Its value could be from 2k Ohm to 47k Ohm.
The lower the value, the less sensitive is the sensor. The higher the value, the less accurate is sensor for higher concentrations of gas. If only one specific gas is measured, the load-resistor can be calibrated by applying a known concentration of that gas. If the sensor is used to measure any gas (like in a air quality detector) the load-resistor could be set for a value of about 1V output with clean air. Choosing a good value for the load-resistor is only valid after the burn-in time.
NOTE: Don’t touch the sensor, it will be very hot.
Features1. High sensitivity to Sulfide, benzene Department of steam, smoke and other harmful gases.2. Long life and low cost.3. Simple drive circuit.
From left to right first pins are as follows:
A0 Analog output
D0 Digital output
GND Ground
Vcc Supply (5V)
Specifications of MQ-135 Gas Sensor- Wide detecting scope.
- Fast response and High sensitivity.
- Stable and long life Simple drive circuit.
- Used in air quality control equipment for buildings/offices, is suitable for detecting of NH3, NOx, alcohol, Benzene, smoke, CO2, etc.
- Size: 35mm x 22mm x 23mm (length x width x height).
- Working voltage: DC 5 V.
- Signal output instruction.
- Dual signal output (analog output, and high/low digital output).
- 0 ~ 4.2V analog output voltage, the higher the concentration the higher the voltage.
Parts per million (PPM) is a unit of measurement used for expressing a very dilute concentration level of pollutants in the air, water and other fluids or one item in a million of anything of the same size. PPM is a volume-to-volume ratio.
Changes in temperature and pressure do not change the ratio of the volume of pollutant gas to the volume of air that contains it.
ConnectionsMQ135 Sensor Module with Surilli WiFi:
- -> PIN A0 (MQ135) to PIN A0 (Surilli WiFi).
- -> GND PIN (MQ135) to GND PIN (Surilli WiFi).
- -> VCC PIN (MQ135) to USB PIN (5V) (Surilli WiFi).
Tera Term is one of the more popular Windows terminal programs. It's been around for years, it's open source, and it's simple to use. For Windows users, it's one of the best options out there.
You can download any version of Tera Term from the link given below:
https://osdn.net/projects/ttssh2/releases/
I am using version v 4.103 for this project.
Making a Connection:You should initially be presented with a "Tera Term: New connection" pop-up within the program. Here, you can select which serial port you'd like to open up. Select the "Serial" radio button. Then select your port from the drop-down menu. (If this window doesn't open when you start Tera Term, you can get here by going to: File > New connection).
That'll open up the port. Tera Term defaults to setting the baud rate at 9600 bps (8-N-1). If you need to adjust the serial settings, go up to Setup > Serial Port. You'll see a window pop up with a lot of familiar looking serial port settings. Adjust what you need to and hit "OK".
The title of your Tera Term window should change to something like "COM##:9600baud" -- now that's a good sign.
That's about all there is to it. The blank window with the blinking cursor is where data is both sent (by typing it in) and received.
Tera Term Tips and TricksLocal Echo
It can be weird to type stuff in the window and not see it show up in the terminal. It's undoubtedly still flowing through the serial terminal to your device, but it can be difficult to type when you don't have any visual feedback for exactly what you're typing. You can turn on local echo by going to the Setup menu and selecting Terminal.
Check the Local echo box if you'd like to turn the feature on.
There are other settings to be made in this window as well. You can adjust the size of the terminal (the values are in terms of characters per row/column), or adjust how new-lines are displayed (either a carriage return, line feed, or both).
Clear Buffer and Clear Screen
If you want to clear your terminal screen you can use either the "Clear buffer" or "Clear screen" commands. Both are located under the Edit menu.
Clear screen will do just that, blank out the terminal screen, but any data received will still be preserved in the buffer. Scroll up in the window to have another look at it. Clear buffer deletes the entire buffer of received data -- no more data to scroll up to.
Shortcut KeysMenus are a pain! If you want to get really fast with Tera Term, remember some of these shortcuts:
- ALT+N: Connects to a new serial port.
- ALT+I: Disconnects from the current port.
- ALT+V: Pastes text from clipboard to the serial port (not CTRL+V).
- ALT+C: Copy selected text into clipboard (not CTRL+C).
- CTRL+TAB: Switch between two Tera Term windows.
Make sure you have selected the right port, board and processor for the Surilli as shown in the picture below and it is programmable (compile and upload “Blink” from File>Examples>Digital>Blink onto your Surilli to check if every thing is working fine).
STEP 2: The CircuitryThe circuitry is quite simple. Its mostly the programming. Follow the figure below to set up your hardware.
- Now you have completed setting up your hardware and Arduino IDE. Copy and paste the Arduino sketch given below into your Arduino IDE and hit upload.
- After the Arduino Code has been uploaded, open your "Tera Term" software, then click on "Serial". Against Serial, select the Port No by referring to your Arduino IDE Software and then click the "OK" button. After clicking on the OK button, the different values of air quality will start to appear on the black screen of your software.
- After that, click the "File" Tab on the upper part of the black screen of the software and select "Log". This will prompt you to save the values of Air Quality in a ".csv" format which is the extension for the Excel. Save the file with any name you want along with ".csv" and in the "Option" tab just below, check the "Time Stack" option. After that click "OK" and then you will have your values in the Excel File.
int sensorValue;
void setup()
{
Serial.begin(9600); // Set the serial port to 9600
Serial.println("Date & Time, Air Quality PPM");
}
void loop()
{
sensorValue = analogRead(0); // Read analog input pin A0
Serial.print("AirQua=");
Serial.print(sensorValue, DEC); // Prints the value read
Serial.println(" PPM");
delay(1000); // Wait 1000ms for next reading
}
ResultsIn my case, the values of Air Quality in Excel were recorded as follows:
Note: You can define the thresholds yourself keeping in mind the climatic changes and also referring to the concerned MET department for the air quality of your area.
If you make something fun and interesting, do share it with our community.
That’s all for now. If you have any queries, visit surilli.io or contact our support. Stay connected with Surilli family for more amazing stuff. :-)
Comments
Please log in or sign up to comment.