YW51 module library for calculating PM2.5

Dependencies:   SoftSerial

Revision:
1:9b8788ea7c85
Parent:
0:1abc1344f5eb
--- a/YW51.h	Tue Feb 19 14:24:36 2019 +0000
+++ b/YW51.h	Thu Mar 07 08:19:32 2019 +0000
@@ -20,7 +20,33 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+ 
+ /*Example:
 #include "mbed.h"
+#include "YW51.h"
+#include <string>
+Serial pc(USBTX, USBRX);
+
+YW51 dev(D2, 2400);
+int main(){
+    pc.baud(9600);
+    int err;
+    pc.printf("YW-51 Testing Program!\r\n");
+    pc.printf("---------------------------\r\n");
+    while(1){
+        err = dev.readData();
+        if(err == 0){
+            pc.printf("PM2.5 = %fug/m3 \r\n", dev.ShowPM());
+            //pc.printf("%d", dev.PMStage(dev.ShowPM()));
+            }else{
+                pc.printf("Data Error!\r\n");
+            }
+        pc.printf("----------------------------\r\n");
+        }   
+}
+ */
+#include "mbed.h"
+#include "SoftSerial.h"//Software Serial implemented by Erik Oliman
 
 #ifndef MBED_YW51_H
 #define MBED_YW51_H
@@ -29,14 +55,14 @@
 {
 
 public:
-    YW51(PinName _tx, PinName _rx, int Baud);
+    YW51(PinName _rx, int Baud);
     int readData();
     double ShowPM();
     int PMStage(double pm);
 
 
 private:
-    Serial _YW51;
+    SoftSerial _YW51;
     int msg[6];
     double pm;
     int findK(double vo);