Hello,
I'm working as an electrical engineer in a company that deals with various embedded systems and water monitoring sensors. The last few days we are trying to connect a Multiparameter Water Quality Sonde with Arduino. The sensor we use is the [YSI 6600 V2](404 | ysi.com Library/Documents/Manuals/069300-YSI-6-Series-Manual-RevJ.pdf) and the microcontroller an Arduino UNO. Our sensor has a DB9 Female connector so we have to achieve a serial communication throughout RS232 protocol.
We first test the proper functionality of our sensor using a RS232 to USB converter. Using a serial console (we like using PuTTY for such things) we managed easily to achieve a communication with our sensor and receive data.
The purpose of our project is to connect it with a microcontroller and this is where the problem begin. Reading carefully its manual we understood that we have to use a RS232 shifter to convert RS232 to TTL and vice versa. Our sensor operates at 12V so we purchased a relevant shifter in order to convert RS232 to 5V TTL. In order to achieve a proper connection we also use a RS-232 DB9 male to male connector.
Below you can see the Arduino code we use:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Let's start!");
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
}
void loop() {
if (mySerial.available()) {
Serial.write(mySerial.read());
}
if (Serial.available()) {
mySerial.write(Serial.read());
}
}
By opening the serial monitor of the Arduino IDE we tried to send commands to our sensor but we didn't manage to receive an answer. Any guidance on our problem is more than welcome . We can't understand if we did something wrong with the connection or is purely a programming fault.
Your baud rate is too high for a software serial port implementation. I seem to recall that the limit is around 19200 baud, although a quick check on the PJRC website for AltSoftSerial indicates that it might reach 31250 baud on a 16MHz AVR.
markd833:
Your baud rate is too high for a software serial port implementation. I seem to recall that the limit is around 19200 baud, although a quick check on the PJRC website for AltSoftSerial indicates that it might reach 31250 baud on a 16MHz AVR.
Thank you for your response! We also tried with smaller baud rates (such as 9600) but the problem still exists.
Hi,
The module looks like it uses 19200 baud.
Which serial is it connected too?
The Serial or mySerial.
I gather mySerial is connected to the module, in which case mySerial.begin(19200);
Serial is connected to the IDE monitor.
Make sure the IDE monitor baud is the same as Serial.begin.
Hi,
If you read the setup instructions for a PC with the ECO Watch to communicate with the module you will find it shows 19200.
Page 2-26.
I do see where it shows 9600 elsewhere, so may need some closer reading.
@Tom, yeah that document is a bit of a mess (in my opinion!). Page 2-24 says that the baud rate should be 9600, then page 2-25 shows 19200 being selected. Then page 2-96 says that the available baud rates are 300, 600, 1200, 2400, 4800 & 9600.
Section 7 (page 7-1) agrees with the low baud rates from page 2-96.
@OP - I would get your sensor working using Putty at 9600 baud or lower just so that you know you have the right serial parameters. Also make sure that you are using 8 data bits, no parity and 1 stop bit as I think the software serial port libraries on Arduino don't support odd/even parity or more than 1 stop bit.
Double check if the signals are straight through or crossover ... also check your cables.
Pin mappings can change with cables and gender changers. I've used older industrial equipment that required a null modem adapter (cable) to interface the RS232C correctly. Technical resource and products (pricey).
dlloyd: Double check if the signals are straight through or crossover ... also check your cables.
Pin mappings can change with cables and gender changers. I've used older industrial equipment that required a null modem adapter (cable) to interface the RS232C correctly. Technical resource and products (pricey).
Thank you for your response! This was one of the very first things we checked and we are pretty sure that there is no crossover. Anyway the technical resource you provided is a hidden gem for future projects. Thanks
markd833: @Tom, yeah that document is a bit of a mess (in my opinion!). Page 2-24 says that the baud rate should be 9600, then page 2-25 shows 19200 being selected. Then page 2-96 says that the available baud rates are 300, 600, 1200, 2400, 4800 & 9600.
Section 7 (page 7-1) agrees with the low baud rates from page 2-96.
@OP - I would get your sensor working using Putty at 9600 baud or lower just so that you know you have the right serial parameters. Also make sure that you are using 8 data bits, no parity and 1 stop bit as I think the software serial port libraries on Arduino don't support odd/even parity or more than 1 stop bit.
I have already achieve a connection between the sensor and my computer using Putty and I confirm that the correct baud rate is 9600 (by default, you can change it to other values based on the manual). Could you explain me how can I check that I' m using 8 data bits, no parity and 1 stop bit? What changes do I have to do in my code in such cases?
What settings did you use in PuTTY besides 9600 baud?
On my opening screen of PuTTY down at the bottom the category list, if I click on serial, I get the COM port, baud rate, data bits, stop bits parity and flow control.
So connecting your sensor to a pc works (I assume) using a 6095B PC Adaptor?
But connecting to an Arduino using the 6095B + SparkFun RS232 Shifter fails?
(See schematic and see Customer Reviews #2)
You might need a MAX232 type adapter (datasheet) instead of the shifter because the chip includes a step-up DC-DC converter for the necessary signal level for RS232 communication.
ioannis94:
By opening the serial monitor of the Arduino IDE we tried to send commands to our sensor but we didn't manage to receive an answer.
Did you succesfully send and receive answers in Putty? I mean, a timestsamp string with the data from all the sensors? I am not certain this sensor can be put in Poll command and I have not find any reference to it in the manual (but it's a big manual...). I do what you try all the time with RBR sensors. Licor sensors. They have specifics set of command for that and they usually list them somewhere. Never tried with YSI.
You may have to pre-program the sensor for outputting data every X interval with the software and then only listen to the port for catching data if/when available?
The EXO2 model can work with serial / ttl. I d'ont know for the V6600.
cdb101:
Did you succesfully send and receive answers in Putty? I mean, a timestsamp string with the data from all the sensors? I am not certain this sensor can be put in Poll command and I have not find any reference to it in the manual (but it's a big manual...). I do what you try all the time with RBR sensors. Licor sensors. They have specifics set of command for that and they usually list them somewhere. Never tried with YSI.
You may have to pre-program the sensor for outputting data every X interval with the software and then only listen to the port for catching data if/when available?
The EXO2 model can work with serial / ttl. I d'ont know for the V6600.
Ok, I should have read your initial post better. You receive data in putty. If you have the list of command to communicate, I am interested. I still think this sensor cannot be polled in rs-232 (you can only listen to it) but it will work using SDI12.
1- I don't see a cariage return in your code. Terminal emulator sometime send it for you. The arduino might not?
2- Some sensors, require that you set the DTR pin high to initiate a communication. Again, this is someting your PC will do but not Arduino. In those case, I physically wire the DTR pin to +5volts. When done, the sensor start to output data at it's define interval.
Hello,
Not all pins on a Arduino board can be used to do Softserial.
I see you are using 10,11, could be that they are not fit for the purpose.
Pins that are for sure fit, are 2 and 3. I think you need interrupt pins to be able to receive the data.
I have been stuck on this issue with a Mega for a long time, so I remember.
Why will 2 an 3 work properly with Softserial?
There is a shield, that was for long available that does provide RS232C and RS422 hardware serial and software serial, this shield connects the on board tranceiver to 0-1 (for hardware serial) and (2-3) for software serial. Link here you see the shield that will fit your needs.
Now, to analyze your problem:
If you connect with a wire pin 10-11, then if you send, you should be able to receive what you have sent via SoftSerial. This without the converter you bought connected to 10-11 so it cannot get in the way.
If this works, connect pin 2 and 3 on your DB9 converter with a wire. Then do the same experiment, then you should be again able to get back what you wrote to your port.
If all these work, then you can connect your external device, I am quite sure that if all steps described above work, you will be very very close to your final solution.