Mario Soranno
Published © MIT

COVID-19 and PM10 Levels!

Experimental studies would assert the possibility that PM10 may act as a “carrier” for the spreading of the viral infection of COVID-19.

BeginnerFull instructions provided6 hours10,044
COVID-19 and PM10 Levels!

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
SDS018
http://inovafitness.com/en/a/chanpinzhongxin/97.html
×1
Adafruit DHT22 temperature-humidity sensor + extras
Note: The pull-up resistor and capacitor are on module.
×1
OLED Display - I2C - SSD1306
×1
Broadcom LED Green
×1
Broadcom LED Yellow
×1
Broadcom LED Red
×1
Capacitor 100 nF
Capacitor 100 nF
Optional: capacitor for DHT22.
×1
Through Hole Resistor, 4.7 kohm
Through Hole Resistor, 4.7 kohm
Optional: resistor for DHT22.
×1
Power Bank
See description.
×1
Through Hole Resistor, 390 ohm
Through Hole Resistor, 390 ohm
Resistors for LEDs.
×3
Machine Screw, M3x16
Case screws.
×4
Machine Screw, M3x6
SDS018 screw.
×1
LAMP SOCKET, LUMEX 3MM LEDs
Optional: LED Mounting Hardware.
×3
Female jumper for wire
×3
Heat-shrink tubing
×1
Pin header (2 pin)
×1
Generic Jumper (0.1")
Generic Jumper (0.1")
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
3D Printer (generic)
3D Printer (generic)
Hot glue gun (generic)
Hot glue gun (generic)
Drill / Driver, Cordless
Drill / Driver, Cordless

Story

Read more

Custom parts and enclosures

Case - upper part

File of the 3D upper part of orange PLA case

Case - lower part

File of the 3D lower part of orange PLA case

Schematics

Electrical schematic

Electrical schematic of COVID-19 and PM10 levels!

Code

COVID-19 and PM10 levels! - Code

Arduino
The firmware is an Arduino sketch.
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128          // OLED display width, in pixels
#define SCREEN_HEIGHT 32          // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     4          // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#include "DHT.h"
#define DHTPIN 2                  // Digital pin connected to the DHT sensor 
#define DHTTYPE    DHT22          // DHT22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);

int startdhr22 = 0;               // Startup flag variable: waiting for the first measurement of DHT22
int switchDisplay = 0;            // Flag variable for switch data on the display


const int ledRed = 3;             // Number of Red LED pin
const int ledGreen = 4;           // Number of Green LED pin
const int ledYellow = 5;          // Number of Yellow LED pin

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);         // On-board LED - initialize digital pin LED_BUILTIN as an output
  pinMode(ledRed, OUTPUT);              // Initialize digital pin as an output
  pinMode(ledGreen, OUTPUT);            // Initialize digital pin as an output
  pinMode(ledYellow, OUTPUT);           // Initialize digital pin as an output
  dht.begin();
  Serial.begin(9600);
  Serial.println("start");

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Do not proceed, loop forever
  } 
  display.clearDisplay();               // Clear the buffer
  display.setTextSize(2);               // Draw 2X-scale text
  display.setTextColor(SSD1306_WHITE);

  // Startup: LEDs Test
  digitalWrite(ledGreen, HIGH);     // Turn the LED ON
  delay(500);                       // Wait for 0,5 secondS
  digitalWrite(ledYellow, HIGH);    // Turn the LED ON
  delay(500);                       // Wait for 0,5 secondS
  digitalWrite(ledRed, HIGH);       // Turn the LED ON
  delay(500);                       // Wait for 0,5 secondS
  digitalWrite(ledGreen, LOW);      // Turn the LED OFF
  digitalWrite(ledYellow, LOW);     // Turn the LED OFF
  digitalWrite(ledRed, LOW);        // Turn the LED OFF
  delay(500);                       // Wait for 0,5 secondS
}

void loop() {
  // ###########################################################################
  // DHT22
  // 0.5 Hz sampling rate (once every 2 seconds).
  // ###########################################################################
  if(0 == startdhr22) {
    delay(2000);  // Startup: waiting for the first measurement of DHT22
    startdhr22 = 1;
  }
  float h = dht.readHumidity();
  float t = dht.readTemperature();      // Read temperature as Celsius (default)
  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }
  Serial.print(F("Humidity: "));
  Serial.print(h);
  Serial.print(F("%  Temperature: "));
  Serial.print(t);
  Serial.println(F("°C "));
  // ###########################################################################
  // SDS018
  // ###########################################################################
  uint8_t dataIN[10] = {0};                 // Data array from SDS018
  float pm25;
  float pm10;
  
  while(Serial.available() > 0) {
    for(int i=0; i<10; ++i) {               // loop for acquire 10 bytes
      dataIN[i] = Serial.read();            // Save data in to dataIN array
      // Serial.println(dataIN[i], HEX);    // Test: Prints data to the serial port (print as an ASCII-encoded hexadecimal)      
    }

    if((0xAA == dataIN[0]) && (0xC0 == dataIN[1]) && (0xAB == dataIN[9])) {    // check if array contains dataIN[0]=0xAA and dataIN[1]=0xC0 and dataIN[1]=0xAB
      uint8_t cksum = 0;
      for(int i=2; i<=7; ++i) {
        cksum += dataIN[i];                 // Calculation of check-sum  
      }
      //Serial.print("check-sum: ");        // Test: Serial monitor
      //Serial.println(cksum, HEX);

      if(cksum == dataIN[8]) {
        digitalWrite(LED_BUILTIN, HIGH);    // Turn the LED on (HIGH is the voltage level)
        uint8_t pm25Lo = dataIN[2];         // PM2.5 low byte
        uint8_t pm25Hi = dataIN[3];         // PM2.5 high byte
        uint8_t pm10Lo = dataIN[4];         // PM10 low byte
        uint8_t pm10Hi = dataIN[5];         // PM10 high byte
  
        pm25 = ((pm25Hi * 256.0) + pm25Lo)/10.0;      // Calculation of PM2.5 value  
        pm10 = ((pm10Hi * 256.0) + pm10Lo)/10.0;      // Calculation of PM10 value
        
        Serial.print("PM2.5: ");            // Serial monitor
        Serial.print(pm25);
        Serial.println(" ug/m3");
        Serial.print("PM10: ");
        Serial.print(pm10);
        Serial.println(" ug/m3");
      }
      Serial.println("-----------------");
    }
  Serial.flush();
  }
  // ###########################################################################
  // LEDs
  // ###########################################################################
  if((pm10 <= 25) && ((h >= 40) && (h <= 60)))  // Normal – Particulate matter concentrations from 0 to 25 µg/m3 and humidity between 40% and 60%;
  {
    digitalWrite(ledGreen, LOW);      // Turn the LED OFF
    digitalWrite(ledYellow, LOW);     // Turn the LED OFF
    digitalWrite(ledRed, LOW);        // Turn the LED OFF
  }
  else if((pm10 <= 25) && ((h < 40) || (h > 60))) // Low - Particulate matter concentrations from 0 to 25 µg/m3 and humidity < 40% o > 60%;
  {
    digitalWrite(ledGreen, HIGH);     // Turn the LED ON
    digitalWrite(ledYellow, LOW);     // Turn the LED OFF
    digitalWrite(ledRed, LOW);        // Turn the LED OFF
  }
  else if(((pm10 > 25) && (pm10 <= 50)) && ((h >= 40) && (h <= 60)))  // Low - Particulate matter concentrations from 26 to 50 µg/m3 and humidity between 40% and 60%;
  {
    digitalWrite(ledGreen, HIGH);     // Turn the LED ON
    digitalWrite(ledYellow, LOW);     // Turn the LED OFF
    digitalWrite(ledRed, LOW);        // Turn the LED OFF
  }
  else if(((pm10 > 25) && (pm10 <= 50)) && ((h < 40) || (h > 60)))    // Warning - Particulate matter concentrations from 26 to 50 µg/m3 and humidity < 40% o > 60%;
  {
    digitalWrite(ledGreen, HIGH);     // Turn the LED ON
    digitalWrite(ledYellow, HIGH);    // Turn the LED ON
    digitalWrite(ledRed, LOW);        // Turn the LED OFF
  }
  else if((pm10 > 50) && ((h >= 40) && (h <= 60)))  // Warning - Particulate matter concentrations > 51 µg/m3 and humidity between 40% and 60%;
  {
    digitalWrite(ledGreen, HIGH);     // Turn the LED ON
    digitalWrite(ledYellow, HIGH);    // Turn the LED ON
    digitalWrite(ledRed, LOW);        // Turn the LED OFF
  }
  else  // Alarm - Particulate matter concentrations > 51 µg/m3 and humidity < 40% or > 60%.
  {
    digitalWrite(ledGreen, HIGH);     // Turn the LED ON
    digitalWrite(ledYellow, HIGH);    // Turn the LED ON
    digitalWrite(ledRed, HIGH);       // Turn the LED ON
  }
  // ###########################################################################
  // Display
  // ###########################################################################
  if(0 == switchDisplay) {
    display.clearDisplay();
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(0,0);       // Set the cursor position (Width, Height)
    if(pm10 > 50)                 // Visualize the word "Alarm" on display
    {
      display.print("Alarm!!!");
    }
    else                          // Visualize the PM10 value on display
    {
      display.print("PM10:");
      display.println(pm10);
    }
    display.print(" HR%:");       // Visualize the humidity value on display
    display.println(h);
    display.display();
    switchDisplay = 1;
  } else {
    display.clearDisplay();
    display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); // Draw 'inverse' text
    display.setCursor(0,0);           // Set the cursor position (Width, Height)
    display.print("PM25:");           // Visualize the PM2.5 value on display
    display.println(pm25);  
    display.print("T[C]:");       // Visualize the temperature value on display
    display.println(t);
    display.display();
    switchDisplay = 0;
  }
  delay(500);                           // Delay of 500ms
  digitalWrite(LED_BUILTIN, LOW);       // TEST: turn the LED_BUILTIN OFF
  delay(1500);                          // Delay of 1500ms
}

Credits

Mario Soranno

Mario Soranno

9 projects • 24 followers
I have a Bachelor's Degree in Industrial Engineering - Electronics. I am an expert in hardware design, I can program in C/C++,Python and ROS

Comments