Created
March 13, 2017 12:22
-
-
Save zen/bc89ee2dc597fc1c8595a45a524bd192 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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