SGP30 (used in POCBreath_V2_smd_commercial)
Dependencies: Adafruit_SGP30_mbed mbed
main.cpp@1:08bbc3ecd836, 2019-06-04 (annotated)
- Committer:
- mehrnaz
- Date:
- Tue Jun 04 14:48:16 2019 +0000
- Revision:
- 1:08bbc3ecd836
- Parent:
- 0:d034cdad5b6d
- Child:
- 2:ef98576cd67b
flow for bluetooth
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
christodoulos | 0:d034cdad5b6d | 1 | #include "mbed.h" |
christodoulos | 0:d034cdad5b6d | 2 | #include <SoftSerial.h> |
christodoulos | 0:d034cdad5b6d | 3 | |
christodoulos | 0:d034cdad5b6d | 4 | Serial ble(A4,A5); |
mehrnaz | 1:08bbc3ecd836 | 5 | AnalogIn flowIn(A3); |
christodoulos | 0:d034cdad5b6d | 6 | |
christodoulos | 0:d034cdad5b6d | 7 | float flowVal1; |
christodoulos | 0:d034cdad5b6d | 8 | float flowVal2; |
christodoulos | 0:d034cdad5b6d | 9 | float Pressure; |
christodoulos | 0:d034cdad5b6d | 10 | float finalflow; |
christodoulos | 0:d034cdad5b6d | 11 | |
christodoulos | 0:d034cdad5b6d | 12 | float flow() |
christodoulos | 0:d034cdad5b6d | 13 | { |
christodoulos | 0:d034cdad5b6d | 14 | flowVal1=3.3*flowIn; //Logic level 3.3 |
christodoulos | 0:d034cdad5b6d | 15 | flowVal2 = 1.5*flowVal1; //5v |
christodoulos | 0:d034cdad5b6d | 16 | Pressure =(125*flowVal2)-62.5; |
christodoulos | 0:d034cdad5b6d | 17 | finalflow=(0.1989*sqrt(Pressure))+0.0284; //flow in litter per min |
christodoulos | 0:d034cdad5b6d | 18 | return finalflow; |
christodoulos | 0:d034cdad5b6d | 19 | |
christodoulos | 0:d034cdad5b6d | 20 | } |
christodoulos | 0:d034cdad5b6d | 21 | |
christodoulos | 0:d034cdad5b6d | 22 | int main(){ |
christodoulos | 0:d034cdad5b6d | 23 | ble.baud(9600); |
christodoulos | 0:d034cdad5b6d | 24 | while(1){ |
christodoulos | 0:d034cdad5b6d | 25 | ble.printf("E2.7, %f, 3.3\n", flow()); |
christodoulos | 0:d034cdad5b6d | 26 | } |
christodoulos | 0:d034cdad5b6d | 27 | |
christodoulos | 0:d034cdad5b6d | 28 | } |