Hi all,
So I am using the RFM69 library and simply trying to (first) send a byte (numbers 0 through 5) from one radio to another. On the receiver I want to receive the byte, put it in a variable so I can decide what to do with it.
Once I have that, I want to send a byte array. The first byte is the same as above, a single number 0 through 5. The second byte is a number from 0 to 20 and on the receiving end I want to put it in a variable and use it to choose how long I "delay" to keep an LED on.
In the past I've converted the single byte to a char and sent that through the radio and then on the receiving end converted the single char back to an int by subtracting '0'. However, I was told that the RFM69 library sends the packets as bytes so it doesn't really make sense to go back and forth between chars and strings when I just want to send bytes in the first place.
So I tried just sending a single byte first, my sending code looks like the following. I removed all of the radio initialization code and more just to keep things simple and short to read:
byte message = 0; //this is the outgoing byte to send to the receiver
//send it
message = 1; //change the message to '1' to command the LED to turn on
radio.sendWithRetry(TONODEID, message, 1);
and then on the receiving end if I do this:
byte remote = 0;
remote = radio.DATA[0]; //the incoming remote command set to variable remote
Serial.print("remote variable sent: ");
Serial.println(remote);
//then I can check if the remote variable == 1 then do something etc
So you would expect, "remote variable sent: 1"
However, this results in the following being printed to the serial monitor--> "remote variable sent: 0"
If I change the message variable to '2' and I send that, I get: "remote variable sent: 109"
I'm confused! Any help would be greatly appreciated!
Thank you