Help using the nRF24L01 module code using RF24 library TMRh20 version

Thread Starter

harshalsardesai3

Joined Dec 6, 2020
10
I found different similar codes doing the same thing but use different lines of code please could someone explain why is this?? i am new to Arduino so i am looking for an explanation on why this difference ??

One code used const byte address[] to fix the pipe/address & the other used const uint64_t what is the difference btween the two ??

https://forum.arduino.cc/index.php?topic=421081#https://forum.arduino.cc/index.php?topic=421081# link for the 1st code which uses const byte address


https://www.electroniclinic.com/nrf...4L01_Hello_World_Transmitter_Side_Programming link for 2nd code which uses const uint64_t
 

Wolframore

Joined Jan 21, 2019
2,609
I can’t access the libraries on the device I have currently but the addresses ensure that the correct information is received and can have unique identifiers. My guess would be that the easy nRF24 lib has it in the library where the second needs declare in code. Have you tried either one and have gotten them to work?
 

Thread Starter

harshalsardesai3

Joined Dec 6, 2020
10
I can’t access the libraries on the device I have currently but the addresses ensure that the correct information is received and can have unique identifiers. My guess would be that the easy nRF24 lib has it in the library where the second needs declare in code. Have you tried either one and have gotten them to work?
Yes i did try both of them and they work. i can use anyone of the lines & it has no issues. So the question still remains what is the difference between them ?
Codes i tried are
#include <SPI.h>

#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 8); // CE, CSN
const uint64_t pipe = 0xE8E8F0F0E1LL; // This is the only line i changed in the later one & still it works fine

void setup() {
radio.begin();
radio.openWritingPipe(pipe); // & instead of this variable the address was used in the later one
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
const char text[] = "Hello World" ;
radio.write(&text, sizeof(text));
delay(10);
}

& The other code


#include <SPI.h>

#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 8); // CE, CSN
const byte address[6] = "00001"; // This is the Only line that i changed yet it works fine

void setup() {
radio.begin();
radio.openWritingPipe(00001);// & instead of this Variable was used
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
}
void loop() {
const char text[] = "Hello World" ;
radio.write(&text, sizeof(text));
delay(10);
}
Help is appreciated
 

Wolframore

Joined Jan 21, 2019
2,609
Why worry about it the second one is taking care of it in the library. The library is a function that runs in your code when its included, it it how it understands what you want it to do so you don’t have to bit bang it.
 

Thread Starter

harshalsardesai3

Joined Dec 6, 2020
10
Help. I tried doing the Hello World example & there is some issue I added the capacitors checked every connection but somehow it takes around an hour of restarting & checking the connections for the modules to connect to each other & once they are connected they it's not a problem I can disconnect them for some time & again they work but everytime I keep them disconnected for over night I have to spend an hour sometimes 2 for them to work again this has haulted all my efforts as I have classes & work during the day & every night I wana work on this my work is left incomplete as most of time is gone only to start the connections please help
 

Thread Starter

harshalsardesai3

Joined Dec 6, 2020
10
It is a bare bone testing setup & the power supplies are 2 laptops for each Arduino. While testing laptops are around 2-3 meters apart
I have to make sure they are connected then I can disconnect them and use without the laptop. But untill then I have to spend hours wondering why they don't communicate. I haven't tried using a battery yet bcoz I just couldn't complete the hardware side of the project bcoz of the communication issue. I tried different channels max power level min power level bt no progress.
Thank You
 

Attachments

Wolframore

Joined Jan 21, 2019
2,609
that's what I thought, the rf modules need their own power supplies, try bypass capacitors between the power and ground closer to the radio modules not attached to long jumpers.
 

Thread Starter

harshalsardesai3

Joined Dec 6, 2020
10
Ok I will try putting the capacitor near the module & will it be better to supply the Arduino with battery of 9V will that give enough power to both the Arduino & the module ? I don't have a separate voltage regulator for 3.3V but I have power supplies of 5V that can output more power.
So will that work just give more power to Arduino not more than 10V 2amp as it can regulate it's own voltage,
max Voltage for the Arduino is 12V so I suppose it will be safe.
 

Thread Starter

harshalsardesai3

Joined Dec 6, 2020
10
Yup I have a power bank but its current output is less than my wall adapters. The adapters I have are rated at 5V each and have 1Amp 2Amp & 1.5Amp variations. Or I can use 9V or 12V lipo batteries.
Which one would be better ??
 

Wolframore

Joined Jan 21, 2019
2,609
Any of the above should be fine, you won't need 1 A. With just the radio and Arduino you're looking at less than 20-30 mA total... The 9V are just not great batteries for a number of reasons, they're weak and have poor capacity.
 
Top