Hi all,
I am trying to read ASCII data from my off-grid power system using the SoftwareSerial library. I am able to read data, but it seems to be well out of range from what I would expect.
Here is the sketch I'm working with.
#include <SoftwareSerial.h>
#define rxPin 3 //white pin2 on mate
#define txPin 2 //green pin3 on mate
#define dtrPin 4 //blue pin4 on mate
#define rtsPin 7 //orange pin7 on mate
// set up a new serial port
SoftwareSerial outback = SoftwareSerial(rxPin, txPin);
int value;
void setup() {
Serial.begin(19200);
// define pin modes for tx, rx:
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode(dtrPin, OUTPUT);
digitalWrite(dtrPin, HIGH);
pinMode(rtsPin, OUTPUT);
digitalWrite(rtsPin, LOW);
// set the data rate for the SoftwareSerial port
outback.begin(19200);
}
int i = 1;
void loop() {
if (outback.available()){
value = outback.read();
Serial.print("Byte ");
Serial.print(i);
Serial.print(": ");
Serial.print(value);
Serial.print(", ");
Serial.write(value);
Serial.println("");
i++;
}
}
Here is a sample of the output:
Byte 1: 189, ½
Byte 2: 179, ³
Byte 3: 218, Ú
Byte 4: 214, Ö
Byte 5: 118, v
Byte 6: 246, ö
Byte 7: 246, ö
Byte 8: 118, v
Byte 9: 246, ö
etc.....
I am connected to an Outback Mate (http://www.outbackpower.com/pdf/manuals/mate_guide.pdf). Based on the communication protocol, the first byte of transmission should be an ASCII code 10.
At first, I thought I might have a baud rate problem, but I don't think so anymore.
Any thoughts or suggestions?
Thanks, Bill