Coder Social home page Coder Social logo

evp_sensor_task's People

Contributors

retep-bassetian avatar samisul avatar

Watchers

 avatar

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.