Srinivasan Ramasamy
/
EC
Water quality
main.cpp@0:ef33eee73e62, 2014-12-23 (annotated)
- Committer:
- ramsphd
- Date:
- Tue Dec 23 10:24:43 2014 +0000
- Revision:
- 0:ef33eee73e62
Electrical conductivity
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ramsphd | 0:ef33eee73e62 | 1 | #include "mbed.h" |
ramsphd | 0:ef33eee73e62 | 2 | #include <stdio.h> |
ramsphd | 0:ef33eee73e62 | 3 | |
ramsphd | 0:ef33eee73e62 | 4 | |
ramsphd | 0:ef33eee73e62 | 5 | DigitalOut myled(LED1); |
ramsphd | 0:ef33eee73e62 | 6 | Serial pc(USBTX, USBRX); |
ramsphd | 0:ef33eee73e62 | 7 | Serial async_port(p9,p10); |
ramsphd | 0:ef33eee73e62 | 8 | |
ramsphd | 0:ef33eee73e62 | 9 | |
ramsphd | 0:ef33eee73e62 | 10 | int main() { |
ramsphd | 0:ef33eee73e62 | 11 | char A[100]; |
ramsphd | 0:ef33eee73e62 | 12 | char *pch; |
ramsphd | 0:ef33eee73e62 | 13 | int t=0; |
ramsphd | 0:ef33eee73e62 | 14 | |
ramsphd | 0:ef33eee73e62 | 15 | pc.printf("EC = "); |
ramsphd | 0:ef33eee73e62 | 16 | async_port.baud(38400); |
ramsphd | 0:ef33eee73e62 | 17 | //async_port.puts("27,b\r"); |
ramsphd | 0:ef33eee73e62 | 18 | |
ramsphd | 0:ef33eee73e62 | 19 | //async_port.puts("C0\r"); |
ramsphd | 0:ef33eee73e62 | 20 | |
ramsphd | 0:ef33eee73e62 | 21 | /*async_port.puts("O,S,1\r"); |
ramsphd | 0:ef33eee73e62 | 22 | wait(1); |
ramsphd | 0:ef33eee73e62 | 23 | async_port.puts("O,SG,1\r"); |
ramsphd | 0:ef33eee73e62 | 24 | wait(1); |
ramsphd | 0:ef33eee73e62 | 25 | async_port.puts("O,TDS,1\r"); |
ramsphd | 0:ef33eee73e62 | 26 | wait(1); |
ramsphd | 0:ef33eee73e62 | 27 | async_port.puts("O,EC,1\r"); |
ramsphd | 0:ef33eee73e62 | 28 | wait(1);*/ |
ramsphd | 0:ef33eee73e62 | 29 | async_port.puts("R\r"); |
ramsphd | 0:ef33eee73e62 | 30 | |
ramsphd | 0:ef33eee73e62 | 31 | //async_port.puts("L,1\r"); |
ramsphd | 0:ef33eee73e62 | 32 | |
ramsphd | 0:ef33eee73e62 | 33 | |
ramsphd | 0:ef33eee73e62 | 34 | //async_port.puts("K,1.0\r"); |
ramsphd | 0:ef33eee73e62 | 35 | //async_port.puts("Cal,dry\r"); |
ramsphd | 0:ef33eee73e62 | 36 | //async_port.puts("Cal,high,80000\r"); |
ramsphd | 0:ef33eee73e62 | 37 | //async_port.puts("Cal,low,12800\r"); |
ramsphd | 0:ef33eee73e62 | 38 | //async_port.puts("Cal,?\r"); |
ramsphd | 0:ef33eee73e62 | 39 | |
ramsphd | 0:ef33eee73e62 | 40 | wait(1); |
ramsphd | 0:ef33eee73e62 | 41 | async_port.gets(A,20); |
ramsphd | 0:ef33eee73e62 | 42 | //pc.printf(A); |
ramsphd | 0:ef33eee73e62 | 43 | pc.printf("\n\r"); |
ramsphd | 0:ef33eee73e62 | 44 | pch = strtok (A,","); |
ramsphd | 0:ef33eee73e62 | 45 | |
ramsphd | 0:ef33eee73e62 | 46 | while (pch != NULL) |
ramsphd | 0:ef33eee73e62 | 47 | { |
ramsphd | 0:ef33eee73e62 | 48 | switch(t) |
ramsphd | 0:ef33eee73e62 | 49 | { |
ramsphd | 0:ef33eee73e62 | 50 | case 0: pc.printf ("EC = %s\n",pch); break; |
ramsphd | 0:ef33eee73e62 | 51 | case 1: pc.printf ("TDS = %s\n",pch); break; |
ramsphd | 0:ef33eee73e62 | 52 | case 2: pc.printf ("SAL = %s\n",pch); break; |
ramsphd | 0:ef33eee73e62 | 53 | case 3: pc.printf ("SG = %s\n",pch); break; |
ramsphd | 0:ef33eee73e62 | 54 | |
ramsphd | 0:ef33eee73e62 | 55 | } |
ramsphd | 0:ef33eee73e62 | 56 | t++; |
ramsphd | 0:ef33eee73e62 | 57 | pch = strtok (NULL, ","); |
ramsphd | 0:ef33eee73e62 | 58 | } |
ramsphd | 0:ef33eee73e62 | 59 | /* wait(10); |
ramsphd | 0:ef33eee73e62 | 60 | pc.printf("TDS="); |
ramsphd | 0:ef33eee73e62 | 61 | async_port.puts("O,TDS,1\r"); |
ramsphd | 0:ef33eee73e62 | 62 | async_port.puts("O,EC,0\r"); |
ramsphd | 0:ef33eee73e62 | 63 | async_port.puts("R\r"); |
ramsphd | 0:ef33eee73e62 | 64 | wait(10); |
ramsphd | 0:ef33eee73e62 | 65 | async_port.gets(A,6); |
ramsphd | 0:ef33eee73e62 | 66 | pc.printf(A); |
ramsphd | 0:ef33eee73e62 | 67 | pc.printf("\n\r"); |
ramsphd | 0:ef33eee73e62 | 68 | */ |
ramsphd | 0:ef33eee73e62 | 69 | |
ramsphd | 0:ef33eee73e62 | 70 | |
ramsphd | 0:ef33eee73e62 | 71 | } |