Hello, There are many instances of several modules sending to one receiver.
however I have communications working between nodes but after hours of work I want the send three pushbuttons from node 00 to node 01, then to illuminate 3 x led's . My problem is writing instruction in the loop to send these multiple commands, as a "batch" file. I am also trying to send a different set of codes from node 00 to node 02. Can anyone point me in the right direction, perhaps with a known sketch example.
Any help very gratefully received.
A bit more information would be useful as well as the minimal code for both nodes that demonstrates the first part of your problem (i.e. 3 buttons on node 00 to 3 leds on node 01) and also for the second part of your problem.
Also, is node 00 normally configured as a receiver? If so, have you looked at the RF24 example where payloads are attached to the Ack from receiver back to sender? RF24/ManualAcknowledgements.ino at master · nRF24/RF24 · GitHub
Sending multiple commands/data parts could either be done by:
1: Having a payload that's sufficiently large to contain all commands/data appended to each other; assemble them on the side of the sender and then disassemble them on the receiver side
2: Send repeated communications, one command/data part at a time.
So what have you tried already and where does it go wrong?
I am trying to use a variation of : Arduino Wireless Network - Multiple NRF24L01 Tutorial
== Example 01 - Servo Control / Node 00 - Potentiometer ==
by Dejan, www.HowToMechatronics.com
This is as far as I can get:
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#define button1 3
#define button2 6
#define button3 15
RF24 radio(7, 8); // nRF24L01 (CE,CSN)
RF24Network network(radio); // Include the radio in the network
const uint16_t this_node = 00; // Address of this node in Octal format ( 04,031, etc)
const uint16_t node01 = 01; // Address of the other node in Octal format
void setup() {
// Serial.begin(9600);
SPI.begin();
radio.begin();
network.begin(90, this_node); //(channel, node address)
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MIN);
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(button3, INPUT_PULLUP);
}
void loop() {
network.update();
//===== Sending =====//
unsigned long buttonState1 = digitalRead(button1);
unsigned long buttonState2 = digitalRead(button2);
unsigned long buttonState3 = digitalRead(button3);
RF24NetworkHeader header(node01); // (Address where the data is going)
network.write(header, &buttonState1, sizeof(buttonState1)); // Send the data
network.write(header, &buttonState2, sizeof(buttonState2));
network.write(header, &buttonState3, sizeof(buttonState3));
Serial.println(buttonState1);
}
Node01
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#define led1 3
#define led2 4
#define led3 5
RF24 radio(7, 8); // nRF24L01 (CE,CSN)
RF24Network network(radio); // Include the radio in the network
const uint16_t this_node = 01; // Address of our node in Octal format ( 04,031, etc)
const uint16_t master00 = 00; // Address of the other node in Octal format
void setup() {
//Serial.begin(9600);
SPI.begin();
radio.begin();
network.begin(90, this_node);
radio.setDataRate(RF24_250KBPS);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}
void loop() {
network.update();
//===== Receiving =====//
while (network.available() ) { // Is there any incoming data?
RF24NetworkHeader header;
unsigned long incomingData;
unsigned long buttonState1;
unsigned long buttonState2;
unsigned long buttonState3;
network.read(header, &incomingData, sizeof(incomingData));
if (header.from_node == 00) {
network.read(header, &buttonState1, sizeof(buttonState1));
network.read(header, &buttonState2, sizeof(buttonState2));
network.read(header, &buttonState3, sizeof(buttonState3));
digitalWrite(led1, !buttonState1); // Turn on the LED
digitalWrite(led2, !buttonState2);
digitalWrite(led3, !buttonState3);
Serial.println(buttonState1);
}
}
}
At the state where I need help, any of which is very gratefully welcome,
Where am I going wrong?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.