Im attempting to send a byte array to a grundfos serial sensor, but before I can do that I encountered a problem.
Whenever I use Serial1.write( any value ) it will be returned read on Serial1.read() instantly afterwards.
The error occurs even when there are just wires connected to TX/RX on the photon, and nothing at the other end of the wires. My code is the following:
int counter = 0;
void setup() {
Serial.begin(9600);
// Used to check if host has serial port (virtual COM port) open.
while(!Serial.isConnected()) {
Particle.process();
}
Serial1.begin(9600, SERIAL_8N1);
}
void loop() {
counter = counter + 1;
if (counter % 10 == 0) {
unsigned char telegram[5] = {
0x72, 0x05, 0xEE, 0x03, 0x68
};
Serial.println("Sending...");
// Serial1.write(telegram, 5);
Serial1.write(42);
}
delay(1000);
}
void serialEvent1() {
while (Serial1.available() > 0) {
int inByte = Serial1.read();
Serial.printlnf("Read %X", inByte);
}
}
Console output: