[Request - Answered] nRF24L01+ library

Ok @Moors7, as I promised already many times and failed to fulfill :tired_face:, apologies.

My network configuration is highly customized and actually using some sort of mesh or dynamic tree where each node can be a leaf or a leaf & router. Only the :particle: Core is fixed node as being the root of the tree or internet gateway, if you prefer.

The network though is too complicated code for a tutorial and it was the main blocking point for my previous efforts to publish something on this, probably a reduced star topology would be easier to understand and follow…

@LukeUSMC I will share extracts of my code, but bear in mind I’m doing nothing fancy in the data communication: the Arduino populates a struct and the :particle: Core pushes that struct on the Internet… I’m just using the existing nRF24L01 libraries… The tough part starts when you want your network to self configure or self re-configure on the fly, which is managed in some messy code I’m not ready yet to share just because it is tough to follow even for me :smile:

I have a few SenseBender Micros from mySensors.org and I am hoping I can pull some of that stuff from it. Anything you’d be willing to share would be great. Thanks!

@LukeUSMC @Moors7 I started the tutorial with a first introductory blog post: please let me know if that’s what you were suggesting and anything else you might want to comment, including the wording as I’m not English mother tongue :smile:

The next post will be about eletronics, explaining how to wire the sensors and the hub, then I will need additional 3 posts for the software, one for each platform.
In the meanwhile, can somebody verify if the spectacular nRF24 library made by BDub has any trouble working with the Photon? I’ve received mine only yesterday and didn’t have the time to verify myself.

1 Like

@rlogiacco that is perfect! Don’t worry about your English, you have better grammar and a larger vocabulary than the average adult native English speakers. If you really want someone to nit pick it, I will but you are doing just fine on your own. Thanks again for sharing your work.

The fact that I kept looking where to find part two might be a good sign? Looks good so far, and I’m interested in seeing where this goes!
As far as your English is concerned, seems pretty good to me, don’t worry about that. Then again, I’m not natively English either :wink:

@LukeUSMC yes please, I’m always willing to improve!

I’ve just finished the Arduino sensor wiring part which took me more than I was expecting due to the lack of a nRF24L01 part for fritzing… :dizzy_face:

I ran the GettingStartedSpark and get a successful response from printDetails. I don’t have a working receiver yet but seems to be working at a basic level.

1 Like

Here is a non-blocking scanner with Adafruit oled output. The scanner examples out there block to the point that you can’t flash your device once you start it. I like to use the oled as a mini serial console to give me just the most important pieces of info. Hopefully this will help someone else and if anyone knows how I can add the tag for C syntax formatting in the forum…please share.

#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"
#include "nRF24L01.h"
#include "RF24.h"

#define OLED_RESET D4
Adafruit_SSD1306 display(OLED_RESET);
//
// Hardware configuration
//

/*
  PINOUTS
  http://docs.spark.io/#/firmware/communication-spi
  http://maniacbug.wordpress.com/2011/11/02/getting-started-rf24/

  SPARK CORE    SHIELD SHIELD    NRF24L01+
  GND           GND              1 (GND)
  3V3 (3.3V)    3.3V             2 (3V3)
  D6 (CSN)      9  (D6)          3 (CE)
  A2 (SS)       10 (SS)          4 (CSN)
  A3 (SCK)      13 (SCK)         5 (SCK)
  A5 (MOSI)     11 (MOSI)        6 (MOSI)
  A4 (MISO)     12 (MISO)        7 (MISO)
*/

RF24 radio(D6,A2);
const uint8_t num_channels = 128;
int counter = 0;

void setup(void)
{
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.display();
  Serial.begin(57600);
  Serial.println("nRF24L01 Interference Scanner.");

  radio.begin();
  radio.setAutoAck(false);

  radio.startListening();
  radio.stopListening();
}

void loop(void)
{
  Spark.process();
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.print("nRF24 Scan");
  display.display();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,16);

if (num_channels != counter){
  channelCheck(counter);
  counter = counter + 1;
  }
else{
  testDone();
  delay(5000UL);
  }
}


void testDone(){
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.print("nRF24 Scan");
  display.display();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,16);
  display.print("Scan Done!");
  counter = 0;
}

void channelCheck(int channel){
      display.setCursor(0,16);
      radio.setChannel(channel);
      display.print("On channel: ");
      display.println(channel);
      display.display();
      radio.startListening();
      delayMicroseconds(128);
      radio.stopListening();
      display.println("Done listening.");
      display.display();
      if (radio.testCarrier()){
        display.println("Carrier Found");
        display.display();
        delay(1000);
        }
      else
      display.println("No Carrier.");
      display.display();
      }
1 Like

I’ve almost finished the arduino sensor code, 90% there.

The wiring is pretty standard

2 Likes

Ok, I now have 3 boards in a very simple configuration: I had a few hiccups with some dodgy connections which drove me mad, but now I’m in a position to verify the code on the field.

4 Likes

try this one instead.

@tezza I will be using those on the hub node.They give a greater range, which is important, but doesn’t change the concept.
Why were you suggesting to use those instead? Any particular reason I might be overlooking?

was responding to the price. these are less than a third of the cost of those mentioned above by @BDub

Part two of the nRF24 walk through is out, part 3 very close to completion: I’ll update the first post adding links to the different parts when they’ll come in.

Comments and corrections are welcome and please @LukeUSMC don’t hesitate to suggest rewordings :smile:

1 Like

I will PM you some edits for Parts 1 and 2 today. That is the least I can do. Thanks!

Thanks @LukeUSMC, I’m eager to see your corrections :smirk:
BTW, my blog received a huge boost in visits… only 7 are coming from this thread though…

1 Like

Give it time, it is a natural progression for anyone looking to build a distributed system. Keep up the good work!

Lads, I’ve the code ready for the Arduino and it’s quite clean to me. I’ve tried to cover two scenarios in one go, but I want your opinion: is it clear as it is (the two reply methods) or should I introduce it in two separate steps?

Please have a look at the sensor firmware on github and let me know.

Just to show off a bit, here are the three different hubs ready to receive their firmware :smiley:



I’ve updated the first post after @LukeUSMC corrections (thanks a million buddy) and I’ve updated the second to reflect what I’ve learned from him.