Skip to content

Instantly share code, notes, and snippets.

@zen
Created March 13, 2017 12:22
Show Gist options
  • Save zen/bc89ee2dc597fc1c8595a45a524bd192 to your computer and use it in GitHub Desktop.
Save zen/bc89ee2dc597fc1c8595a45a524bd192 to your computer and use it in GitHub Desktop.
/*
PMS3003 particle matter sensor library
MIT License
Copyright by Tomasz 'Zen' Napierala © 2016
http://github.com/zen
*/
#include "PMS3003.h"
SoftwareSerial* pms_handle = NULL;
PMS3003::PMS3003(uint8_t pin_rx, uint8_t pin_tx, uint8_t pin_set) {
_pin_rx = pin_rx;
_pin_tx = pin_tx;
_pin_set = pin_set;
}
void PMS3003::begin(void) {
pinMode(_pin_rx, OUTPUT);
pinMode(_pin_tx, INPUT);
pinMode(_pin_set, OUTPUT);
pms_handle = new SoftwareSerial(_pin_rx, _pin_tx);
}
void PMS3003::enableSensor(void) {
digitalWrite(_pin_set, HIGH);
}
void PMS3003::disableSensor(void) {
digitalWrite(_pin_set, LOW);
}
void PMS3003::readSensor(void) {
pms_handle->begin(PMS_BAUDRATE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment