You should study how the sprinft works, and perhaps start with a few simple examples.
When you use a 4-byte parameter, you have to specify in the format string that a 4-byte parameter is used. For example with "%03lX". The 'X' is for a 2-byte parameter, the extra 'l' makes it 4-byte.
When you specify in the format that a 2-byte parameter is used, you have to give the sprintf a 2-byte parameter, not a single byte parameter.
This works:
unsigned char rxBuf[8]= { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x11, 0x22 };
unsigned long rxId = 0x103;
char ReceString[32];
void setup()
{
Serial.begin( 9600);
}
void loop()
{
sprintf(ReceString, "%03lX %02X%02X%02X%02X%02X%02X%02X%02XX",
rxId,
(unsigned int) rxBuf[0],
(unsigned int) rxBuf[1],
(unsigned int) rxBuf[2],
(unsigned int) rxBuf[3],
(unsigned int) rxBuf[4],
(unsigned int) rxBuf[5],
(unsigned int) rxBuf[6],
(unsigned int) rxBuf[7]);
ReceString[3]=7+'0';
Serial.println(ReceString);
Serial.println(rxBuf[0]);
delay(1000);
}
You could add the '7' at position 3 in the format string. There is no need to do that afterwards.
Tinkercad:
