Strange characters at end of NRF24L01+ transmission

Hello,

I'm working on a little module that uses NRF24L01+ to communicate and trigger actions. It's using TMRH20's NRF24Network library, and sends a message of a single char. This triggers an action on the receiving module, which after completing the action responds (again with a single char) to act as a "confirmation."

I was experimenting with it last night using an Arduino and serial monitor to send the char and view the response.

For those wondering, I'm using the same baud rate for the serial monitor as in my code. It seems to be working correctly, correctly triggers the action, and even correctly receives the appropriate response message ("k" for "okay," "a" for "that's already done," "e" for "error / bad input").

The only strange thing is that there is an odd question mark symbol and a Q attached at the end of each received confirmation message, so for example:

Trying to send code: b
Received code: k �Q
Trying to send code: t
Received code: k �Q
Trying to send code: w
Received code: e �Q

Does anybody know what this might be about? Again, it's not an actual ? but a little symbol of one, I'll try to attach a screenshot later today.

EDIT: Updated with actual symbol.

This is the ? symbol: �

I had wondered if it has to do with Serial.read() only taking in 1 byte, but since a char is only 1 byte, perhaps this isn't the issue.

Does anybody know what this might be about?

Sure. It's about a problem with your code, which you didn't post.

Sorry, was posting from somewhere without SSH access to the server hosting the code.

Code on the module:

#define LED_PIN 3
#define ACTION_PIN 2

#include <SPI.h>
#include <RF24Network.h>
#include <RF24.h>

RF24 radio(7,8);
RF24Network network(radio);

const uint16_t base = 00;
const uint16_t destination = 01;

// Toggle the Relay
void runAction() {
  digitalWrite(ACTION_PIN, HIGH);
  delay(100);
  digitalWrite(ACTION_PIN, LOW);
  delay(100);
}

// Blink the LED
void blink(int sleep) {
    digitalWrite(LED_PIN, HIGH);
    delay(sleep);
    digitalWrite(LED_PIN, LOW);
    delay(sleep);
}

void sendResponse(char response) {
    RF24NetworkHeader header(base);
    network.write(header, &response, sizeof(response));
}

void setup() {                
    pinMode(LED_PIN, OUTPUT);
    pinMode(ACTION_PIN, OUTPUT);

    radio.begin();
    radio.setPALevel(RF24_PA_MAX);
    radio.setAutoAck(1);

    network.begin(76, destination);
    radio.setDataRate(RF24_250KBPS);
}


void loop() {
    network.update();
    while ( network.available() ){
        RF24NetworkHeader header;
        char message;
        network.read(header, &message, sizeof(char));

        switch (message) {
           // "Trigger" the action
            case 't':
                runAction();
                sendResponse('k');
                break;

            // "Blink" the LED
            case 'b':
                blink(250);
                sendResponse('k');
                break;

            default:
                // "Error" / invalid 
                sendResponse('e');
        }
    }
}

Code triggering the module:

#include <SPI.h>
#include <RF24.h>
#include <RF24Network.h>

RF24 radio(7,8);
RF24Network network(radio);

const uint16_t base = 00;
const uint16_t destination = 01;

void setup() {
  Serial.begin(57600);

  radio.begin();
  radio.setAutoAck(1);
  radio.setPALevel(RF24_PA_MAX);
  
  network.begin(76, base);     
  radio.setDataRate(RF24_250KBPS);
}

void loop() {  
  network.update();

  while ( network.available() ){
    char message;
    RF24NetworkHeader header;
    network.read(header, &message, sizeof(char));
    Serial.print("Received code: ");
    Serial.println(message);
  }

  if (Serial.available()) {
    char command = Serial.read();
    RF24NetworkHeader header(destination);
    bool ok = network.write(header,&command,sizeof(char));
    if (ok) {
      Serial.print("Trying to send code: ");
      Serial.println(command);
    } else {
      Serial.println("Didn't work.");
    }
  }  
}
        char message;
        network.read(header, &message, sizeof(char));

Why are you reading the message one character at a time?

Why are you sending data one character at a time?

The code you posted does not match the serial output you claim to get.

PaulS:
Why are you reading the message one character at a time?
Why are you sending data one character at a time?

It's not really sending "the message one character at a time" -- the single character is the message, as stated at the very beginning of the post. It just has to trigger an action, why not use a char?

PaulS:
The code you posted does not match the serial output you claim to get.

Correct, hence the post.

Correct, hence the post.

Why would you post code that does not generate the output that you showed? You are wasting our time.

PaulS:
Why would you post code that does not generate the output that you showed? You are wasting our time.

I don't follow. You seem to be trying pretty hard to give curt, unhelpful responses, which seems to be wasting my time as well. Perhaps you could explain what you mean, or feel free not to respond further if you feel that your time is being wasted.

Running this code currently, I'm getting identical output except for the characters in question (�Q). The presence of those characters was the exact reason for the post.

Trying to send code: b
Received code: k
Trying to send code: t
Received code: k
Trying to send code: w
Received code: e

I thought that some of that data was being printed by the receiver. I see now that that is not the case. I apologize for jumping to conclusions.

    char message;
    RF24NetworkHeader header;
    network.read(header, &message, sizeof(char));

Try making message an array, with 2 elements. Replace the sizeof(char) with 1. What does that do?

No worries. As luck would have it, after it being so consistent a few evenings ago, I'm unable to replicate the issue today, so I think I'll just cross my fingers and blame it on either a faulty connection or poor network conditions that evening. If the unusual characters return I'll try your suggestion and update the thread.

Just for clarification, and in case it comes back, you were suggesting that I try something like:

char message[2];
RF24NetworkHeader header;
network.read(header, &message, sizeof(1));

Is that what you meant?

Sorry for the false alarm, and thanks for your input.