Notifications
Clear all

nrf2401+ changing channel, data rate and power level with RadioHead ReliableDatagram & NRF24 Libraries

Page 1 / 3

RCLawn
(@rclawn)
Eminent Member
Joined: 9 months ago
Posts: 47
Topic starter  

 

Has any one ever changed the channel, data rate and power level. It would probably be a piece of cake if I could find any examples to manipulate. I think I'm having wifi interference issues...I read there are 120 channels available for the nrf2401+ and wifi uses the lower ones.

// Initialize RadioManager with defaults - 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!RadioManager.init())

somewhere I found some commands that looked like they would do this but I didn't know how to implement. Now I can't even find that page. I thought it was on https://www.airspayce.com/mikem/arduino/RadioHead/  

Thank You

Please help,

Mike

Ps


Quote
RCLawn
(@rclawn)
Eminent Member
Joined: 9 months ago
Posts: 47
Topic starter  

no fair I wasn't done editing yet.... I thought it was on > https://www.airspayce.com/mikem/arduino/RadioHead/  

somewhere

If any one was looking for zero turn / tank / bobcat style control modifications based on Bill's

The nRF24L01 - Wireless Joystick for Arduino Robot Car with nRF24L01+ w/ extra buttons( mods spearheaded by Will) for lights and horn that part is working. It is configured for play station joysticks and

Ebay's Dual Motor Driver Module Board H-bridge DC MOSFET IRF3205 3-36V 15A Peak30A running some power wheels toy geared motors. It has officially made it down the incline and back (without help). I also have some custom drive couplings that can be 3d printed for a few different wheels if anyone is interested in pursuing power wheels powered stuff . That is all. I hope this is super easy for some one on here.

Please help me

Thanks in advance

Mike

 

 


ReplyQuote
Will
 Will
(@will)
Noble Member
Joined: 1 year ago
Posts: 1929
 

@rclawn 

I just Googled and this came up. Have you read it ?

https://arduino.stackexchange.com/questions/79452/nrf24l01-channel-switching

I was kidnapped by mimes.
They did unspeakable things to me.


ReplyQuote
RCLawn
(@rclawn)
Eminent Member
Joined: 9 months ago
Posts: 47
Topic starter  

Thank you Will.

I did now. I was thinking that the code needed to be for the radiohead library. I will try it. but there is alot of stuff that doesn't look right(compared to our sketch).

Like :

byte address[][6] = {"1Node", "2Node", "3Node", "4Node", "5Node", "6Node"};

or


  radio.openWritingPipe(address[0]); //we are pipe 0, we open a data channel

from stack exchange vs.

uint8_t len = sizeof(buf);
uint8_t from;

or

Serial.println((char*)buf);

I kinda wish the original sketch didn't use the #include <RHReliableDatagram.h> it seems obscure and hard to find stuff for. it was one the only sketches i found(at the time) that used the 2 wheel scheme. I think I'm going to try hacking up a non- #include <RHReliableDatagram.h> sketch and see if I can make it work (better) that way.

It was Bill's original sketches that brought me to this forum.

I do appreciate your help

any extra input is a plus

Mike


ReplyQuote
Will
 Will
(@will)
Noble Member
Joined: 1 year ago
Posts: 1929
 

@rclawn 

I'm apparently missing something fundamental (which is likely since I haven't used this hardware or software) but the radiohead library (specifically the RH_NRF24 class reference) specifies a function setChannel.

◆ setChannel()

bool RH_NRF24::setChannel ( uint8_t  channel )  

Sets the transmit and receive channel number. The frequency used is (2400 + channel) MHz

Returns
true on success

References spiWriteRegister().

Referenced by init().

 

Does this not accomplish your goal of changing channels ?

I was kidnapped by mimes.
They did unspeakable things to me.


ReplyQuote
RCLawn
(@rclawn)
Eminent Member
Joined: 9 months ago
Posts: 47
Topic starter  

so i just put "RH_NRF24::setChannel 124" and that sets it to channel 124?

in the current sketch there is a statement: "   // Initialize RadioManager with defaults - 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!RadioManager.init())
Serial.println("init failed");
}   "

 

now if i could put some numbers comma's or something in between those parenthesis it would be awesome i just know it has to be just so or it breaks it or does nothing. If only I could see an example of how it was done...

Thanks

Mike


ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 2755
 

@rclawn I am just using gut feel, experience in general as I am not very familiar with that device. I would first look at the header file for RadioManager, the variable names and/or comments may clue you in.

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
Will
 Will
(@will)
Noble Member
Joined: 1 year ago
Posts: 1929
 

@rclawn 

I don't know, as I said I haven't used the equipment.

But I would think it more likely that you'd be using the name of the variable you defined for the class. So, maybe something like ...

RH_NRF24    myObject(...);     // Create instance of radiohead class

...

myObject.setChannel(... your channel choice here...);    // hange channel

I was kidnapped by mimes.
They did unspeakable things to me.


ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 2755
 

@rclawn I am unsure what you mean by not have the include <RHReliableDatagram.h> . Do you not want to use the RadioHead library? Perhaps you are planning on writing on the metal using assembler? If so, it's great to have a programmer here with 20+ years experience as the NRF24 has been a problem area, perhaps you will be able to lay the groundwork for a better library eventually.

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
RCLawn
(@rclawn)
Eminent Member
Joined: 9 months ago
Posts: 47
Topic starter  

@zander,

I am a programming noboby, it's highly unlikley I will spawn a library. It would be cool if some one out there would make an example using radiohead library that switched the channel. Not everyone is trying to send large chucks of data and Im pretty sure that slowing the bitrate would help prevent retries / delays also. bottom line is that I'm not going to give up but I did find a non-radiohead sketch on youtube I'm going to try and slip my code into and try it.


ReplyQuote
RCLawn
(@rclawn)
Eminent Member
Joined: 9 months ago
Posts: 47
Topic starter  

hey hey hey...look what I found...

// nrf24_client.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing client
// with the RH_NRF24 class. RH_NRF24 class does not provide for addressing or
// reliability, so you should only use RH_NRF24 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example nrf24_server.
// Tested on Uno with Sparkfun NRF25L01 module
// Tested on Anarduino Mini ( http://www.anarduino.com/mini/) with RFM73 module
// Tested on Arduino Mega with Sparkfun WRL-00691 NRF25L01 module

 

// Defaults after init are 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!nrf24.setChannel(1))
Serial.println("setChannel failed");
if (!nrf24.setRF(RH_NRF24::DataRate2Mbps, RH_NRF24::TransmitPower0dBm))
Serial.println("setRF failed");

 

https://www.airspayce.com/airspayce/products/other-software/


ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 2755
 

@rclawn Ok, I thought you were an expert since you were not going to use a library but build from scratch. I look forward to your results.

Can you explain to me how 

slowing the bitrate would help prevent retries 

and how that is connected to the Channel?

BTW, the answer was already given to you.

 

 

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 2755
 

@rclawn Good find, BTW, this answer was given to you several posts ago

https://forum.dronebotworkshop.com/postid/32274/

It is considered poor judgement to traverse a chasm in 2 leaps.


ReplyQuote
RCLawn
(@rclawn)
Eminent Member
Joined: 9 months ago
Posts: 47
Topic starter  

they got me again...

www.airspayce.com/mikem/arduino/RadioHead/RadioHead-1.121.zip

has some *.pde example files that open in text editor

nrf24_client.pde


ReplyQuote
RCLawn
(@rclawn)
Eminent Member
Joined: 9 months ago
Posts: 47
Topic starter  

@zander ,

I saw it, but that's different from

if (!nrf24.setChannel(1))

to me...

...programming nobody, some times i'm pretty dense and you literally have to spell it out for me.

I failed visual basic because I couldn't type fast enough(in 99). That's my last attempt at any formal programming training.

thanks for rubbing it in...


ReplyQuote
Page 1 / 3