What I have:
Current Cost CC128 power meter Current Cost CC128 Display Unit
Arduino Mega 2560
Official Ethernet Sheild (new one which is compatible with the Mega) plugged in to Arduino
Windows Vista machine to load the Mega with code
What I am trying to achieve:
(Initially) get the Mega to read and understand the serial data coming from the CC128
(Eventually) get the Mega to publish this on the web (e.g. on Pachube)
What is happening now:
The Arduino is reading the data as rubbish corrupted characters.
Connections:
Current Cost pin 4 (GND) to Arduino ground. Current Cost pin 8 (TX) to Arduino pin 2. (CAT5 cable about 2m long).
Wall wort plugged in to Arduino
2m USB connecting Arduino/PC
Ethernet cable plugged in to Ethernet Shield
Here is the sketch I am using:
#include <SoftwareSerial.h>
// Set up the serial port
SoftwareSerial softSerial = SoftwareSerial(2, 300); // 300 is dummy TX pin (not needed)
void setup() {
pinMode(2, INPUT);
softSerial.begin(57600); // << This speed is changed for testing
Serial.begin(9600); // Hardware serial for diagnostic
}
void loop() {
// Listen for serial data coming in:
char someChar = softSerial.read();
Serial.print(someChar); // echo to hardware serial monitor
}
This is the output I am getting for each softSerial speed. In all cases the "data" is appearing every 6 seconds, it is being corrupted and there are lots of "ÿ" (y with umlaut) characters appearing too:
57600
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿN?îNd[.N3d(N?î?IbÓ2jNïKtÎåÁN?\hN;$ÿÅhÅÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÎ?fNd[]3dVYN?n%ÿbNÿºjÎçOtN?KÿRòÅN³DEªøÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿN?æNa?Nÿ¢eãNj?
¦NÿË+Nî?ÿNOyN<pNÏÿpE^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
9600:
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýÃÓÁ÷LãúÿãSñÏÃÉÒÒÔyWÏOñÁÂÒmR³æÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿýËÒÅ÷mãûÚãsñïãÉÓÓÖyw¿ÐÁßCMSß×ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
2400:
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ6?þkOÀÏðKòÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿïüø~_ÐÀú[öÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
If I change the code to use NewSoftSerial instead of SoftwareSerial (at all 3 speeds), I just get a load of "ÿ" characters with no "data" interspersed:
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
Interestingly, when I go back to using SoftwareSerial at 57600 and remove the wall wort (leaving the Arduino powered by the USB) I still get the "data" but I get far fewer "ÿ" characters:
ÿÿÿÿÎæÎd[]Nÿ%N?j¥IæNÿ¸îÎî?®?¼ÁNëTNpS¼Ç¯ÿÿÿNæ?l_]Nÿ?j?LjNÓ2jNë?ÿ?ãÁNã\NetH~yǾÿÿÎfN?ÿN;àeÆ?î?JæNÿLjNëËðÎÿÿÿXzhNpÌvq<ÿÿÿÿNÿ?Nl_]Nÿ%YNÿ%HbNÓºjNïKtNãÿÿøhNxHmóÇ<ÿÿÿÎæNh[]Nÿ%VYNÿ¥OjNÿ¸jÎëOtN?KÿZrÃNe°ÿmqǼÿÿÿÿÿÿÿÎfNe?Nÿ¢eçN?î?MbNÛÿjNn?ÇN<ÄNç\NxÖ[8Ïÿÿÿ
Similar effect at the other speeds.
And if I try the hardware port (Serial.read()) I just get a load of "ÿ" characters again, no data.
The Current Cost appears to be sending out data. I have cycled the power a few times. I have also hooked it up to Meniscus on the PC and received this from it:
<msg><src>CC128-v0.11</src><dsb>00641</dsb><time>05:46:29</time><tmpr>23.7</tmpr><sensor>0</sensor><id>00077</id><type>1</type><ch1><watts>00914</watts></ch1></msg>
I have searched the web but cannot find anyone who is doing this using a Mega.
There is a similar problem here on the read-only forum but with no solution:
http://arduino.cc/forum/index.php/topic,44879.0.html
Thank you for reading this far! I would love to hear anyone's ideas on what might be going on here. I am hoping I have made a simple (stupid) mistake....?!
I am now off to hit my head against a brick wall.
Thanks!