Bonjour à tous,
Je cherche à envoyer une chaine de caractère entre deux arduino (Leonardo en emission, Mega en reception) avec des modules NRF24l01+ et la librairie NRF24 (http://tmrh20.github.io/RF24/index.html)
L'exemple "Getting started" (avec un int) marche très bien. Quand je test avec des chaines de caractères, il y a bien la réception d'un message toute les 5seconde, mais la variable "test" semble vide.
Code emetteur :
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(7,8);
void setup() {
Serial.begin(9600);
radio.begin(); // Start up the radio
radio.setAutoAck(1); // Ensure autoACK is enabled
radio.setRetries(15,15); // Max delay between retries & number of retries
radio.openWritingPipe('1Node');
}
void loop(void){
char *test = "salut" ;
radio.write(&test,32);
Serial.write(test);
delay(5000);
}
Code récepteur :
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"
RF24 radio(7,8);
void setup() {
Serial.begin(9600);
radio.begin(); // Start up the radio
radio.setAutoAck(1); // Ensure autoACK is enabled
radio.setRetries(15,15); // Max delay between retries & number of retries
radio.openReadingPipe(1,'1Node');
radio.startListening();
}
void loop(){
if( radio.available()){
char *test; // Variable for the received timestamp
while (radio.available()) { // While there is data ready
radio.read( &test, 32 );
Serial.println("recu : ");
delay(100);
Serial.write(test); // Get the payload
}
}
}
Pouvez-vous m'aider SVP ? =(