rs232 input from a sensor

Hey,

So I have an environmental sensor that spits out data over an rs232 serial port. I wrote a program in processing that reads this data and creates an xml from it. When I open the port with processing at 9600, I receive a string that looks something like "A02, T65, P282, H200".

Now I want to connect the sensor to an Arduino and have it read the data. I'm not really sure how I would go about this, but I tried connecting the ground, and the TX and RX ports from the rs232 to the Arduino. I then opened the port at 9600, and began reading bytes as integers. I got a string of indecipherable integers in the serial monitors. Something like:

0 0 0 0 0 0 0 255 49 0 0 0 0 -1 -1 19 49

Then I tried reading it as characters, and I received a string of garage. I thought the numbers might represent Ascii characters, but they don't seem to correspond with anything decipherable.

Any ideas? Thanks.. still learning the basic, and I really appreciate all the help so far.

-Thomas

Thomasbot,

What kind of Arduino are you using? Exactly how are you connecting the sensor output to the Arduino (what Arduino pins, what external components, if any)?

-Mike

I’m using an Arduino Duemilanove. I’m not using any external component, and I’m connecting using pins 2 and 3.

Here’s my code:

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

SoftwareSerial softSerial =  SoftwareSerial(rxPin, txPin);

void setup()  {

  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  softSerial.begin(9600);

  Serial.begin(9600);
}

void loop() {

  int data = softSerial.read();
  Serial.println(data);
}

Thanks

-Thomas

but I tried connecting the ground, and the TX and RX ports from the rs232 to the Arduino

Is the "rs232" on the sensor an actual RS-232 port (+12/-12 volts) or a TTL port (+5/0 volts)?

Your problem is that an RS-232 link cannot be directly wired to an Arduino serial link pins (voltage levels are not compatable). You need a voltage/logic inversion convertor such as a MAX232 chip.

Lefty

Hmm. Its an rs232 port definitely. Is there an easy way to see if it is TTL or not? The technical side of the sensor is unfortunately pretty undocumented, but it uses FTDI drivers to communicate with my PC.

-Thomas

Is there an easy way to see if it is TTL or not?

Measure the voltage on the TxD line from the device with reference to the ground pin on the same connector. Make sure the device isn't tranmitting anything. The idle state will be negative if it's RS232.

There is also a version of this same sensor with a USB port. Would that be any easier?

-Thomas

It would be easier if you wanted to plug it into a PC, but not an Arduino. Is the sensor packaged, or is it hackable?

I could hack it if necessary. Actually, some of the individual sensors are detachable. The air quality sensor just has a positive and negative connection. I'm looking into how to make this work on its own with the Arduino right now. Maybe this is the route I want to go.

-Thomas

OK, so I discovered the board has a TTL tX pin which sends data to a sparkfun LCD screen. I can’t seem to read anything off of it, but its a start.

-Thomas