Ciao a tutti sono nuovo del forum per tanto non so se scrivo nella giusta sezione, corregetemi in tal caso.
Non voglio annoiarvi col descrivermi il mio progetto ma andrò dritto al punto/problema: ho letto la la libreria dei nRF24L01 e non riesco a trovare il modo di inviare un messaggio (dal main) a tutti i ricevitore che inneschi in loro una funzione la quale ritorni al main un valore.
Vorrei che tutti i receivers avessero lo stesso codice e non fosse necessario dover specificare l'address.
Infatti l'obbiettivo principale del mio progetto è che andando a tentativi riesco a assegnare a ogni ricevitore il proprio address.
In realta grazie a questa funzione :
TRASMITTER
int pairing(int pipe){
// Generate a single random character to transmit
unsigned char data = random(0, 10);
radio.openWritingPipe(addresses[pipe]);
// Ensure we have stopped listening (even if we're not) or we won't be able to transmit
radio.stopListening();
// Did we manage to SUCCESSFULLY transmit that (by getting an acknowledgement back from the other Arduino)?
// Even we didn't we'll continue with the sketch, you never know, the radio fairies may help us
if (!radio.write( &data, sizeof(unsigned char) )) {
Serial.println("No acknowledgement of transmission - receiving radio device connected?");
}
// Now listen for a response
radio.startListening();
// But we won't listen for long, 200 milliseconds is enough
unsigned long started_waiting_at = millis();
// Loop here until we get indication that some data is ready for us to read (or we time out)
while ( ! radio.available() ) {
// Oh dear, no response received within our timescale
if (millis() - started_waiting_at > 200 ) {
Serial.println("No response received - timeout!");
return;
}
}
RECEIVER
// This is what we receive from the other device (the transmitter)
unsigned char data;
// Is there any data for us to get?
if ( radio.available()) {
// Go and read the data and put it into that variable
while (radio.available()) {
radio.read( &data, sizeof(char));
}
// No more data to get so send it back but add 1 first just for kicks
// First, stop listening so we can talk
radio.stopListening();
data = data + 100;
radio.write( &data, sizeof(char) );
// Now, resume listening so we catch the next packets.
radio.startListening();
Riesco a ottenere una o piu risposte solo se sono da address diversi, se invece ci sono due receiver(due diverse risposte) con uno stesso address ne ottengo solo 1.....
Ho scritto in questo forum per questo semplice motivo vorrei riuscire ad avere due risposte anche se l'address è lo stesso.
Ringrazio in Anticipo per qualsiasi consiglio.