density sensor with arduino uno using rs232 to ttl converter

im doing a project where i have to connect various sensors and send the data to cloud and one of those sensors is dm500 ultrasonic density sensor which has a rs232 output. so i used rs232 to ttl converter to interface it with arduino uno im using, but there are lot of problems like

  1. sensor data is not displayed in the format written in the code(it displays the same as it in hyperterminal)
  2. data is displayed only when the arduino board is reset
  3. data is displayed only once a 40 sec if i programmed it to reset continuously

so i donno what to do with this can anyone help me with this one??

can anyone help me with this one??

My crystal ball says the problem is on line 119719819987199 of your code. But, maybe that's its serial number...

You posted no code. You posted no schematic. You posted no link to the hardware you are using. You posted no program output. So, obviously you don't really want help.

sorry for that, im new here..
#include<SoftwareSerial.h>
SoftwareSerial myserial(2,3);
char data;
int finish=0;
int i=0;
char array[20];

void setup() {
Serial.begin(9600);
myserial.begin(9600);

}

void loop()
{
sensor();
if(finish)
{
Serial.write(myserial.read());
Serial.print("density:");
Serial.print(array);
Serial.println("gm per cm cube");
finish=0;
i=0;
}

}

void sensor()
{
while(myserial.available()>0)
{
data= myserial.read();
if(data !=0x0D && finish==0)
{
array[i++]=data;
}
if(data==0x0D)
{
finish=1;
}
}
}

this is the code i used but i get values only on pin 0,1 that too with all the problems i meantion before
and coming to the schematics i made a null modem and
density sensor gnd,vcc,tx,rx to rs232 gnd,vcc,tx,rx and then
ttl converter rx,tx,gnd,vcc to arduino tx,rx,gnd,3.3v respectively

Why this...?

Serial.write(myserial.read());

At that point in time, the following serial character hasn't arrived yet.

You never check if you overran the end of the array[20] array. You could be writing to memory you don't own. Use a named constant for the size.

When you print the array, how does the print() function know where the end of the array is? It is expecting a C-style string which has a null character at the end. Maybe Serial.write(array, i); will do what you want.

Use code tags next time. This is your first warning.

i tried to use the same code with ultrasonic sensor echo pro, and it gives data correctly and i want to post this data to the cloud. i can send the data to cloud as " Distance:D003.4T024*C " but i want to post the data in json array format as the backend guy told the server could only accept data in json array . so can you tell me how to do this. i have no idea about json array. i tried to gather some info from net but i didnt get any clarity. so can you help me with this?

Sorry, I've never used JSON. Perhaps someone else here can help.