Start Bootstrap

Input devices

Week 13


I decided to make a CO2 sensor because I will use it in my final project.

First I got an MQ 135 gas sensor because with this type of sensor it is possible to calibrate to read CO2 and VOCS gases inside a space.

You can find the data sheet here:MQ135 DataSheet

To draw the board I based on the MQ135 module

This is a useful site with information about the sensor: MQ-135 Sensor Air Quality Sensor Hazardous Gas Detection Module Arduino

The sensor of MQ135 is a very simple sensor, it only connects to the GND and 5V to heat the resistance that is in its interior.

I tried to make my board as simple as possible. The MQ135 module for sale uses an Analog pin and a digital pin.In my case I will only use an Analog pin. So I removed the voltage regulator, the capacitors that were connecting to the digital.

I also removed the potentiometer, because I will calibrate the sensor through arduino code, and change its values, until I get an appropriate value of CO2 in ppm.

So now on my board I just have:

  • led with a resistor
  • 10K resistor
  • MQ135 sensor

    In the images we can see the schematic and the board.


    The board was cut in the Carvey machine, by the same process of the previous plates.

    Then the components were welded.

    The MQ135 sensor has 2 H pins that connect to the internal resistance.

    2pins type A and 2 type B pins

    Pin A of the sensor is what has the resistance should be connected to the analog pin of the board.

    Inside our homes, the percentage of CO2 is 5x higher than the percentages abroad.

    Values range from:

  • 400ppm - 750ppm - Good for health
  • 750 ppm - 1200 ppm - we must be careful about health
  • + 1200 ppm - harmful to health

  • The rise in the concentration of toxic gases in the interior is due to the re-gasification and the release of gases by humans. People should open windows, doors to air the house, and always have plants inside the houses.

    So after receiving the values of CO2, I put 3 leds that will have the color:

  • Blue - for good levels
  • Yellow - for medium levels
  • Red - to harmful levels


    First I connected my sensor to the microcontroller I had drawn earlier in the week 6- Eletronic Design

  • VCC(co2 sensor) -5V (microcontroller)
  • GND (co2 sensor) -GND (microcontroller)
  • AnalogPin (co2 sensor) - analog Pin (microcontroller)

  • Note that in order to calibrate the sensor, it should take about 1 hour to warm up to obtain reliable data.

    Then I had a problem. I had already tested the mq135 sensor on an Arduino and saw that it is able to read the CO2 values of the air.

    However when trying to send the same arduino code to my microcontroller Attiny44 I realized that the library "MQ135.h" is not compatible with Attiny 44.

    This forced me to rethink the code and make my own conversion from analog read values to ppm values, based on the library code "MQ135.h".

    So after some time, I managed to make the code work. The final code is this:

  • mq135.txt _Arduino File

  • Since on my microcontroller with Attiny 44 it is not possible to open the serial monitor to confirm the data jammed by my co2 sensor, to calibrate and confirm the ppm values emitted by my co2 sensor, I connected the sensor to an arduino and sends I read the code I wrote and read the values on the serial monitor, as shown in the video.

    My MQ135 sensor is calibrated and ready to use :)