Hello i need some help on how to send a text message from one node to another i need someone to help me code this because i do not know how to code very well to do it on my own. below is the sketch i found online for a 1 on 1 text chat using the nrf24 library but not sure how to do a text message from node 1 to node 2 or 3 without sending the message to everyone at once.
also not sure how to connect them nodes together as a mesh network i have 5 arduino uno setup with the nrf24 modules can someone please help me.
#include<SPI.h>
#include"nRf24L01.h"
#include"RF24.h"
#include"printf.h"
RF24 radio(9, 10);
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
bool go_to_tx_mode = false;
char input[32] = "";
void setup() {
Serial.begin(57600);
printf_begin();
radio.begin();
radio.setRetries(15, 15);
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1, pipes[0]);
radio.startListening();
radio.printDetails();
// put your setup code here, to run once:
}
void loop() {
if (go_to_tx_mode)
{
radio.stopListening();
bool ok = radio.write(input, 32);
if (ok)
{
printf("ME : %s\n", input);
go_to_tx_mode = false;
radio.startListening();
}
else
printf("could not write....\n");
}
if (radio.available())
{
char payload[32] = "";
bool done = false;
while (!done)
{
done = radio.read( payload , 32 );
printf("HIM : %s\n", payload);
}
}
if (Serial.available())
{
int len = Serial.readBytesUntil('\n', input, 31);
input[len] = '\0';
go_to_tx_mode = true;
}
}
At the moment i used this RX and TX to use for ping
Tx
/*
Copyright (C) 2012 James Coliz, Jr. <maniacbug@ymail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
Update 2014 - TMRh20
*/
/**
* Simplest possible example of using RF24Network
*
* TRANSMITTER NODE
* Every 2 seconds, send a payload to the receiver node.
*/
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(7,8); // nRF24L01(+) radio attached using Getting Started board
RF24Network network(radio); // Network uses that radio
const uint16_t this_node = 01; // Address of our node in Octal format
const uint16_t other_node = 00; // Address of the other node in Octal format
const unsigned long interval = 2000; //ms // How often to send 'hello world to the other unit
unsigned long last_sent; // When did we last send?
unsigned long packets_sent; // How many have we sent already
struct payload_t { // Structure of our payload
unsigned long ms;
unsigned long counter;
};
void setup(void)
{
Serial.begin(57600);
Serial.println("RF24Network/examples/helloworld_tx/");
SPI.begin();
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
}
void loop() {
network.update(); // Check the network regularly
unsigned long now = millis(); // If it's time to send a message, send it!
if ( now - last_sent >= interval )
{
last_sent = now;
Serial.print("Sending...");
payload_t payload = { millis(), packets_sent++ };
RF24NetworkHeader header(/*to node*/ other_node);
bool ok = network.write(header,&payload,sizeof(payload));
if (ok)
Serial.println("ok.");
else
Serial.println("failed.");
}
}
Rx
/*
Copyright (C) 2012 James Coliz, Jr. <maniacbug@ymail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
Update 2014 - TMRh20
*/
/**
* Simplest possible example of using RF24Network,
*
* RECEIVER NODE
* Listens for messages from the transmitter and prints them out.
*/
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
RF24 radio(7,8); // nRF24L01(+) radio attached using Getting Started board
RF24Network network(radio); // Network uses that radio
const uint16_t this_node = 00; // Address of our node in Octal format ( 04,031, etc)
const uint16_t other_node = 01; // Address of the other node in Octal format
struct payload_t { // Structure of our payload
unsigned long ms;
unsigned long counter;
};
void setup(void)
{
Serial.begin(57600);
Serial.println("RF24Network/examples/helloworld_rx/");
SPI.begin();
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
}
void loop(void){
network.update(); // Check the network regularly
while ( network.available() ) { // Is there anything ready for us?
RF24NetworkHeader header; // If so, grab it and print it out
payload_t payload;
network.read(header,&payload,sizeof(payload));
Serial.print("Received packet #");
Serial.print(payload.counter);
Serial.print(" at ");
Serial.println(payload.ms);
}
}
I can do a ping up to 200 ft i would like to extend the range using more nodes between the 2 as relays problem is not how to code the 3 nodes as relays can someone please help me?
Hello i really need help in Coding i need someone to help me program this I'm trying to setup the nrf24 network to get 6 people on it so i can send a text message to one of them without the rest seeing that message. the above code is what i use to text i honestly don't know how to send the text in the mesh network from just one person to another without the rest seeing it.