loading

Want to test the quality of air around you? Wana make your new science project or just have some fun? Got a LinkitONE board? Then you are at the right place!

Here i'll show you step by step how to interface a dust sensor with your LinkitONE. I'll use the dust sensor one found in the grove starter kit for the LinkitONE.

Step 1: What Do You Need?

1) Mediatek LinkitONE

2) Grove base shield

3) Grove dust sensor

4) Micro-USB cable (for burning code)

5) Battery pack

Step 2: Assembling the Parts

Now, assemble all the parts together.

First off all, put the grove base shield on your LinkitONE carefully. Check if the pins are placed correctly. If thats done, then connect the sensor.

We'll be using the digital pin 8 of the linkit for communication, so connect the dust sensor to that pin.

Make sure everything is secure, and handle the sensor with care so that it doesnot fall.

Connections:

Red Wire - 5v

Black write - GND

Yellow wire - Data pin 8 /D8

Step 3: Updating Board's Firmware

If your board's firmware is old, you'll need to update it to use it properly, so download the latest firmware updater from the Mediatek's website.

To update the Board's Firmware, open the "firmware updater" software that you installed in the last part in the previous step. Once open, Make sure that the switches on the board are in the right position for updating firmware; MS for the MS--UART, USB for the USB--Battery switch, and SPI for the SPI--SD switch. Plug your board into your computer, then click "Download". It will now begin downloading and installing the latest firmware for your board.

Step 4: Writing Some Code

The code is really simple here! There's nothing much!

We're just taking a analog reading from sensor about dist particles per cubic feet. We are first analyzing reading for 30 seconds and then giving back the readings.

CODE:

-----------------

int pin = 8;
unsigned long duration;

unsigned long starttime;

unsigned long sampletime_ms = 2000; //sampe 30s ;

unsigned long lowpulseoccupancy = 0;

float ratio = 0;

float concentration = 0;

void setup() {

Serial.begin(9600);

pinMode(8,INPUT);

starttime = millis();//get the current time;

} void loop() {

duration = pulseIn(pin, LOW);

lowpulseoccupancy = lowpulseoccupancy+duration;

if ((millis()-starttime) >= sampletime_ms)//if the sampel time = = 30s { ratio = lowpulseoccupancy/(sampletime_ms*10.0); // Integer percentage 0=>100 concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve

Serial.print("concentration = ");

Serial.print(concentration);

Serial.println(" pcs/0.01cf");

Serial.println("\n");

lowpulseoccupancy = 0; starttime = millis();

}

}

----------

Okay, so now burn this code to your board.

Step 5: Testing It Out!

Now test your device!

Just burn the code on your board from the previous step and then start!

Open the serial monitor on the modem port of your Linkit. Carefully observe your readings. They update every 30 seconds.

You can even plot a graph using opensource tools available online such as plotty or ubidots.

Step 6: Final Touches!

Now build your own air quality box!

You made your own dust sensor, but you can make a small box that you can carry anywhere you want and that can measure air quality as well!

About This Instructable

455views

6favorites

License:

More by ssarthak598:DIY Smart Home Monitoring Bottle Arduino Video Game (The DIY Gift) Is My Fridge Door Open?! 
Add instructable to: