Hello everyone, i work on nRF24L01 and i have 3 ardunio with 3 nRF24L01 and 3 IMU as transmitter and 1 ardunio with 1 nRF24L01 as reciever, i am trying to recieve data from each transmitter and read angles simultinious, i written code like this at one transmitter :
network.update();
mpu6050.update();
float angleX = mpu6050.getAngleX();
RF24NetworkHeader header(master00);
bool ok = network.write(header, &angleX, sizeof(angleX));
Serial.print(angleX);Serial.print("\t");
and this one at reciever :
---------------------------------
const uint16_t this_node = 00;
const uint16_t node01 = 01;
const uint16_t node02 = 02;
const uint16_t node03 = 03;
--------------------------------------
network.update();
while (network.available()){
RF24NetworkHeader header;
if (header.from_node == 01){
network.read(header, &Kaci, sizeof(Kaci));
Serial.print("Kepçe Açısı=");Serial.print(Kaci);Serial.print("\t");
}
if( header.from_node == 02){
network.read(header, &Boomaci, sizeof(Boomaci));
Serial.print("Boom Açısı=");Serial.print(Boomaci);Serial.print("\t");
}
if( header.from_node == 03){
network.read(header, &Stickaci, sizeof(Stickaci);
Serial.print("StickAçısı=");Serial.print(Stickaci);Serial.print("\t");
}
it worked and recieved datas and i could print each angle from each reciever but sometimes reciever make mistakes and doesnt recieve datas from right transmitter for right header node.
Could you help somehow ? or do you have another solution ?
--------------------------------------------------codes----------------------------------------------------------
#include <SPI.h>
#include <RF24.h>
#include <RF24Network.h>
#include <nRF24L01.h>
#include <MPU6050_tockn.h>
#include <Wire.h>
MPU6050 mpu6050(Wire);
RF24 radio(9,10);
RF24Network network(radio);
const uint16_t this_node = 01;
const uint16_t master00 = 00;
void setup() {
SPI.begin();
Serial.begin(9600);
Wire.begin();
mpu6050.begin();
mpu6050.calcGyroOffsets(true);
radio.begin();
network.begin(90, this_node);
radio.setDataRate (RF24_2MBPS);
}
void loop() {
network.update();
mpu6050.update();
float angleX= mpu6050.getAngleX();
RF24NetworkHeader header;
bool ok = network.write(header, &angleX, sizeof(angleX));
Serial.print(angleX);Serial.print("\t");
}
--------------------------------------------------------------------------
#include <SPI.h>
#include <RF24.h>
#include <RF24Network.h>
#include <nRF24L01.h>
#include <MPU6050_tockn.h>
#include <Wire.h>
MPU6050 mpu6050(Wire);
RF24 radio(9,10);
RF24Network network(radio);
const uint16_t this_node = 02;
const uint16_t master00 = 00;
void setup() {
SPI.begin();
Serial.begin(9600);
Wire.begin();
mpu6050.begin();
mpu6050.calcGyroOffsets(true);
radio.begin();
network.begin(90, this_node);
radio.setDataRate (RF24_2MBPS);
}
void loop() {
network.update();
mpu6050.update();
float angleX = mpu6050.getAngleX();
RF24NetworkHeader header(master00);
bool ok = network.write(header, &angleX, sizeof(angleX));
Serial.print(angleX);Serial.print("\t");
}
-----------------------------------------------------------------------------------
#include <SPI.h>
#include <RF24Network.h>
#include <Sync.h>
#include <RF24.h>
#include <nRF24L01.h>
#include <Wire.h>
RF24 radio(9,10);
RF24Network network(radio);
const uint16_t this_node = 00;
const uint16_t node01 = 01;
const uint16_t node02 = 02;
float Kaci,Boomaci;
void setup() {
// put your setup code here, to run once:
SPI.begin();
Serial.begin(9600);
radio.begin();
network.begin(90, this_node);
radio.setDataRate (RF24_2MBPS);
}
void loop() {
// put your main code here, to run repeatedly:
network.update();
while (network.available()){
RF24NetworkHeader header;
if (header.from_node == 01){
network.read(header, &Kaci, sizeof(Kaci));
Serial.print("Kepçe Açısı=");Serial.print(Kaci);Serial.print("\t");
}
if( header.from_node == 02){
network.read(header, &Boomaci, sizeof(Boomaci));
Serial.print("Boom Açısı=");Serial.print(Boomaci);Serial.print("\t");
}
delay(100);
}
}