nRF24L01: data sending problems

Recently i´ve been working with these RF modules, with the codes for transmitter and reciever that i´m using works, but i have to reset the arduinos to see one value on the reciever, i changed many things on the codes, but nothing really seems to work. I´ll put the codes down here for you.

// TRANMITTER CODE
#include <SPI.h>
#include <Wire.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
#define module (0x53)

struct Data {
byte values[6];
int registerXyz = 0x32;
int x, y, z;
}
data;

void setup(){
Serial.begin(9600);
Wire.begin();
Wire.beginTransmission(module);
Wire.write(0x2D);
Wire.write(0);
Wire.endTransmission();
Wire.beginTransmission(module);
Wire.write(0x2D);
Wire.write(16);
Wire.endTransmission();
Wire.beginTransmission(module);
Wire.write(0x2D);
Wire.write(8);
Wire.endTransmission();
Mirf.cePin = 7;
Mirf.csnPin = 8;
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.setRADDR((byte *)“server”);
Mirf.payload = sizeof(data);
Mirf.channel = 10;
Mirf.config();
}

void loop() {
Wire.beginTransmission(module);
Wire.write(datos.registroXyz);
Wire.endTransmission();
Wire.beginTransmission(module);
Wire.requestFrom(modulo, 6);
int i =0;
while(Wire.available()) {
data.values =Wire.read();

  • i++;*
  • }*
  • Wire.endTransmission();*
  • data.x = (((int)data.values[1]) << 8) | data.values[0];*
  • data.y = (((int)data.values[3]) << 8) | data.values[2];*
  • data.z = (((int)data.values[5]) << 8) | data.values[4];*
  • delay(300);*
  • if(!Mirf.isSending() ) {*
    _ Mirf.setTADDR((byte *) “client”);_
    _ Mirf.send((byte *) &data);_
  • }*
    }
    ///RECIEVER CODE
    #include <SPI.h>
    #include <Mirf.h>
    #include <nRF24L01.h>
    #include <MirfHardwareSpiDriver.h>
    int blue = 4;
    const int green = 3;
    const int red = 2;
    struct Data {
  • byte values[6];*
  • int registerXyz = 0x32;*
  • int x, y , z;*
    }
    data;
    void setup() {
  • Serial.begin(9600);*
  • Mirf.cePin = 7; *
  • Mirf.csnPin = 8; *
  • Mirf.spi = &MirfHardwareSpi; *
  • Mirf.init(); *
    _ Mirf.setRADDR((byte *)“client”);_
  • Mirf.payload = sizeof(data);*
  • Mirf.channel = 10;*
  • Mirf.config(); *
  • pinMode(red, OUTPUT); *
  • pinMode(green, OUTPUT);*
  • pinMode(blue, OUTPUT);*
    }
    void loop() {
  • if (!Mirf.isSending() && Mirf.dataReady() ) {*
    _ Mirf.getData((byte *) &data);_
  • char out[512];*
  • sprintf(out, “%d %d %d”, data.x, data.y, data.z);*
  • Serial.println(out);*
  • delay(10);*
  • }*
  • if (data.x >= 50 || data.x <= -50) {*
  • digitalWrite(red, HIGH);*
  • } else {*
  • digitalWrite(red, LOW);*
  • }*
  • if (data.y >= 50 || data.y <= -50) {*
  • digitalWrite(blue, HIGH);*
  • } else {*
  • digitalWrite(blue, LOW);*
  • }*
  • if (data.z >= 218) {*
  • digitalWrite(green, HIGH);*
  • } else {*
  • digitalWrite(green, LOW);*
  • }*
    }
    Another thing to mention is that a few months ago i worked with the same code and modules, but i can´t understand why this is happening now

It's all the fault of those little guys with dark glasses. Use the code button when posting code.

Have a look at this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

...R

PS ... When posting code please use the code button </>
codeButton.png

so your code 
looks like this

and is easy to copy to a text editor See How to use the Forum

Also please use the AutoFormat tool to indent your code for easier reading.