evp_sensor_task's People
evp_sensor_task's Issues
Dust Sensor Code
int ledPower = 2;
double dustDensity;
int sensorValue;
double voltage;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// set LED pin as output
pinMode(ledPower,OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the LED pin low
digitalWrite(ledPower,LOW);
delayMicroseconds(180); // delay about 180us
// read the analog pin
sensorValue = analogRead(A1); // needs about 100 us
delayMicroseconds(30); //delay about 30 us
// set the LED pin high
digitalWrite(ledPower,HIGH);
delayMicroseconds(9680); // filling out the rest of the pulse cycle
// Convert analog value to voltage
voltage = sensorValue * (5.0 / 1023.0);
// calculate dust density
if ( voltage <= 0.9) dustDensity = 0.0;
if (voltage < 3.5 && voltage > 0.9) dustDensity = -0.0127*pow(voltage, 2.0) + 0.2225*voltage - 0.1819;
if (voltage >= 3.5) dustDensity = 40.0*pow(voltage, 2.0) - 280.8*voltage + 493.28;
if (dustDensity >= 0.8) dustDensity = 0.8;
// print the measured and calculated data
Serial.println("Voltage:\t" + String(voltage) + " V\tDust Density:\t" + String(dustDensity)+ " mg/m^3");
delay(1000);
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.