Giter Site home page Giter Site logo

maartin0 / plantower_pms7003-esp-idf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jmstriegel/plantower_pms7003

0.0 0.0 0.0 8 KB

Plantower_PMS7003 Particulate Matter Sensor Library For Arduino

License: BSD 3-Clause "New" or "Revised" License

C++ 96.69% CMake 2.91% Makefile 0.40%

plantower_pms7003-esp-idf's Introduction

Plantower_PMS7003 Arduino Library

An Arduino library for interfacing with the Plantower PMS7003 laser particle counter. This should also work the the PMS5003 sensor, as they share the same protocol.

PMS7003

The PMS7003 is a particle matter counter capable of detecting particulates in the range of 0.3 to 10 microns.

This device uses a serial connection to send measurements to a connected device roughly once a second. Concentration measurements are provided for PM1.0 (0.3-1.0um), PM2.5 (1.0-2.5um), and PM10 (2.5-10.0um).

Interface

Interfacing with the device is via an atypical 1.27mm pitch 10-pin (2x5 row) male header. I recommend using an SWD breakout board and cable for easy prototyping--the pinout is totally different but they are easy to source. Here's what I used:

All of the data pins require a 3.3v TTL level, but power must be supplied to VCC at 5v, which is a requirement for proper operation of the built-in fan.

Pins are numbered as shown below. Pin 1 is at the top of the keyed side of the connector.

+5v VCC  1  2   +5v VCC
    GND  3  4   GND
  Reset  5  6   N/C
     RX  7  8   N/C
     TX  9  10  Set

Connecting the PMS7003 to a compatible 3.3v device requires 4 pins:

  • Connect microcontroller +5v VCC or USB to pin 1 (VCC).
  • Connect microcontroller GND to pin 3 (GND).
  • Connect microcontroller TX to pin 7 (RX).
  • Connect microcontroller RC to pin 9 (TX).

Usage

// Constructor
Plantower_PMS7003 sensor = Plantower_PMS7003();

void setup()
{
  // Initialize the sensor with the serial device
  // that it's connected to. Hardware Serial1 is the
  // default, if no parameter is provided to init()

  Serial1.begin(9600);    // Note: 9600 baud
  sensor.init(&Serial1);

}

void loop()
{
  // Use updateFrame() to read in sensor data in your
  // loop until hasNewData() returns true.
  sensor.updateFrame();

  // Note: once updateFrame() is called, all data is
  // invalid until hasNewData() returns true.
  if (sensor.hasNewData())
  {
    // PM1.0: getPM_1_0() 
    Serial.print("PM1.0: ");
    Serial.print(sensor.getPM_1_0());
    
    // PM2.5: getPM_2_5()
    Serial.print(" PM2.5: ");
    Serial.print(sensor.getPM_2_5());
    
    // PM10: getPM_10_0()
    Serial.print(" PM10: ");
    Serial.print(sensor.getPM_10_0());
    Serial.println();
  }

}

A full example can be found in pms_7003_test.ino.

License

This library was written by Jason Striegel and provided under the BSD license. See license.txt for details.

plantower_pms7003-esp-idf's People

Contributors

jmstriegel avatar maartin0 avatar per1234 avatar

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.