<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ammonia Archives | Microcontroller Tutorials</title>
	<atom:link href="https://www.teachmemicro.com/tag/ammonia/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.teachmemicro.com/tag/ammonia/</link>
	<description>Microcontroller Tutorials and Resources</description>
	<lastBuildDate>Sun, 28 Jun 2026 01:11:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://www.teachmemicro.com/wp-content/uploads/2019/04/blue-icon-65x65.png</url>
	<title>ammonia Archives | Microcontroller Tutorials</title>
	<link>https://www.teachmemicro.com/tag/ammonia/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>MQ-135 Air Quality Sensor Tutorial</title>
		<link>https://www.teachmemicro.com/mq-135-air-quality-sensor-tutorial/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mq-135-air-quality-sensor-tutorial</link>
					<comments>https://www.teachmemicro.com/mq-135-air-quality-sensor-tutorial/#comments</comments>
		
		<dc:creator><![CDATA[Roland Pelayo]]></dc:creator>
		<pubDate>Wed, 29 Jan 2020 01:00:19 +0000</pubDate>
				<category><![CDATA[Arduino Tutorial]]></category>
		<category><![CDATA[Sensor Tutorial]]></category>
		<category><![CDATA[acetone]]></category>
		<category><![CDATA[alcohol]]></category>
		<category><![CDATA[ammonia]]></category>
		<category><![CDATA[arduino UNO]]></category>
		<category><![CDATA[mq]]></category>
		<category><![CDATA[sensor]]></category>
		<category><![CDATA[toluene]]></category>
		<guid isPermaLink="false">https://www.teachmemicro.com/?p=4231</guid>

					<description><![CDATA[<p>The MQ-135 “air quality” sensor is part of the MQ series of gas sensors that uses a chemical-sensitive element. The resistance of such elements varies when exposed to certain gases. The MQ-135 is sensitive to multiple gases including Benzene, Acetone, Alcohol, and Ammonium. Getting Gas Concentration from MQ-135 Like all MQ gas sensors, the MQ-135 &#8230;</p>
<p>The post <a href="https://www.teachmemicro.com/mq-135-air-quality-sensor-tutorial/">MQ-135 Air Quality Sensor Tutorial</a> appeared first on <a href="https://www.teachmemicro.com">Microcontroller Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The MQ-135 “air quality” sensor is part of the MQ series of <a href="https://www.win-source.net/category/sensors-transducers/gas-sensors">gas sensors</a> that uses a chemical-sensitive element. The resistance of such elements varies when exposed to certain gases. The MQ-135 is sensitive to multiple gases including Benzene, Acetone, Alcohol, and Ammonium.</p>
<p><span id="more-4231"></span></p>
<h3><strong>Getting Gas Concentration from MQ-135</strong></h3>
<p>Like all MQ gas sensors, the MQ-135 follows a sensitivity curve:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-gas-curve.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-4232" src="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-gas-curve.png" alt="MQ-135 gas curve" width="532" height="469" srcset="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-gas-curve.png 532w, https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-gas-curve-300x264.png 300w" sizes="auto, (max-width: 532px) 100vw, 532px" /></a></p>
<p>The graph is a <a href="https://en.wikipedia.org/wiki/Log%E2%80%93log_plot">log-log graph</a> and shows plots for multiple gases. The x-axis is the detected concentration of the gas in parts per million (PPM) while the y-axis is the RS/R0 ratio - the ratio of the sensor resistance in clean air over the resistance of the sensor in various gases.</p>
<p>Let’s select acetone as our target gas. There are two clear intersections of the acetone line: one is when PPM is 100 or 10<sup>2</sup> and the other is when PPM is 10 or 10<sup>1</sup>:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-gas-curve-with-acetone-circled.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-4233" src="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-gas-curve-with-acetone-circled.png" alt="MQ-135 acetone" width="530" height="468" srcset="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-gas-curve-with-acetone-circled.png 530w, https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-gas-curve-with-acetone-circled-300x265.png 300w" sizes="auto, (max-width: 530px) 100vw, 530px" /></a></p>
<p>At PPM = 10, the Rs/R0 ratio is right between 1 or 10<sup>0</sup> and 1.2589 or 10<sup>0.1</sup>. We can interpolate this as 10<sup>0.05</sup> hence at PPM=10, Rs/R0 should be approximately 1.122.</p>
<p>At PPM = 100, the Rs/R0 ratio is right between 10<sup>-0.4</sup> and 10<sup>-0.3</sup>. This should be 10<sup>-0.35</sup> or approximately 0.447.</p>
<p>Now that we have two points on the graph, we can use the two-point form of the line equation:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/01/point-point-form-small.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-4235" src="https://www.teachmemicro.com/wp-content/uploads/2020/01/point-point-form-small.png" alt="" width="200" height="37" /></a></p>
<p>We set y<sub>1</sub> = 1.122, x<sub>1</sub> = 10 and y<sub>2</sub> = 0.447, x<sub>2</sub> = 100. Our equation now for getting the concentration in PPM for acetone is:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/01/ppm_acetone_formula-small.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-4236" src="https://www.teachmemicro.com/wp-content/uploads/2020/01/ppm_acetone_formula-small.png" alt="" width="300" height="49" /></a></p>
<p>The next step is to determine the resistance of the sensor in clean air R0. This can be done by measuring the output voltage of the sensor and then deriving the resistance from that voltage.</p>
<h3><strong>The MQ-135 Breakout Board</strong></h3>
<p>For this tutorial, I am using the MQ-135 sensor breakout board:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-breakout-board-1.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-4239" src="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-breakout-board-1.png" alt="MQ-135 breakout board" width="600" height="454" srcset="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-breakout-board-1.png 600w, https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-breakout-board-1-300x227.png 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>The MQ-135 breakout board, like other MQ boards, has four pins. The D0 pin goes high when sufficient levels of Benzene, Alcohol, Acetone, or Ammonium are in the air. The exact concentration of these chemicals that trigger the D0 pin is unknown. Hence, measuring concentration is done through the A0 pin.</p>
<p>The A0 pin provides a voltage proportional to the concentration of the chemicals to which MQ-135 is sensitive. But before you can acquire the concentration in PPM, you must determine first the resistance of the sensor in clean air (R0).</p>
<h3><strong>Measuring the Clean Air Resistance</strong></h3>
<p>Almost all MQ gas sensors follow this schematic:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/01/MQ-135-schematic-diagram.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-4240" src="https://www.teachmemicro.com/wp-content/uploads/2020/01/MQ-135-schematic-diagram.png" alt="MQ135 schematic diagram" width="601" height="268" srcset="https://www.teachmemicro.com/wp-content/uploads/2020/01/MQ-135-schematic-diagram.png 601w, https://www.teachmemicro.com/wp-content/uploads/2020/01/MQ-135-schematic-diagram-300x134.png 300w" sizes="auto, (max-width: 601px) 100vw, 601px" /></a></p>
<p>Our aim is to measure the resistance of the sensor in clean air (R0). As shown, measuring the resistance between the A0 pin and GND would give us the value of resistor R2. R0 here creates a voltage divider with R2. Hence, if we can measure the output voltage at A0 in clean air, R0 is:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/01/R0-formula.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-4241" src="https://www.teachmemicro.com/wp-content/uploads/2020/01/R0-formula.png" alt="Formula for R0" width="250" height="78" /></a></p>
<p>Using an ohmmeter, measure the resistance between the A0 and GND to acquire R2. For example, the R2 on my module is approximately 1000 ohms.</p>
<p>Now, wire up the diagram as shown:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-arduino.jpg"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-4242" src="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-arduino.jpg" alt="Arduino to MQ135 wiring" width="600" height="411" srcset="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-arduino.jpg 600w, https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-arduino-300x206.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>We will be using Arduino’s analog-to-digital converter to determine voltage A0. Upload the sketch below:</p>
<pre class="lang:arduino decode:true "><pre><code class="language-cpp">void setup() {
   Serial.begin(9600);
}

void loop() {
   // read the input on analog pin 0:
   int sensorValue = analogRead(A0);
   // convert to voltage:
   float volts = sensorValue * 5;
   volts = volts / 1023;
   // print out the voltage:
   Serial.println(volts);
   delay(1); // delay in between reads for stability
}</code></pre></pre>
<p>Open the serial monitor and the voltage is shown. Here’s a screenshot of my serial monitor:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-serial-monitor.jpg"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-4243" src="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-serial-monitor.jpg" alt="MQ135 serial screenshot" width="608" height="369" srcset="https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-serial-monitor.jpg 608w, https://www.teachmemicro.com/wp-content/uploads/2020/01/mq-135-serial-monitor-300x182.jpg 300w" sizes="auto, (max-width: 608px) 100vw, 608px" /></a></p>
<p>Now you will notice that the value is going down. This is normal as the sensor is now preheating. Preheat time varies between MQ sensors; those which have not been used for a long time takes longer to preheat. Mine have been in storage for months, and it took almost 30 minutes to preheat. You will know it is ready when the values on the serial monitor is not drifting anymore. Mine was stable when the reading came down to 0.85.</p>
<p>Since I now know what my device’s A0 at clean air is, I can now determine R0 using the formula:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/01/R0-formula.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-4241" src="https://www.teachmemicro.com/wp-content/uploads/2020/01/R0-formula.png" alt="Formula for R0" width="250" height="78" /></a></p>
<p>My R2 is 1000, so that gives me an R0 of around 176 ohms.</p>
<h3><strong>MQ-135 Acetone Sensor with Arduino</strong></h3>
<p>The concentration in acetone can now be determined using this sketch:</p>
<pre class="lang:arduino decode:true "><pre><code class="language-cpp">int R0 = 176;
int R2 = 1000;
float RS;
float PPM_acetone;

void setup() {
   Serial.begin(9600);
}

void loop() {
   // read the input on analog pin 0:
   int sensorValue = analogRead(A0);
   // convert to voltage:
   float volts = sensorValue * 5;
   volts = volts / 1023;
   // calculate RS
   RS = R2 * (1-volts);
   RS = RS/volts;
   // calculate acetone PPM
   PPM_acetone = 159.6 - 133.33*(RS/R0);
   // print out the acetone concentration:
   Serial.println(PPM_acetone);
   delay(1); // delay in between reads for stability
}</code></pre></pre>
<p>Recall that the formula for the concentration of acetone is:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/01/ppm_acetone_formula-small.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-4236" src="https://www.teachmemicro.com/wp-content/uploads/2020/01/ppm_acetone_formula-small.png" alt="" width="300" height="49" /></a></p>
<p>So we need to know Rs -- the resistance of the MQ-135 when acetone is present. This value can be acquired if we revise the formula to get R0 to:</p>
<p><a href="https://www.teachmemicro.com/wp-content/uploads/2020/01/RS-formula.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-4244" src="https://www.teachmemicro.com/wp-content/uploads/2020/01/RS-formula.png" alt="Formula for RS" width="250" height="77" /></a></p>
<p>We use this value in the previous formula to get the concentration of acetone in PPM.</p>
<h3><strong>Air Quality Trigger Device</strong></h3>
<p>Now if your project doesn’t require that the concentration of the gases is known, you can use the MQ-135 as a simple switch. We modify the wiring diagram where the D0 pin now connects to the Arduino UNO instead of the A0 pin:</p>
<p>This is now the sketch:</p>
<pre class="lang:arduino decode:true "><pre><code class="language-cpp">int D0 = 2;

void setup() {
   Serial.begin(9600);
   pinMode(D0, INPUT);
}

void loop() {
   if(digitalRead(D0) == HIGH){
   Serial.println(&quot;Chemical detected!&quot;);
   }else{;}
   delay(100); // delay in between reads for stability
}</code></pre></pre>
<p>The sketch uses the serial monitor as before. This time, it will print “Chemical detected” when any of the MQ-135 chemicals is near.</p>
<p>Have any questions, reactions or suggestions? Kindly drop a comment below.</p>
<p>The post <a href="https://www.teachmemicro.com/mq-135-air-quality-sensor-tutorial/">MQ-135 Air Quality Sensor Tutorial</a> appeared first on <a href="https://www.teachmemicro.com">Microcontroller Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.teachmemicro.com/mq-135-air-quality-sensor-tutorial/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 

Served from: www.teachmemicro.com @ 2026-07-26 21:23:38 by W3 Total Cache
-->