Transmit String with nRF24L01+ modules and Mirf Library
hello everybody,
i'm asking project. want send string first arduino board second arduino board using nrf24l01 modules , mirf library. don't know how convert array of bytes caught receiver string, , how print it.
this program on first (sender) :
this code on receiver :
thanks help
i'm asking project. want send string first arduino board second arduino board using nrf24l01 modules , mirf library. don't know how convert array of bytes caught receiver string, , how print it.
this program on first (sender) :
code: [select]
#include <spi.h>
#include <mirf.h>
#include <nrf24l01.h>
#include <mirfhardwarespidriver.h>
string data;
void setup(){
serial.begin(9600);
mirf.spi = &mirfhardwarespi;
mirf.init();
mirf.setraddr((byte *)"pcard");
mirf.payload = sizeof(string);
mirf.config();
serial.println("configuration terminé");
mirf.settaddr((byte *)"drone");
serial.println("configuration terminé");
}
void loop(){
if(serial.available()>0){
data = serial.readstring();
serial.println("bien recu : "+ data);
mirf.send((byte *) &data);
while(mirf.issending()){
}
serial.println("finished sending");
}
}
this code on receiver :
code: [select]
#include <spi.h>
#include <mirf.h>
#include <nrf24l01.h>
#include <mirfhardwarespidriver.h>
void setup(){
serial.begin(9600);
mirf.spi = &mirfhardwarespi;
mirf.init();
mirf.setraddr((byte *)"drone");
mirf.payload = sizeof(string);
mirf.config();
serial.println("configuration terminé");
}
void loop(){
string data="";
if(mirf.dataready()){
mirf.getdata((byte *) &data);
serial.println(data);
}
}
thanks help
if need in array of bytes transmitting on transceiver, why bother strings in first place? use char arrays (also known strings)
Arduino Forum > Using Arduino > Programming Questions > Transmit String with nRF24L01+ modules and Mirf Library
arduino
Comments
Post a Comment