VAISALA CO2 Sensor - Serial Comm

Dear fellow people compensating time for not having a girlfriend, {just joking, I'm even married}

I'm dealing with a problem and desperately in need for help right now. I'm opening a mushroom farm and could get my hands cheaply on a high quality CO2 measurement device (VAISALA GMT 220) which works even under high relative humidity up to 99%. So far so good!

The former owner of the sensor had it always connected to an Arduino Mega for purposes of Serial Communication, like setting the airpressure, threshold values etc.

He gave me a sketch, he was working with. (follows at the end)

I myself am the owner of an Arduino Uno Board, and successfully tried to apply the sketch on my Arduino. Unfortunately it is not working the way it should. I connected the Cables TX/RX and GND - 100% correctly. But whenever I send a command via the Serial Monitor, it's just puking out a distorted version of the same command. In some FB-Group a guy was mentioning that I might connected the Sensor to the same UART as the Serial Monitor. Although the Sketch I'm using should actually simulate another Serial Port. If anybody has any constructive help I would be very very grateful! Still just a stupid beginner...

Thanks in Advance

Jonathan

Please edit your post and insert code tags!

Both SoftwareSerial and HardwareSerial classes have their interal buffers so you definitely don't need to add more buffers.

So your sketch can be written much shorter:

#include <SoftwareSerial.h>

SoftwareSerial O2_serial(10, 11);

void setup() {
  Serial.begin(9600);
  O2_serial.begin(9600);
}

void loop() {
  while (Serial.available()) {
    O2_serial.write(Serial.read());
  }
  while (O2_serial.available()) {
    Serail.write(O2_serial.read());
  }
}

Rs232 operates at different voltage levels to the Mega serial port - do you have level shifting components or an rs232 adapter lead ?

Hi Pylon and Hammi,

first of all thanks for your reply and the effort! It's actually kind of a shitty situation since I could really benefit from the Sensor, I'm building up a mushroom farm and without the CO2 sensor it's kind of difficult to know if I get the right amount of Air exchange. Other CO2 sensors which operate at 99% relative Humidity I can't afford at the moment. So it would be really nice to get some help, I'd even pay a couple of $ if necessary. (Got also some sleeping place near Berlin, if anybody wants to ever visit Germany :wink:

I removed the code since I couldn't figure out how to add the marks and nevertheless it seems to be crap! Sorry not yet much experience in the field of coding.

The short Sketch you(Pylon) created was tried and didn't give out anything. Only the board mounted RX LED flashed when I typed smth in the serial Monitor prompt.

I'm wondering about the different Volt of rs232 to the serial comm pins of my mega, since the former owner of this sensor could do it with his mega and direct patch cables without any converter etc.

I'm adding the Manual of the sensor and hope it helps!

Greetings

Jonathan

Manual

vaisala-gmt220-userguide-english.pdf (724 KB)

vaisala-gmt220-userguide-english.pdf (724 KB)

Your manual never says the communication is RS-232. It does say an adapter is necessary to connect to a PC, which leads one to believe the device uses TTL levels. You can easily verify by powering the device and measuring the TX voltage to ground.

Paul

since the previous Owner already successfully used the sensor with an Arduino I don't think voltage is the problem, I need a simple code which let's me Send a command to the device and receive the answer.

For 200$ it's possible to buy a data cable and use windows hyper terminal to send commands via prompt. So there must be a way to send a simple Command like "DISP 2" and receive the answer of for example "1100"

Try this one

change these

  mySerial.begin(4800);
  mySerial.println("Hello, world?");

to these

  mySerial.begin(9600);
  mySerial.print("MF");
  mySerial.print(0x0D);

Reading manual seems that every command should be followed by only return and not line feed (0x0A)

Pins used by softserial are 10 and 11, if you want to change them you have to change this line

SoftwareSerial mySerial(10, 11); // RX, TX

Thys way the Arduino will be a sort of USB-serial adapter so you can send commands using the serial monitor, where in the botton, near baud, you have to choose to send only CR.

Remember to connect Tx of the sensor to (SoftwareSerial's) Rx of the Arduino and the other way around. After all what the sensor transmits (Tx) the Arduino has to receive (Rx).

The attached pictures show a Mega2560 clone and not an UNO! Is that your setup or the setup of the former owner?

Using SoftwareSerial on a Mega2560 doesn't make sense, the board has 4 hardware serial interfaces.