Dust sensor

Dependents:   PMS5003

Fork of DustSenzor by marko puric

Committer:
mpuric
Date:
Tue Jun 13 19:15:47 2017 +0000
Revision:
7:067de0268900
Parent:
6:f6a93c155525
Child:
8:faa84647167c
init commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mpuric 0:513b42c738f3 1 #ifndef DUSTSENZOR_H
mpuric 0:513b42c738f3 2 #define DUSTSENZOR_H
mpuric 0:513b42c738f3 3 #include"mbed.h"
mpuric 6:f6a93c155525 4
mpuric 6:f6a93c155525 5 /** Simple class for reading values from Plantower PMS5003 dust concentration sensor.
mpuric 2:4c3bdadb6bc4 6
mpuric 6:f6a93c155525 7 * Example:
mpuric 6:f6a93c155525 8 * @code:
mpuric 6:f6a93c155525 9 * #include "mbed.h"
mpuric 6:f6a93c155525 10 * #include "DustSenzor.h"
mpuric 6:f6a93c155525 11
mpuric 6:f6a93c155525 12 * DustSenzor ds(p5, p9, p10);
mpuric 6:f6a93c155525 13 * float values [6];
mpuric 6:f6a93c155525 14 * float *ptr;
mpuric 6:f6a93c155525 15
mpuric 6:f6a93c155525 16 * int main() {
mpuric 6:f6a93c155525 17 * ds.start();
mpuric 6:f6a93c155525 18 * ptr = ds.read();
mpuric 6:f6a93c155525 19
mpuric 6:f6a93c155525 20 * for( int i = 0; i < 6; i++) {
mpuric 6:f6a93c155525 21 * values [i] = *(ptr + i);
mpuric 6:f6a93c155525 22 * }
mpuric 6:f6a93c155525 23 * }
mpuric 6:f6a93c155525 24 * @endcode
mpuric 6:f6a93c155525 25 */
mpuric 0:513b42c738f3 26
mpuric 6:f6a93c155525 27 class DustSenzor {
mpuric 6:f6a93c155525 28
mpuric 0:513b42c738f3 29 public:
mpuric 6:f6a93c155525 30 DustSenzor ( PinName set, PinName uartTx, PinName uartRx );
mpuric 6:f6a93c155525 31 /** Start the communication with sensor.
mpuric 6:f6a93c155525 32 */
mpuric 5:fd42a3f8c7eb 33 void start();
mpuric 6:f6a93c155525 34
mpuric 6:f6a93c155525 35 /** Stop the communication with sensor.
mpuric 6:f6a93c155525 36 */
mpuric 6:f6a93c155525 37
mpuric 5:fd42a3f8c7eb 38 void stop();
mpuric 6:f6a93c155525 39 /** Read the values from a float array with 9 elements. Function is returnig a pointer to the first element of array.
mpuric 6:f6a93c155525 40 */
mpuric 5:fd42a3f8c7eb 41 float* read();
mpuric 5:fd42a3f8c7eb 42
mpuric 6:f6a93c155525 43 /** Reset the sensor. Low reset.
mpuric 6:f6a93c155525 44 */
mpuric 7:067de0268900 45 //void reset();
mpuric 0:513b42c738f3 46
mpuric 0:513b42c738f3 47 private:
mpuric 5:fd42a3f8c7eb 48 float value[9];
mpuric 0:513b42c738f3 49 Serial uart;
mpuric 0:513b42c738f3 50 DigitalOut set;
mpuric 2:4c3bdadb6bc4 51 unsigned char buff[32];
mpuric 2:4c3bdadb6bc4 52 bool provjera;
mpuric 0:513b42c738f3 53 int br;
mpuric 7:067de0268900 54 void serialRead();
mpuric 6:f6a93c155525 55 void readBuffer();
mpuric 5:fd42a3f8c7eb 56 void save( unsigned char *);
mpuric 5:fd42a3f8c7eb 57
mpuric 0:513b42c738f3 58 };
mpuric 0:513b42c738f3 59 #endif
mpuric 0:513b42c738f3 60
mpuric 0:513b42c738f3 61