Hi everyone!
I'm stuck with a problem, and I can't figure out how to solve it...
i'm trying to connect a flow meter (TSI 4000 series FlowMeter) to Arduino in order to send specific commands to set flow limits, type of sample (water, air, N2, etc) and so on.
I've bought an RS232 Shield for Arduino (SparkFun RS232) and i'm using an Arduino Mega.
I'm trying to send a simple command, "?", and I should receive an "OK" message from the flow meter. The problem is that I'm receiving a bunch of squares, and I don't know if it's a coding problem or a connection problem.
I've attached the Black and the green wire from the FlowMeter (+5V and Grownd) to the corresponding pins of the shield, the Yellow and White wires of the FlowMeter (RS-232 Out and RS-232 IN) to the TX and RX pins on the shield, and finally I've connected TX1 and RX1 on the Mega to the MTX and MRX pins on the shield (photo attached). Two jumpers connect MRX to TX and MTX to RX on the shield.
Here the code I'm using:
//SERIAL I/O
const int numReadings = 50;
unsigned int flowRead[numReadings]; // string to be read
byte inread; // dum reading variable
byte r1; //first byte to be read
byte r2; //second byte to be read
byte ack; //acknowledgement byte for reading
//RUNNING AVERAGE
int index = 0; // the index of the current reading
unsigned int flowTot = 0; // the running total
float flowRunMean = 0; // the average
void setup() {
Serial.begin(9600); //USB2SERIAL
Serial1.begin(38400); //flowmeter
}
void loop() {
//~~~~~~~~~~~~~~~~~~~~~~~~~~//
// READINGS DEFAULTS
//~~~~~~~~~~~~~~~~~~~~~~~~~~//
Serial1.write("?/r");
while(Serial1.available()>0){
Serial.write(Serial1.read());
}
delay(1000);
}
What am I doing wrong? Any Help??
Thanks a lot guys!