nRF24 / RF24Mesh

OSI Layer 7 Mesh Networking for RF24Network & nrf24L01+ & nrf52x devices
http://nrf24.github.io/RF24Mesh
GNU General Public License v2.0
422 stars 154 forks source link

I can't communicate a node with another node. #163

Closed wavewolf closed 4 years ago

wavewolf commented 5 years ago

Communication from any node to master works correctly but if I want to send master data to a specific node it does not work. It also happens when I want to send data from one node to another node, it does not work.

TMRh20 commented 5 years ago

Not sure what to suggest. If the mesh is up and functioning it should just work.

On Apr 5, 2019, at 05:17, ignacioslez notifications@github.com wrote:

Communication from any node to master works correctly but if I want to send master data to a specific node it does not work. It also happens when I want to send data from one node to another node, it does not work.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

wavewolf commented 5 years ago

I explain the situation. I have 4 systems with nrf24l01 + modules:

a- System 1 Master (receives information and sends information to the nodes). b- Node 1 system (sends information to the master and node 3) c- Node 2 system (sends information to the master and node 3) d - System node 3 (receives infomation to the node 1 & node 2 and sends information to the master)

I only get it to work when the nodes send information to the master, any other option doesn't work. I can't send information from node to node or from master to node.

TMRh20 commented 5 years ago

Only thing I can think of is to try a different radio channel in case of interference. Use mesh.begin(uint8_t channel)

On Apr 6, 2019, at 11:05, ignacioslez notifications@github.com wrote:

I explain the situation. I have 4 systems with nrf24l01 + modules:

a- System 1 Master (receives information and sends information to the nodes). b- Node 1 system (sends information to the master and node 3) c- Node 2 system (sends information to the master and node 3) d - System node 3 (receives infomation to the node 1 & node 2 and sends information to the master)

I only get it to work when the nodes send information to the master, any other option doesn't work. I can't send information from node to node or from master to node.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

wavewolf commented 5 years ago

I don't know if it has any sense with it, but when I use the normal RF24 library and I define reading channels in the supposed master, it only works in this way: openReadingPipe(1, pipes[1]), openReadingPipe(1, pipes[2]), openReadingPipe (1, pipes[3])... but if I try: openReadingPipe(1, pipes[1]), openReadingPipe(2, pipes[2]), openReadingPipe (3, pipes[3]), it doesn't work. The master don't receive anything. This problem could be the same?

TMRh20 commented 5 years ago

Yeah, that seems like the same problem. Really odd.

On Apr 7, 2019, at 17:56, ignacioslez notifications@github.com wrote:

I don't know if it has any sense with it, but when I use the normal RF24 library and I define reading channels in the supposed master, it only works in this way: openReadingPipe(1, pipes[1]), openReadingPipe(1, pipes[2]), openReadingPipe (1, pipes[3])... but if I try: openReadingPipe(1, pipes[1]), openReadingPipe(2, pipes[2]), openReadingPipe (3, pipes[3]), it doesn't work. The master don't receive anything. This problem could be the same?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

wavewolf commented 5 years ago

Hi again, I have detected an error that I had regardless of the library and I have solved it. Now I've got the "nodetonode" example working, and I've also managed to send data from two different nodes to the master. But now I have a problem, I can't send data from the master to a different node.

Could you take a look at the master code and node 3 to see if I'm making an error?

NODE 3 (this node receives information from the master):

#include "RF24.h"
#include "RF24Network.h"
#include "RF24Mesh.h"
#include <SPI.h>

const int pinCE = A4;
const int pinCSN = A5; 
int golpesBlue = 0;

RF24 radio(pinCE, pinCSN);
RF24Network network(radio);
RF24Mesh mesh(radio, network);

#define nodeID 3

void setup()
{
 Serial.begin(115200);
 mesh.setNodeID(nodeID);
 Serial.println(F("Connecting to the mesh..."));
 mesh.begin();
}

void loop() {
mesh.update();

  while (network.available()) {

    RF24NetworkHeader header;
    network.read(header, &payload, sizeof(payload));

    if (payload == 85) { 
      golpesBlue++;
     Serial.print("Received packet #");
    Serial.println(golpesBlue);
    }

  }
}

MASTER (the master receives information from node 1 and 2 and sends information to node 3):

#include "RF24Network.h"
#include "RF24.h"
#include "RF24Mesh.h"
#include <SPI.h>
#include <EEPROM.h>

int sensorA = 0;
int sensorAant = 0;

RF24 radio(8, 9);
RF24Network network(radio);
RF24Mesh mesh(radio, network);

void setup() {

 Serial.begin(115200);
  mesh.setNodeID(0);
  Serial.println(mesh.getNodeID());
  mesh.begin();
}

void loop() {

  mesh.update();
  mesh.DHCP();
//-------------------------------------------------------------------------------//
    if (network.available()) {
      RF24NetworkHeader header;
      network.peek(header);
      Serial.print("Got ");
      uint32_t dat;
      switch (header.type) {
        case 'M':
          network.read(header, &dat, sizeof(dat));
          Serial.print(dat);
          Serial.print(" from RF24Network address 0");
          Serial.println(header.from_node, OCT);
          break;
        default:
          network.read(header, 0, 0);
          //Serial.println(header.type);
          break;
      }

      if (dat == 75) {
        sensorA++;
        Serial.println("node 1 data");
      }
      else if (dat == 76) {
        sensorA = sensorA + 2;
        Serial.println("node 2 data");
      }
    }
//----------------------------------------------------------------------------------//

  if (sensorA != sensorAant) {
    Serial.println(sensorA);

    uint32_t payload = 85;

    for (int i = 0; i < mesh.addrListTop; i++) {

      RF24NetworkHeader header(mesh.addrList[i].address, OCT); //Constructing a header
      Serial.println( network.write(header, &payload, sizeof(payload)) == 1 ? F("Send OK") : F("Send Fail")); //Sending an message

    }

  }

  sensorAant = sensorA;
}
Avamander commented 5 years ago

What's your setup like? How well decoupled is the power? Are you sure your modules are not counterfeit? What Arduinos are you using?