Dust sensor
Fork of DustSenzor by
DustSenzor.h@8:faa84647167c, 2017-06-14 (annotated)
- Committer:
- mpuric
- Date:
- Wed Jun 14 17:24:09 2017 +0000
- Revision:
- 8:faa84647167c
- Parent:
- 7:067de0268900
- Child:
- 9:93fe9ccde2a9
init commit;
Who changed what in which revision?
User | Revision | Line number | New 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 | 8:faa84647167c | 42 | |
mpuric | 0:513b42c738f3 | 43 | |
mpuric | 0:513b42c738f3 | 44 | private: |
mpuric | 8:faa84647167c | 45 | float value[6]; |
mpuric | 0:513b42c738f3 | 46 | Serial uart; |
mpuric | 0:513b42c738f3 | 47 | DigitalOut set; |
mpuric | 2:4c3bdadb6bc4 | 48 | unsigned char buff[32]; |
mpuric | 2:4c3bdadb6bc4 | 49 | bool provjera; |
mpuric | 0:513b42c738f3 | 50 | int br; |
mpuric | 7:067de0268900 | 51 | void serialRead(); |
mpuric | 6:f6a93c155525 | 52 | void readBuffer(); |
mpuric | 5:fd42a3f8c7eb | 53 | void save( unsigned char *); |
mpuric | 5:fd42a3f8c7eb | 54 | |
mpuric | 0:513b42c738f3 | 55 | }; |
mpuric | 0:513b42c738f3 | 56 | #endif |
mpuric | 0:513b42c738f3 | 57 | |
mpuric | 0:513b42c738f3 | 58 |