RF24.read(char) reading garbage

Hello, I've been trying to send a char from one arduino to another using ManiacBug's RF24 library, but whenever the receiver reads the value it gets a few weird values, however, if I send the same value repeated times the receiver starts to get the correct value, for example, if I send 1 from time to time, the receiver sometimes reads 1, sometimes 68 and sometimes -17, everytime it outputs one of those values, I even ran the scanner to check for "empty" channels and switched to them, still the same behavior...
Well, here's the code:

const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
void setup(void)
	radio.setPayloadSize(RADIO_PAYLOAD_SZ); //8
	radio.setChannel(RADIO_CHANNEL); //currently set to 8
	radio.openWritingPipe(pipes[RADIO_PIPE_TO]);  //on the sender val = 1 and on receiver val = 0
	radio.openReadingPipe(1,pipes[RADIO_PIPE_FROM]); //on the sender val = 0 and on receiver val = 1

void loop(void)
	if (EVENT) {
		char c = 1;
		radio.write(&c,sizeof(char)); //this is supposed to be the command to send, which is being read incorrectly
		radio.write(&value, sizeof(unsigned long));
		radio.write(&len, sizeof(int));
		radio.write(&type, sizeof(int));
	} else {
		char c = 2;

short x = 0; //I tried to use a struct to receive all the values but it gets "corrupted" when reading as well
void loop(void)
	if ( radio.available() )
		if ( x == 0 ) {
			char c = 0;
			radio.read(&c, sizeof(char)); 
			printf("command %d\r\n", c);
			if ( c == 2 ) {
				x = 3;
			} else {
				if ( radio.read(&value, sizeof(unsigned long)) )
					x = 1;
		} else if ( x == 1 ) {
			if ( radio.read(&len, sizeof(int)) )
				x = 2;
		} else if ( x == 2 ) {
			if ( radio.read(&type, sizeof(int)) )
				x = 3;

		if ( x == 3 ) {
			x = 0;

Whenever I send "c" to the receiver it receives weird values, including but not only the value I sent, for instance, when I send 1, the receiver reads 1, -17 and 68, and when I send 2 it reads 2 and usually 68 as well.

On the receiver side I tried to use a struct to receive all values instead of using the flag "x" to indicate what's the hardware reading at the moment, but whenever I read the struct all values inside it would be garbage. The struct was something like:

typedef struct {
unsigned long Value;
int Len;
int Type;
} MyStruct;
MyStruct s;
radio.write(&s, sizeof(MyStruct));
radio.,read(&s, sizeof(MyStruct)); //garbage inside the struct

Does anyone have any idea what could it be...? I'm currently using a NRF24L01+, VCC on 3v3, CE is on 8, CSN 10, SCK 13, MISO 12 and MOSI 11 attached to an Arduino Nano.
Well, please let me know if I forgot to input any other important information, thanks everyone!

Hi, have you got some caps on the 3V3 rail, e.g. 10uF, preferably 100uF? Transmitting can make short spikes in demand for current. If these are not satisfied, the message may be garbled, or the range reduced.


Hey Paul, thanks a lot for taking your time, actually I don't have any capacitor connected to the 3v3 rail, gonna try that, thanks a lot!

No problems. Please edit your original post and put code tags (the # button) around your sketch.