I bought a wireless (433MHz) receiver and transmitter the other day to interact with remote controls I have to turn lamps on and off. I try to reverse engineer the signals being transmitted when a button is pressed. I get a predictable signal when I interpret the receiver's signal as a 4800 baud serial RX, and I try to mimic that signal. All seems ok up to here. However, I find it hard to transmit the same bytes. What I did first, was to read the signal from the receiver and print to to the serial monitor using this code:
int incomingByte = 0;
void setup() {
Serial.begin(4800);
}
void loop() {
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.println(incomingByte, HEX);
}
This gives me the hex for every byte received. I logged those, and try to send them using the transmitter using this code:
void setup() {
Serial.begin(4800);
}
void loop() {
...
Serial.write(0x84);
Serial.write(0x84);
Serial.write(0x84);
Serial.write(0xbc);
...
}
I now connect the TX to the serial monitor instead of the transmitter hardware, and compare that result with the original receiver's RX signal. They are not the same. I think it may be something silly like hex vs decimal or data type bit length or anything like that. Is there any reason to suspect that Serial.read and Serial.write are not totally symmetric, ie Serial.write(Serial.read) is not an exact copy? What else could be wrong?