Hi, I’m trying to communicate with a CurrentCost EnviR to get the message it sends every 6 seconds through the serial at 57600 baud but I only receive strange characters.
Trying to figure what was going on I connected pin 0 (Hardware Serial Rx) to pin 2 and set that pin as Software serial Rx. Then I send to the Hardware Serial whatever I receive through SoftwareSerial (which is exactly the same that I send through the Hardware Serial). This way I can monitor what is going on.
It works great for 4800, 9600, 14400 and 19200 baud but after that I only get garbage.
My guess is that the timings for the 57600 are wrong in the library.
The CurrentCost serial communication specs are here: Current Cost CC128 Display Unit
My sketch is this one:
#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 300
#define ledPin 5
SoftwareSerial currentcost(rxPin, txPin);
void setup()
{
Serial.begin(57600);
Serial.println("Arduino here!");
// set the data rate for the SoftwareSerial port
pinMode(rxPin, INPUT);
currentcost.begin(57600);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (currentcost.available()) {
Serial.print((char)currentcost.read());
//digitalWrite(ledPin, HIGH);
}
else {
//digitalWrite(ledPin, LOW);
//Serial.println();
}
}
Does anyone know how can I get this to work?
Thanks a lot!