Ihave ben ttying to send just an easy message to star using this module but I haven´t been able to send it.
The first code is:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE en 9, CSN en 10
const byte direccion[6] = "00001";
void setup() {
Serial.begin(9600);
radio.begin();
radio.setChannel(100);
radio.openWritingPipe(direccion);
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_250KBPS);
radio.setAutoAck(false);
radio.stopListening();
}
void loop() {
const char mensaje[] = "Hola"; // Mensaje a enviar
bool enviado = radio.write(&mensaje, sizeof(mensaje)); // Enviar mensaje
if (enviado) {
Serial.println("Mensaje enviado: Hola");
} else {
Serial.println("Fallo en el envío");
}
Serial.println(mensaje);
delay(1000); // Espera 1 segundo antes de enviar de nuevo
}
The second code is:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE en 9, CSN en 10
const byte direccion[6] = "00001"; // Misma dirección que el transmisor
void setup() {
Serial.begin(9600);
radio.begin();
radio.setChannel(100); // Establece el canal en 100 (2500 MHz)
radio.openReadingPipe(0, direccion);
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_250KBPS);
radio.setAutoAck(false);
radio.startListening();
}
void loop() {
while (radio.available()) { // Verifica si hay datos en el buffer
char mensaje[32] = ""; // Se inicializa el buffer vacío
radio.read(mensaje, sizeof(mensaje)); // Leer el mensaje recibido
Serial.print("Mensaje recibido: ");
Serial.println(mensaje); // Mostrar el mensaje completo
}
}