Show Posts
Pages: [1]
1  Topics / Home Automation and Networked Objects / Re: pH monitoring with Atlas Scientific pH stamp on: March 28, 2012, 03:30:48 pm
This board has a continuous and on demand mode.  Send it an "E" command to terminate continuous. Send it a "C" command to get a value periodically say every 10 seconds. Calibration has to be performed with a 7 and 4 or 7 and 10 standard. Do the 7 first as this fixes the intercept then do 4 as this fixes the slope.

You may also want to consider using analog ports rather than serial when you have more than one sensor (pH and EC). These are some options.

http://webpages.charter.net/tdsmeter/

http://www.phidgets.com/products.php?category=6&product_id=1130_0

You could add a temp sensor on yet a another analog port but the accuracy required for hydro use may not justify it unless you will be controlling envrionmental equipment.
2  Topics / Home Automation and Networked Objects / XBee with tow Arduinos connected to Pc for programming on: March 21, 2012, 01:18:30 pm
Can I have two UNO's with xBee radios connected to the same PC so that I can do sketch development on the PC and still have the two UNOs talking xBee when I test. BTW I have not used xBee but want to learn how to use it for arrays of sensors in a hydroponics setup. I have a mega interfaced to my PC control software now but want to get rid of lots of wires and have more localized activities going on. Just need to establish what the best development setup might be to get me started. Thanks for any help.
3  Using Arduino / Programming Questions / Re: Help making up a string from various data sources on: March 09, 2012, 03:22:37 pm
Never mind, I found one accidentally.
4  Using Arduino / Programming Questions / Re: Help making up a string from various data sources on: March 09, 2012, 02:52:39 pm
Thanks very much. I fiddled with the code and got the sprintf to do it. I couldn't find a lot of stuff on sprintf for Arduino. Addressing modes are slowly sinking in. I'm not a C++ guy. Is there another source of knowledge for these constructs in the context of Arduino. I would at the very least like to get a handle on the sprintf formatting choices for future work. My searches were largely unprodutive.
5  Using Arduino / Programming Questions / Help making up a string from various data sources on: March 09, 2012, 12:09:46 pm
I would like to make a string out of the data in these prints and pass it to one routine for the send. I have tried all manner of stuff and get nowhere. I would like to avoid the overhead of the string class if possible. If not I guess I can just leave the prints or pass a wack of parameter to the sendmessage routine (not elegant).


Code:
           char* sendmsg;                 //message string to send to PC

            sendmsg = ??????              //some code here to make the string up
            sendmessage(sendmsg);   //and use the routine instead of the prints below 

 
            Serial.print("AQ:");             //optimize this sometime by using a function
            Serial.print(i);                  //i and v are ints
            Serial.print(':');
            Serial.print(v);


     
//one send routine for the sketch
void sendMessage(char* myString)  //send a command message to the PC
{
  mystring = "{" + mystring + "}" + '0'
  Serial.print(myString);
}

   
6  Using Arduino / Programming Questions / noob need help understanding function parameters on: March 07, 2012, 10:36:16 pm
I want to pass a 2 char mnemonic to a function and have it return the index. I an very new to this world and cannot seem to get this to work. I get the parsed strings OK. I want to pass them to the function getmnemonic and have it give me the index. The memory stuff is fouling me up. Can someone please help.

Code:
#include <string.h>

int cp = 0; // char pointer
boolean cfound = false; // complete command found
boolean cstart = false; // start of command
char stringIn[50]; // commandbuffer

char *parsed[10];   //parsed strings[/color]int counter = 0;   //initialise the counter
char *command[]={"FF","DF","SF","SD","pH","EC","CN","FR","FM","PR","PN","PC","SN"};

#define SOC '{'
#define EOC '}'

void setup() {
 Serial.flush();
 Serial.begin(9600);
 delay(500);
 //Serial.print("(:H:)");
}

 void loop() {
 int sa;
 char bt;
 sa = Serial.available(); // count serial buffer bytes
 
 if (sa > 0) { // if buffer not empty process buffer content
  for (int i=0; i < sa; i++){
   bt = Serial.read(); // read one char from the serial buffer
     
   if (cstart )
   {
    stringIn[cp] = bt;
    cp++;
   }
   
   if (bt == SOC) { // got a start of command
    cstart = true;
    //Serial.println("start");
   }
     
   if (bt == EOC && cstart) { // check for last command char )
    cfound = true;
    stringIn[--cp] = NULL;
    counter=0;
    break; // end for-loop
   }
  }
 }
 
 if (cfound) {
   for (int i=0; i<cp; i++){
      Serial.print(stringIn[i]);   //data is correct at this point
    }
 
  char *token = strtok(stringIn, ":");
 
  if(token)
  {
   parsed[counter++] = strdup(token); // You've got to COPY the data pointed to
   token = strtok(NULL, ":"); // Keep parsing the same string
   
   while(token)
   {
      //Serial.println(atoi(parsed[0]));
      parsed[counter++] = strdup(token); // You've got to COPY the data pointed to
      token = strtok(NULL, ":");
   }
   
   if (counter > 0 )
    {
     processmessage();
    }
   cp = 0;
   stringIn[cp] = NULL;
   cstart = false;
   cfound = false;
   }
  }
 }
 
 //convert string to integer  int i = atoi(string);
 //convert string to float float x = float(string);
 //send float out serial Serial.print(x,2);  x is float to 2 decimal places
 
 void processmessage(void)
  {
     
  Serial.println(counter);
  for (int i=0; i<counter; i++) {
  Serial.println( parsed[i]);
  }
 
  switch (getmnemonic(parsed[0])) {
   
   case 0: //FF Channel fill float
   Serial.println("Fill float");
   
   break;
   
   case 1: //DF Channel drain float
   Serial.println("Drain float");
   
   break;
  }
 }

int getmnemonic(char* code )
 {
   
   Serial.println( code);
   for (int i=0; i< 12; i++)
   {
    if (command[i] == code)
     {
      Serial.println("match");
      return(i);
      break;
     }
   }
 }



7  Using Arduino / Programming Questions / Re: Help parsing data with strtok on: March 07, 2012, 03:17:12 pm
I think I found my issue. I am very new at this variable incrementing. Th print statements had nothing to print  duh!! Thanks aging for the help.
8  Using Arduino / Programming Questions / Re: Help parsing data with strtok on: March 07, 2012, 03:09:45 pm
Thanks much for your help. I pasted that code in and changed the array with *. I still get no strings out.

Code:
#include <string.h>

int cp = 0; // char pointer
boolean cfound = false; // complete command found
boolean cstart = false; // start of command
char stringIn[50]; // commandbuffer
char *parsed[10];   //parsed strings
int counter = 0;   //initialise the counter
byte index =0;
char delims[]=":";

#define SOC '{'
#define EOC '}'

void setup() {
 Serial.flush();
 Serial.begin(9600);
 delay(500);
 //Serial.print("(:H:)");
}

 void loop() {
 int sa;
 char bt;
 sa = Serial.available(); // count serial buffer bytes
 
 if (sa > 0) { // if buffer not empty process buffer content
  for (int i=0; i < sa; i++){
   bt = Serial.read(); // read one char from the serial buffer
     
   if (cstart ) {
    stringIn[cp] = bt;
    cp++;
     //Serial.print(bt);
   }
   
   if (bt == SOC) { // got a start of command
    cstart = true;
    //Serial.println("start");
   }
     
   if (bt == EOC && cstart) { // check for last command char )
    cfound = true;
    stringIn[--cp] = NULL;
    break; // end for-loop
   }
  }
 }
 
 if (cfound) {
   for (int i=0; i<cp; i++){
      Serial.print(stringIn[i]);   //data is correct at this point
    }
 
  counter = 0; //initialise the counter
  char *token = strtok(stringIn, ":");
 
  if(token)
  {
   parsed[counter++] = strdup(token); // You've got to COPY the data pointed to
   Serial.println( parsed[counter]);
   
   token = strtok(NULL, ":"); // Keep parsing the same string
   while(token)
   {
      parsed[counter++] = strdup(token); // You've got to COPY the data pointed to
      token = strtok(NULL, ":");
      Serial.println( parsed[counter]);  //nothing prints here
   }
   cp = 0;
   stringIn[cp] = NULL;
   cstart = false;
   cfound = false;
   }
  }
 }
9  Using Arduino / Programming Questions / Re: Help parsing data with strtok on: March 07, 2012, 01:46:07 pm
I have been at this for hours. I found some code on an old forum and cannot locate it here. Anyways, I am trying to parse serial data (yeah I know its all over the place and I have looked all over the place). But, this code just loops and loops and I can't get the component strings. The correct string gets to the while loop but it never terminates. Could someone please assist.

Code:
#include <string.h>

int cp = 0; // char pointer
boolean cfound = false; // complete command found
boolean cstart = false; // start of command
char stringIn[50]; // commandbuffer
char parsed[50];   //parsed strings
int counter = 0;   //initialise the counter
byte index =0;

#define SOC '{'
#define EOC '}'

void setup() {
 Serial.flush();
 Serial.begin(9600);
 delay(500);
 Serial.print("(:H:)");
}

 void loop() {
 int sa;
 char bt;
 sa = Serial.available(); // count serial buffer bytes
 
 if (sa > 0) { // if buffer not empty process buffer content
  for (int i=0; i < sa; i++){
   bt = Serial.read(); // read one char from the serial buffer
     
   if (cstart ) {
    stringIn[cp] = bt;
    cp++;
     //Serial.print(bt);
   }
   
   if (bt == SOC) { // got a start of command
    cstart = true;
    //Serial.println("start");
   }
     
   if (bt == EOC && cstart) { // check for last command char )
    cfound = true;
    stringIn[--cp] = NULL;
    break; // end for-loop
   }
  }
 }
 
 if (cfound) {
   for (int i=0; i<cp; i++){
      Serial.print(stringIn[i]);   //data is correct at this point
    }
   
 counter = 0; //initialise the counter
 char *p = stringIn; //assign the address of stringIn to *p
 char *str;          //intialize str
             
 while ((str = strtok_r(p, ":", &p)) != NULL) // delimiter is the colon
  {
   parsed[counter] = *str; //use the counter as an index to add each value to the array
   counter++; //increment the counter
   p = NULL; 
   Serial.print( parsed[counter]);
  }
  cp = 0;
  stringIn[cp] = NULL;
  cstart = false;
  cfound = false;
  }
 }
10  Topics / Home Automation and Networked Objects / Re: ArduinoGrow on: March 06, 2012, 02:24:29 pm
The first version is up and running.

http://peterphrastus.com/drupal/HydroHomeSoft_hydroponics_software_manual
11  Topics / Home Automation and Networked Objects / Re: ArduinoGrow on: February 21, 2012, 09:33:13 am
The plan is to have ArduinoGrow on the site in a few days. It will basically be the same as HydroHomeSoft initially. In the future, it is hoped that more of the capabilities of the Arduino can be exploited to offload PC functionality. Hopefully, others would like to participate in that process. A command language can be developed for the interface between the PC and the Arduino.
Pages: [1]