Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DustSenzor by
DustSenzor.h@6:f6a93c155525, 2017-06-08 (annotated)
- Committer:
- mpuric
- Date:
- Thu Jun 08 16:50:46 2017 +0000
- Revision:
- 6:f6a93c155525
- Parent:
- 5:fd42a3f8c7eb
- Child:
- 7:067de0268900
Added comments.
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 | 5:fd42a3f8c7eb | 42 | |
| mpuric | 6:f6a93c155525 | 43 | /** Reset the sensor. Low reset. | 
| mpuric | 6:f6a93c155525 | 44 | */ | 
| mpuric | 6:f6a93c155525 | 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 | 5:fd42a3f8c7eb | 54 | void serialSensor(); | 
| 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 | 
