Download  Print this page

Sharp GP2Y1026AU0F Application Manual page 9

Dust sensor, arduino uno/mega
Hide thumbs

Advertisement

Application Guide for Sharp GP2Y1026AU0F Dust Sensor
Source Code Listing cont'd – sharp_gp2y1026au0f_v2.ino – PART B
// Assign values.
dataStart = frame[0];
VoutH = frame[1];
VoutL = frame[2];
VrefH = frame[3];
VrefL = frame[4];
checksum = frame[5];
dataEnd = frame[6];
// Check the start and end of frame.
if
( dataStart != 0xaa || dataEnd != 0xff ) { return; }
// Verify the checksum.
int
testSum = VoutH + VoutL + VrefH + VrefL;
if
( testSum != checksum ) { return; }
// Print the data values.
Serial.print("dataStart=");
Serial.print(dataStart);
Serial.print(",
");
Serial.print("VoutH=");
Serial.print(VoutH);
Serial.print(",
");
Serial.print("VoutL=");
Serial.print(VoutL);
Serial.print(",
");
Serial.print("VrefH=");
Serial.print(VrefH);
Serial.print(",
");
Serial.print("VrefL=");
Serial.print(VrefL);
Serial.print(",
");
Serial.print("Checksum=");
Serial.print(checksum);
Serial.print(",
");
Serial.print("dataEnd=");
Serial.print(dataEnd);
Serial.print(", ");
// Calculate Vout.
float
Vout = (VoutH * 256 + VoutL) / 1024.0 * 5.0;
Serial.print("Vout=");
Serial.print(Vout * 1000.0);
Serial.print("mV,
");
// Calculate "a" coefficient beforehand by using a reference dust monitor.
// The coefficient will be different depending on the reference dust monitor used
// and your specific application conditions.
float
a = 100 / 0.35;
// Calculate dust density.
float
dustDensity = a * Vout;
Serial.print("dustDensity=");
Serial.print(dustDensity);
Serial.print("ug/m3");
Serial.println(" ");
}
// END PROGRAM
9
http://www.socle-tech.com

Advertisement

loading

  Related Manuals for Sharp GP2Y1026AU0F