Arduino with the GP2Y1014AU0F Sensor

HARDWARE

Arduino Nano R3
GP2Y1014AU0F Sensor
0.96’ SPI OLED Display Module
220 µf Capacitor
Through Hole Resistor, 150 ohm

Summery

Let’s use the Sharp GP2Y1014AU0F Sensor to calculate the Dust Density in the Air.

Concerning the Project

Sharp’s GP2Y1014AU0F optical air quality analyzer is a six-pin analogue output optical air quality analyzer designed to detect dust particles in the air. It works on the basis of the laser scattering concept. Dust particles distribute the IR LED light towards the photodetector when air containing dust particles reaches the specified sensor chamber. The dust particles determine the intensity of the dispersed light. The greater the number of dust particles in the air, the greater the light intensity.

Organic Light-Emitting Diodes (OLEDs) are self-lighting devices made by interspersing a succession of organic thin films between two conductors. When an electric current is used in these films, a brilliant light is produced. OLEDs use the same technology as televisions, however they have fewer pixels than ordinary televisions.

Make sure your solder wires are at a reasonable distance from one another during soldering.

Code :

#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
 
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
 
// Declaration for SSD1306 display connected using software SPI (default case):
#define OLED_MOSI   9
#define OLED_CLK   10
#define OLED_DC    11
#define OLED_CS    12
#define OLED_RESET 13
 
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,
  OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
 
int measurePin = A5;
int ledPower = 7;
  
float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;
  
void setup(){
  Serial.begin(9600);
  pinMode(ledPower,OUTPUT);
  display.begin(SSD1306_SWITCHCAPVCC);
  display.clearDisplay();
  display.display();
}
  
void loop(){
  digitalWrite(ledPower,LOW);
  delayMicroseconds(280);
 
  voMeasured = analogRead(measurePin);
 
  delayMicroseconds(40);
  digitalWrite(ledPower,HIGH);
  delayMicroseconds(9680);
 
  calcVoltage = voMeasured*(5.0/1024);
  dustDensity = 0.17*calcVoltage-0.1;
 
  if ( dustDensity < 0)
  {
    dustDensity = 0.00;
  }
  
  Serial.println("Raw Signal Value (0-1023):");
  Serial.println(voMeasured);
 
  Serial.println("Voltage:");
  Serial.println(calcVoltage);
 
  Serial.println("Dust Density:");
  Serial.println(dustDensity);
   
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(85,22);
  display.println("Dust");
  display.setCursor(85,38);
  display.println("Density");
  display.setTextSize(3);
  display.setCursor(0,13);
  display.println(dustDensity);
  display.setCursor(6,43);
  display.setTextSize(2);
  display.println("ug/m3");
  display.display();
  display.clearDisplay();
  
  delay(1000);
}

“People with Goals have different Aura than others” – KP

– Helping Hands.

About the author

pondabrothers

View all posts

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *