Water quality

Dependencies:   mbed

main.cpp

Committer:
ramsphd
Date:
2014-12-23
Revision:
0:ef33eee73e62

File content as of revision 0:ef33eee73e62:

#include "mbed.h"
#include <stdio.h>


DigitalOut myled(LED1);
Serial pc(USBTX, USBRX);
Serial async_port(p9,p10);


int main() {
    char A[100];
    char *pch;
    int t=0;
    
    pc.printf("EC = ");
    async_port.baud(38400);
    //async_port.puts("27,b\r");
    
    //async_port.puts("C0\r");
    
    /*async_port.puts("O,S,1\r");
    wait(1);
    async_port.puts("O,SG,1\r");
    wait(1);
    async_port.puts("O,TDS,1\r");
    wait(1);
    async_port.puts("O,EC,1\r");
    wait(1);*/
    async_port.puts("R\r");
    
    //async_port.puts("L,1\r");
    
    
    //async_port.puts("K,1.0\r");
    //async_port.puts("Cal,dry\r");
    //async_port.puts("Cal,high,80000\r");
    //async_port.puts("Cal,low,12800\r");
    //async_port.puts("Cal,?\r");
    
    wait(1);
    async_port.gets(A,20);
    //pc.printf(A);
    pc.printf("\n\r");
    pch = strtok (A,",");
    
  while (pch != NULL)
  {
    switch(t)
    {
       case 0: pc.printf ("EC = %s\n",pch); break;
       case 1: pc.printf ("TDS = %s\n",pch); break;
       case 2: pc.printf ("SAL = %s\n",pch); break;
       case 3: pc.printf ("SG = %s\n",pch); break;
       
  }
   t++; 
    pch = strtok (NULL, ",");
  }
  /*  wait(10);
    pc.printf("TDS=");
    async_port.puts("O,TDS,1\r");
    async_port.puts("O,EC,0\r");
    async_port.puts("R\r");
    wait(10);
    async_port.gets(A,6);
    pc.printf(A);
    pc.printf("\n\r");
    */
    
    
    }