element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Summer of Green Tech Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Summer of Green Tech Design Challenge
  • More
  • Cancel
Summer of Green Tech Design Challenge
Blog Blog #4: Integration of the Materials
  • Blog
  • Forum
  • Documents
  • Leaderboard
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Summer of Green Tech Design Challenge to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: paulcastor30
  • Date Created: 19 Oct 2023 6:14 AM Date Created
  • Views 580 views
  • Likes 1 like
  • Comments 2 comments
  • seeeduino xiao
  • Seeed Studio XIAO SAMD21
  • summer of green tech design challenge
  • air quality
  • samd21
Related
Recommended

Blog #4: Integration of the Materials

paulcastor30
paulcastor30
19 Oct 2023

This blog will discuss the integration of the required materials stated in Blog #2 and Blog #3. Below are the steps for integrating all the materials to develop our Seeeduino SAMD21-based Indoor Caron Dioxide Monitoring Device.

  • Prepare the required materials discussed in Blog #2.
  • Connect your sensors to the SAMD21 Microcontroller pins. Kindly follow the wiring diagram below.

image

  • Connect your Seeeduino XIAO SAMD21 Microcontroller to your PC or Laptop via a USB Type-C Cable.
  • Create a new Arduino Sketch and paste the following program below.

#include "Wire.h"
#include <MQ135.h>
#include <DHT.h>
#include <RGBLed.h>
#include <LiquidCrystal_I2C.h>

#define PIN_MQ135 A1
#define DHTTYPE DHT20
#define BUZZER 3
#define REDLED 10
#define GREENLED 9
#define BLUELED 8

LiquidCrystal_I2C lcd(0x27, 20, 4);
MQ135 mq135_sensor(PIN_MQ135);
DHT dht(DHTTYPE);
RGBLed led(REDLED, GREENLED, BLUELED, RGBLed::COMMON_ANODE);

unsigned long readMillis;
unsigned long currentMillis;
const unsigned long readPeriod = 2000;
int redcolor = 0;
int greencolor = 0;
int bluecolor = 0;

void setup() {
  analogReadResolution(12);
  Serial.begin(115200);
  lcd.init();
  Wire.begin();
  dht.begin();

  lcd.backlight();
  lcd.setCursor(1, 0);
  lcd.print("Indoor Air Quality");
  lcd.setCursor(1, 1);
  lcd.print("Monitoring  Device");
  lcd.setCursor(0, 2);
  lcd.print("System  Initializing");
  lcd.setCursor(0, 3);
  for (int i = 0; i < 20; i++)
  {
    lcd.print(".");
    delay(100);
  }
  lcd.setCursor(0, 3);
  for (int i = 0; i < 20; i++)
  {
    lcd.print(" ");
    delay(100);
  }
  lcd.setCursor(8, 3);
  lcd.print("DONE");
  delay(100);


  //lcd.setCursor(0, 0);
  //lcd.print("Real-time Air Status");
  readMillis = millis();
}

void loop() {
  currentMillis = millis();
  if (currentMillis - readMillis >= readPeriod) {
    float temp_hum_val[2] = {0};
    if (!dht.readTempAndHumidity(temp_hum_val)) {
      // do nothing
    }
    float rzero = mq135_sensor.getRZero();
    float correctedRZero = mq135_sensor.getCorrectedRZero(temp_hum_val[1], temp_hum_val[0]);
    float resistance = mq135_sensor.getResistance();
    float ppm = mq135_sensor.getPPM();
    float correctedPPM = mq135_sensor.getCorrectedPPM(temp_hum_val[1], temp_hum_val[0]);
    /*
        Serial.print("MQ135 RZero: ");
        Serial.print(rzero);
        Serial.print("\t Corrected RZero: ");
        Serial.print(correctedRZero);
        Serial.print("\t Resistance: ");
        Serial.print(resistance);
        Serial.print("\t PPM: ");
        Serial.print(ppm);
        Serial.print("\t Corrected PPM: ");
        Serial.print(correctedPPM);
        Serial.println("ppm");
    */
    lcd.clear();
    //delay(100);

    lcd.setCursor(3, 1);
    lcd.print("PPM: ");
    lcd.print(correctedPPM);
    lcd.print(" ppm");

    lcd.setCursor(0, 2);
    lcd.print("Temperature: ");
    lcd.print(temp_hum_val[1]);
    lcd.print(" C");

    lcd.setCursor(2, 3);
    lcd.print("Humidity: ");
    lcd.print(temp_hum_val[0]);
    lcd.print("%");



    float pm_sensor_reading = correctedPPM;

    if (pm_sensor_reading >= 0.0 && pm_sensor_reading <= 50.0) {

      lcd.setCursor(7, 0);
      lcd.print("Good");

      //aqi_cat[] = s"Good";
      redcolor = 0;
      greencolor = 228;
      bluecolor = 0;
      led.setColor(redcolor, greencolor, bluecolor); //green
      digitalWrite(BUZZER, LOW);
      Serial.println(F("Good"));
    }
    else if (pm_sensor_reading >= 51.0 && pm_sensor_reading <= 100.0) {


      lcd.setCursor(6, 0);
      lcd.print("Moderate");
      //aqi_cat = "Moderate";
      redcolor = 255;
      greencolor = 255;
      bluecolor = 0;
      led.setColor(redcolor, greencolor, bluecolor); //yellow
      digitalWrite(BUZZER, LOW);
      Serial.println(F("Moderate"));
    }
    else if (pm_sensor_reading >= 101.0 && pm_sensor_reading <= 150.0) {
      lcd.setCursor(3, 0);
      lcd.print("Unhealthy for");
      lcd.setCursor(2, 1);
      lcd.print("Sensitive Groups");
      //aqi_cat = "Unhealthy for Sensitive Groups";
      redcolor = 255;
      greencolor = 126;
      bluecolor = 0;
      led.setColor(redcolor, greencolor, bluecolor); //orange
      digitalWrite(BUZZER, LOW);
      Serial.println(F("Unhealthy for Sensitive Group"));
    }
    else if (pm_sensor_reading >= 251.0 && pm_sensor_reading <= 200.0) {

      lcd.setCursor(5, 0);
      lcd.print("Unhealthy");
      //aqi_cat = "Unhealthy";
      redcolor = 255;
      greencolor = 0;
      bluecolor = 0;
      led.setColor(redcolor, greencolor, bluecolor); //red
      digitalWrite(BUZZER, HIGH);
      Serial.println(F("Unhealthy"));

    }
    else if (pm_sensor_reading >= 201.0 && pm_sensor_reading <= 300.0) {


      lcd.setCursor(3, 0);
      lcd.print("Very Unhealthy");
      //aqi_cat = "Very Unhealthy";
      redcolor = 143;
      greencolor = 63;
      bluecolor = 151;
      led.setColor(redcolor, greencolor, bluecolor); //purple
      digitalWrite(BUZZER, HIGH);
      Serial.println(F("Very Unhealthy"));
    }
    else if (pm_sensor_reading >= 301.0 && pm_sensor_reading <= 500.0) {

      lcd.setCursor(5, 0);
      lcd.print("Hazardous");
      //aqi_cat = "Hazardous";
      redcolor = 126;
      greencolor = 0;
      bluecolor = 35;
      led.setColor(redcolor, greencolor, bluecolor); //maroon
      digitalWrite(BUZZER, HIGH);
      Serial.println(F("Hazardous"));
    }
    else if (pm_sensor_reading >= 501.0) {

      lcd.setCursor(5, 0);
      lcd.print("Hazardous");
      //aqi_cat = "Hazardous";
      redcolor = 126;
      greencolor = 0;
      bluecolor = 35;
      led.setColor(redcolor, greencolor, bluecolor); //maroon
      digitalWrite(BUZZER, HIGH);
      Serial.println(F("Hazardous"));
    }
    else {
      redcolor = 0;
      greencolor = 0;
      bluecolor = 0;
      led.setColor(redcolor, greencolor, bluecolor);
      digitalWrite(BUZZER, LOW);

      lcd.setCursor(8, 0);
      lcd.print("None");
      //aqi_cat = "None";
    }

    readMillis = millis();
  }
}

  • Save the Arduino sketch.
  • Upload the demo. If you do not know how to upload the code, please check how to upload the code.
  • Open the Serial Monitor of Arduino IDE by clicking Tool-> Serial Monitor. Or tap the CTRL+SHIFT+M keyboard keys at the same time. if everything goes well, you will get the readings.
  • Sign in to reply

Top Comments

  • shabaz
    shabaz over 1 year ago +1
    There's nothing here. What's the purpose of this empty blog?
  • paulcastor30
    paulcastor30 over 1 year ago in reply to shabaz

    Sorry for the late reply. I already updated the blog. It has now all the contents necessary. Thank you very much.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 1 year ago

    There's nothing here. What's the purpose of this empty blog?

    image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube