Control power meter with Arduino (RS232 port)

Hi everyone. Sorry that I have to repost my project but I have some new questions to ask relating to it.
My project is about finding a way for an Arduino Uno to communicate and interface with a

Bird RF 4421 Power Meter.

In short, I need to obtain power reading measurements from the power meter through Arduino. Note that I do not need to control the power meter in any way, just have to get the power readings.

So far my progress is this. The port at the back should be connected to a 25 to 9 pin converter. Then another converter (picture below)is used before connecting to the Arduino.

So what I assume now is that the Arduino will be receiving a 0-5V input that represents the data sent by the power meter and the Arduino will also be able to somehow control the power meter through another wire? (through either the blue or green wires in the picture).

On the programming side, what I've figured is that I have to put the commands in a string. For example: "PNFCFDT3TRG". This string sets up the 4421 to send no prefixes, read forward dBm, make one reading on "TRG", and triggers a measurement. But in Arduino, I have to convert these letters into HEX like this following command:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11);
byte GetData[] = {0x02,0x46,0x46,0x48,0x44,0x34,0x04};
mySerial.write(GetData);

So GetData will have the instructions and will be sent to the power meter once Serial.write is performed.

Am I on the right track so far? Really need some help on the specific wiring of the pins and also the Arduino coding. Some brief examples of the coding would greatly help!!

Any help is really appreciated. Hope my post does not seem trivial or dumb :slight_smile:

Here is the official link to the Bird RF 4421 Power Meter: 404

Don't use that converter in the picture. Choose one that has a MAX232 chip in it.

MorganS:
Don't use that converter in the picture. Choose one that has a MAX232 chip in it.

Thank you for your quick reply sir. Is this the one you recommend?

http://www.emartee.com/product/41885/#

Your converter needs to be connected to pins 10 and 11 as that is what you specify with SoftwareSerial mySerial(10, 11);

Do not change that to the HW serial pins (0 and 1), just wire the device differently.

Your hex code 0x46,0x46,0x48,0x44,0x34 does not reflect the message "PNFCFDT3TRG". It will also be quite a mission to create multiple the messages that way.

You can use something like

// message buffer that is large enough to hold longest message plus STX and EOT
char msg[32];
// clear the buffer
memset(msg, 0, sizeof(msg));
// message starts with STX
msg[0] = 0x02;
// add command after STX
strcpy(&msg[1], "PNFCFDT3TRG");
// add EOT at end
msg[strlen("PNFCFDT3TRG") +1] = 0x04;
// send
Serial.write(msg, strlen("PNFCFDT3TRG") +2);

daniellau5551:
Note that I do not need to control the power meter in any way,

That's not what your title says !

...R

If you are using softwareSerial, which as far as I understand from the rather poor documentation available, it is limited to 8-N-1 ( 8 databits, No parity, one stop bit). That means you may have to change the default settings via dip switches on your device to match, the instructions for which state that 2 stop bits is the default setting.

sterretje:
Your converter needs to be connected to pins 10 and 11 as that is what you specify with SoftwareSerial mySerial(10, 11);

Do not change that to the HW serial pins (0 and 1), just wire the device differently.

Your hex code 0x46,0x46,0x48,0x44,0x34 does not reflect the message "PNFCFDT3TRG". It will also be quite a mission to create multiple the messages that way.

You can use something like

// message buffer that is large enough to hold longest message plus STX and EOT

char msg[32];
// clear the buffer
memset(msg, 0, sizeof(msg));
// message starts with STX
msg[0] = 0x02;
// add command after STX
strcpy(&msg[1], "PNFCFDT3TRG");
// add EOT at end
msg[strlen("PNFCFDT3TRG") +1] = 0x04;
// send
Serial.write(msg, strlen("PNFCFDT3TRG") +2);

sorry the coding was just an example and it didn't represent "PNFCFDT3TRG" in any way.
I apologise for my error.
So by using your example program, I can request the power meter to send readings right?

Add this:

mySerial.write(GetData);

Then I should be able to read the values afterwards?

I'm just a beginner sorry if I don't really understand your explanation.

Robin2:
That's not what your title says !

...R

Now I think about it, you are totally right. :slight_smile: Sorry for the error

daniellau5551:
sorry the coding was just an example and it didn't represent "PNFCFDT3TRG" in any way.
I apologise for my error.
So by using your example program, I can request the power meter to send readings right?

Add this:

mySerial.write(GetData);

Then I should be able to read the values afterwards?

I'm just a beginner sorry if I don't really understand your explanation.

OOPS, the last line in my code should have been mySerial.write(msg, strlen("PNFCFDT3TRG") +2);. There is no GetData in my code :wink:

And after that you should indeed be able to read the data from the device; note the comment by 6v6gt though (I did not look up the specs of the power meter).

daniellau5551:
Now I think about it, you are totally right. :slight_smile: Sorry for the error

If you edit your Original Post you can change the title.

...R