This might be simple but i can’t seem to figure out how to send a 3 or 4 digit number between to NRF’s. I can send unsigned characters just fine but I can’t seem to send integers. Is this a problem with SPI?
Uhm… NRF’s just chuck bytes back and forth. They don’t care whether they map to a valid ascii character or not.
An unsigned int is typically just 4 bytes representing that value. Break it down into the constituent bytes, and send individually.
For example:
unsigned char m[4]; // message of length 4 bytes
m[0] = value >> 24; // No need for & 0xFF masking, will be clamped by type conversion
m[1] = value >> 16;
m[2] = value >> 8;
m[3] = value;
send_message(m)
To reconstitute on the other end:
unsigned int value = 0xCAFEBABE;
unsigned char m[4]; // message of length 4 bytes
recv_message(m)
value = ((unsigned int)m[0] << 24) | ((unsigned int)m[1] << 16) | ((unsigned int)m[2] <<8) | m[3];
value == 0xCAFEBABE
Note, I haven’t tested this specific code, so typos may be present.
Also note that a full 4 byte unsigned integer will represent the range from 0 to 4294967295, which may be unnecessary in your application. If you don’t need that range, and message size is a concern, just send 8, or 16 bit integers, for ranges of 0-255, or 0-65535.
I will have to give a try tonight and see what happens.