Serial data output incorrect language?

I am trying to read the XML data from a current cost CC128.

I have used the supplied SoftwareSerial example to read the raw data on my Arduino Pro Mini.

This example code is in the public domain.

*/
#include <SoftwareSerial.h>

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

void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

Serial.println(“CC128 Test!”);

// set the data rate for the SoftwareSerial port
mySerial.begin(57600);

}

void loop() // run over and over
{
if (mySerial.available())
Serial.write(mySerial.read());
if (Serial.available())
mySerial.write(Serial.read());
}

The data returned looks like this…

<íóç><óòã>ÃÃ128-ö1.24</óòã><äóâ>00990</äóâ><ôéíå>09:25:14</ôéíå><ôíðò>22.5</ôíðò><óeîóïò>0</óåîóïò><éä>00705</éä><ôùðå>1</ôùðå><ãè1><÷áôôó>00214</÷áôôó></ãè1></íóç>

It should look something like this…

CC128-v1.180143400:43:0518.700227610000000746

So I am getting the decimal numbers, its just the characters that are gibberish.

Can anyone help me with this? I’m sure it will be a quick fix.
I have tried all different baud rates to no avail. The CC128 spec is for 57600 baud.

I`m not sure if this is a translation issue with the SoftwareSerial lib I am using however I can not find any other mentions of this sort of issue.

Cheers,

Ben

P6Mole: Can anyone help me with this? I'm sure it will be a quick fix.

Throw away SoftwareSerial and use AltSoftSerial instead!

Though you cannot freely decide about the pins (AltSoftSerial pins depend on the board you use), the AltSoftSerial library is much better than SoftwareSerial. Especially when using a hardware serial at the same time.

SoftwareSerial which is provided with the Arduino IDE is the worst library that is provided with the Arduino software.

Thanks for the tip however I am still none the wiser, if not worse.

This is what I get…

<ÚÍ�ùþ<æÉ�ù
Š’Âjd(r$ˆ iÉ�ùþ<È͉ù‚‚ÊÊ‚âzD͉ùþ<襵•ùŠŠÒšŠÒ¢²âzD(V¬Yþ<èµÁÉù’Šr$ˆzD¨ Éùþ<æeÜͽÉù‚âz4¨–k½Éùþ<Ò‘ù‚‚º‚ªâzJDùÆ¢åÁ•ùŠâzD(•ùâ„+òþ<î…ÑÑÍù‚‚’ª¢âzt(ÑÑÍùâz4¡ÅòâzÔk�ùj

Cheers,

Ben

What do you see if you read the serial data from the device using a terminal emulator ?

Please show a complete circuit diagram of all connections you made to your Arduino!

Would it be possible that you try to connect a RS232 COM-port (voltage level -12V...+12V) directly to the Arduino SoftwareSerial/AltSoftSerial serial pin (Arduino voltage level: 0V...5V)?

If your device has a RS232 COM-port output, you'd need a "RS232-TTL serial adapter" to connect that device to your Arduino.

Have you checked number of bits, parity etc?

I have the earth to earth and the Tx from the CC128 to my pin 8 for AlsSoftwareSerial or Pin 3 for SoftwareSerial.

It is a 3V serial interface according to the currentcost website and other digging that I have done.

Current Cost CC128, The CC128 rj45 pinout is like this, i.e. 1 = +v Unregulated (Same as the PSU input) 2 = PIC chip pin 52 (PGC) 3 = +V Regulated 4 = GND 5 = PIC chip pin 47 (PGD) 6 = PIC chip pin 9 (Program Voltage (nMCLR)) 7 = Unit RX 8 = Unit TX

I dont know where to check the parity bits etc. Other people have achieved this without any issues like these hence why I am confused. The mere fact that I am getting the temp, energy usage and time from the data shows that it is receiving it all ok...

Sorted it.

The Serial Baud rate for the cc128 is not 57,600 as advertised it is actually 57,000. Now I am getting the correct data for me to play with.

http://web.archive.org/web/20100724220142/http://e.inste.in/2008/06/16/interfacing-the-currentcost-meter-to-an-arduino/

Right at the bottom there is a discussion about the baud rates been 50 out. So trial and error and it now works.

Cheers all.

Ben

Serial.println("CC128 Test!");

Does this line in your code work correctly ?

Um... Yea. I think.