DUST-TRACK DATA LOGGER / How to get string data through Serial communication?

Hello

I’m just making data logger of dust-track machine.

Originally it communicate with computer through hypercommunication

I just want to connect it to arduino and wanna save the data with sdcard( arduino yun)

it gets serial data as ASC2 code

the problem is void Get_DTRK_Data() part

I just write it with the reference of PDR machine but it’s bit different and it cannot get anything from the machine

it’s baudrate is 1200 and data bits is 8

i just want to check the data per second. it’s enough

how to read the data from the machine ?..;;;

DTRK_Only_ver1.ino (1.19 KB)

#include <stdlib.h>
#include <Wire.h>
#include <SoftwareSerial.h>


const int chipSelect = 4; //For SD Card
int nEnable = 1;

char DTRK_Conc[10], DTRK_Temp[10], DTRK_RH[10],DTRK_Pres[10];
char caWindSpeed[10], caWindDir[10];
char caHumidity[10],caTemp[10],caTempF[10],caBattery_V[10];

// SoftwareSerial mySerial(12,13);

void setup()
{

  Serial.begin(1200);  //DTRK
  //Serial3.begin(9600);  // For wind sensor
  delay(1000);
 
}


void Get_DTRK_Data()
{
  byte index = 0;
  char caDTRK[81];

  caDTRK[0] = 'X';;
  while(Serial.available()>0)
  {
    char inChar = Serial.read();
    caDTRK[index++] = inChar;
    caDTRK[index] = '\0';
  }
  //Serial.println("Serial input: ");
  //Serial.println(caDTRK);
  if (caDTRK[0] == 'O') // Read any data if avaialable
  { 
  //New output received from DTRK, Format = "2.93"
  sscanf (caDTRK,"%s",DTRK_Conc);
  Serial.print("DTRK_Conc = ");
  Serial.print(DTRK_Conc);
  } 
  else
  { 
   // If no new output, trigger DTRK to send ou
  Serial.write("ASDATA01"); // serial command to retrieve data every 1 sec
  Serial.write(1);
  Serial.println("oh sent to Serial1 - DTRK");
  }
}
  

void loop() {
  Get_DTRK_Data();
  //Get_RM_Young_Data();
  //Get_Vaisala_Data();

}

I just write it with the reference of PDR machine

What PDR machine? What reference?

Are you using Serial to talk to the machine OR to talk to the PC? Both is the wrong answer. So is yes.

If you are using Serial to talk to the machine, how are you debugging the code?

You seem to be using Pins 0 and 1 to read data from your device (with Serial.read() ), but then you also seem to be using Serial.print() to send data back to the device. If you have the PC connected to your Arduino at the same time there will be confusion because Pins 0 and 1 are also used to communicate with the PC.

Why are you not using SoftwareSerial to read from the device and Serial to send data to the Serial Monitor for debugging and such.

You may find the examples in serial input basics useful. They are simple and reliable.

...R

I'm just making data logger with DUSTTRACK machine. and originally it communicates with PC through serial communication

I just connect it to arduino yun and want get data through ARDUINO

Originally, the serial command to get data from machine is ASDATA. then the machine returns the value it gets with its sensor. ( ASC2)

My question is

How to send the letter ASDATA to machine, and how can i read the returns from the machine?

Any examples or advice.... Help me... I'm really in hurry..

Best

What do mean by "the letter ASDATA"?
That's six letters.

lsk3411:
I'm just making data logger with DUSTTRACK machine. and originally it communicates with PC through serial communication

I just connect it to arduino yun and want get data through ARDUINO

Post a link to the datasheet for this DUSTTRACK machine?

How does it physically connect to your PC?
What Operating System is in the PC ?

It sounds to me like the device connects with a USB cable and you are connecting it to the Yun's USB connector.

And this is the first time you have mentioned a Yun - which is very different from a regular Arduino such as an Uno or Mega. If this is a Yun project you should ask the Moderator to move this Thread to the Yun section of the Forum.

If the device connects to the Yun's USB port I suspect you could write a Python program for your Yun that would read the data.

Maybe you should first write a Python program on your PC and get that working. With a bit of luck the same program will work on the Yun.

...R