Exluding ZMOD
Dependencies: iAQ_Core Adafruit_SGP30_mbed mbed BME680
main.cpp@0:d034cdad5b6d, 2019-05-30 (annotated)
- Committer:
- christodoulos
- Date:
- Thu May 30 08:26:56 2019 +0000
- Revision:
- 0:d034cdad5b6d
- Child:
- 1:08bbc3ecd836
flow to 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); |
christodoulos | 0:d034cdad5b6d | 5 | AnalogIn flowIn(A2); |
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 | } |