nRF24L01 sending data buging

Hello, I am working on my graduation work, and I’m making a car controlled with an GY-80 BMP085 Digital Accelerometer. The data is transmitted from a joystick to the car via nRF2401 device. When I transmitt 2 value of 3 axis Accelerometer, everything is working fine, but when I want to transmitt a third value ( temperature from a GY-80 BMP085), my code starts buging.
I checked this bug with Serial Monitor (Serial.print() function) and it shows this: first 300 ms is normal, then for a second 200 - 300 ms it stops working, then again it the same…
Here is my code for transmitter:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#include <ADXL345.h>
#include <Adafruit_BMP085.h>
/-----( Declare Constants and Pin Numbers )-----/
#define CE_PIN 9
#define CSN_PIN 10

ADXL345 adxl;
Adafruit_BMP085 bmp;

// NOTE: the “LL” at the end of the constant is “LongLong” type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe

/-----( Declare objects )-----/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/-----( Declare Variables )-----/
int joystick[3]; //
void setup() /****** SETUP: RUNS ONCE ******/
{
Serial.begin(9600);
radio.begin();
adxl.powerOn();
if (!bmp.begin()) {
Serial.println(“Could not find a valid BMP085 sensor, check wiring!”);
while (1) {}
}
radio.openWritingPipe(pipe);
delay(200);
}//–(end setup )—

void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
int x,y,z,t;
int throttle, steer, cooler;
adxl.readAccel(&x, &y, &z);
t=bmp.readTemperature();
x=x+130;
y=y-42;
steer = map(x, -250, 250, 47, 118);
throttle = map(y, -230, 230, -255, 255);
steer = constrain (steer, 47, 118);
throttle = constrain (throttle, -255, 255);
if (steer < 86 && steer > 78) {
steer = 82;
}
if (throttle < 30 && throttle > -30) {
throttle = 0;
}
if (t >= 30) {
cooler = 255;
}
else if (t < 25) {
cooler = 0;
}
else {
cooler = 100;
}
joystick[0] = steer;
joystick[1] = throttle;
joystick[2] = cooler;
radio.write( joystick, sizeof(joystick) );
Serial.print("ugao: ");
Serial.print(steer);
Serial.print("gas: ");
Serial.print(throttle);
Serial.print("klima: ");
Serial.println(cooler);
}//–(end main loop )—

On a serial monitor it shows:

Ugao:56 gas: 233 klima 100
Ugao:56 gas: 233 klima 100
Ugao:56 gas: 233 klima 100
Ugao:54 gas: 133 klima 100

and then stops for a moment (about half a sec)

Ugao:56 gas: 233 klima 100
Ugao:56 gas: 233 klima 100
Ugao:56 gas: 233 klima 100
Ugao:56 gas: 233 klima 100

My guess is that bmp and nRF are bothering each other…
Hope you’ll solve my problem.
Thanks.

And than over and over again, which couse in my receiver bugs.. A forgot to say than I'm using arduino uno for joystick, and arduino uno for controlling the car..

The code it is looks ok, but this is only the Tx side, maybe the problem it is on Rx side so it is good to post and the Rx code.

I will ask you also to try to change the code

radio.write( joystick, sizeof(joystick) );

to the bellow

radio.write(& joystick, sizeof(joystick) );

The same on the receiver e.g.

radio.read(&joystick,radio.getDynamicPayloadSize());

And tell us if that help ;)

Thanks, but wasn’t helpful… It seems that there is some synhro problem with transmitter and receiver.

When I UPLOAD this code to transmitter and receiver there is no problem…

Transmitter:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#include <ADXL345.h>
/-----( Declare Constants and Pin Numbers )-----/
#define CE_PIN 9
#define CSN_PIN 10

ADXL345 adxl;

// NOTE: the “LL” at the end of the constant is “LongLong” type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe

/-----( Declare objects )-----/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/-----( Declare Variables )-----/
int joystick[2]; // 2 element array holding Joystick readings

void setup() /****** SETUP: RUNS ONCE ******/
{
Serial.begin(9600);
radio.begin();
adxl.powerOn();
radio.openWritingPipe(pipe);
}//–(end setup )—

void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
int x,y,z;
adxl.readAccel(&x, &y, &z);
x=x+130;
y=y-42;
joystick[0]=x;
joystick[1]=y;
radio.write( joystick, sizeof(joystick) );

}//–(end main loop )—

/-----( Declare User-written Functions )-----/

//NONE
//( THE END )**

And Receiver:

-----( Import needed libraries )-----/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>
/-----( Declare Constants and Pin Numbers )-----/
#define CE_PIN 9
#define CSN_PIN 10

// NOTE: the “LL” at the end of the constant is “LongLong” type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe

/-----( Declare objects )-----/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/-----( Declare Variables )-----/
int joystick[2]; // 2 element array holding Joystick readings
Servo steer;

int ENA = 5;
int IN1 = 6;
int IN2 = 7;

void setup() /****** SETUP: RUNS ONCE ******/
{
Serial.begin(9600);
delay(1000);
Serial.println(“Nrf24L01 Receiver Starting”);
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
steer.attach(8);

pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(ENA, LOW);

}//–(end setup )—

void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
delay(50);
if ( radio.available() )
{
// Read the data payload until we’ve received everything
bool done = false;
while (!done)
{
// Fetch the data payload
done = radio.read( joystick, sizeof(joystick) );
int a,b;
a = map(joystick[0], -200, 200, 47, 118);
b = map(joystick[1], -200, 200, -255, 255);
a = constrain(a, 47, 118);
b = constrain(b, -255, 255);
if ( a > 77 && a < 87 ) {
a = 82;
}
if ( b > -30 && b < 30 ) {
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
b = 0;
}
else if ( b >= 30 ) {
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
}
else {
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
b = abs (b);
}

Serial.print("X = “);
Serial.print(a);
Serial.print(” Y = ");
Serial.println(b);

steer.write(a);
analogWrite(ENA, b);

}
}
else
{
Serial.println(“No radio available”);
}

}//–(end main loop )—

/-----( Declare User-written Functions )-----/

//NONE
//( THE END )**

BUT when I want to add a bmp temperature sensor, it seems that the transmitter has some problem to run normaly.

On Serial monitor I can see that the Serial.print() function has some delay… For example, when I add Serial.print() my value on transmitt side, it shows:

X: 123 Y: 23 Temp: 22
X: 123 Y: 23 Temp: 22
X: 123 Y: 23 Temp: 22

then some delay (about 300ms)

and than again value

X: 123 Y: 23 Temp: 22
X: 123 Y: 23 Temp: 22
X: 123 Y: 23 Temp: 22

then again delay…

There is no any delay in the code, and I wan to transmitt it smooth… It couses bug in my receiver side shown like:
“No radio available.”

Any help?