Bonjour tout le monde:)
J'espère que vous pourrez m'aider à résoudre un mystère autour d'un module NRF24.
Je n’ai jamais eu de gros problème en utilisant cette puce avec le µc nano 328P, mais en utilisant des 2560, cela ne fonctionne pas correctement. J'ai lu que l'alim 3.3 du méga n'est pas suffisamment bien réguler pour les chip radio, j'ai essayer avec une alim de labo sans succès
J'utilise la bibliothèque Mirf avec l'exemple ping_client ping_server.
Mes broches sont montées comme ceci:
MOSI - ICSP-4
MISO - ICSP-1
SCK - ICSP-3
CSN-D42
CE -D44
V- 3v3
G-gnd
Quelqu'un a-t-il une piste?
Voici le code exemple que j'utilise coté serveur:
/**
An Mirf example which copies back the data it recives.
Pins:
Hardware SPI:
MISO -> 12
MOSI -> 11
SCK -> 13
Configurable:
CE -> 8
CSN -> 7
*/
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
void setup() {
Serial.begin(115200);
Mirf.csnPin = 42;
Mirf.cePin = 44;
/*
Set the SPI Driver.
*/
Mirf.spi = &MirfHardwareSpi;
/*
Setup pins / SPI.
*/
Mirf.init();
/*
Configure reciving address.
*/
Mirf.setRADDR((byte *)"serv1");
/*
Set the payload length to sizeof(unsigned long) the
return type of millis().
NB: payload on client and server must be the same.
*/
Mirf.payload = sizeof(unsigned long);
/*
Write channel and payload config then power up reciver.
*/
Mirf.config();
Serial.println("Listening...");
}
void loop() {
/*
A buffer to store the data.
*/
byte data[Mirf.payload];
/*
If a packet has been recived.
isSending also restores listening mode when it
transitions from true to false.
*/
if (!Mirf.isSending() && Mirf.dataReady()) {
Serial.println("Got packet");
/*
Get load the packet into the buffer.
*/
Mirf.getData(data);
/*
Set the send address.
*/
Mirf.setTADDR((byte *)"clie1");
/*
Send the data back to the client.
*/
Mirf.send(data);
/*
Wait untill sending has finished
NB: isSending returns the chip to receving after returning true.
*/
Serial.println("Reply sent.");
}
}
Voici le code exemple que j'utilise côté client:
/**
A Mirf example to test the latency between two Ardunio.
Pins:
Hardware SPI:
MISO -> 12
MOSI -> 11
SCK -> 13
Configurable:
CE -> 8
CSN -> 7
Note: To see best case latency comment out all Serial.println
statements not displaying the result and load
'ping_server_interupt' on the server.
*/
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
void setup() {
Serial.begin(115200);
Mirf.csnPin = 42;
Mirf.cePin = 44;
/*
Setup pins / SPI.
*/
/* To change CE / CSN Pins:
Mirf.csnPin = 9;
Mirf.cePin = 7;
*/
/*
Mirf.cePin = 7;
Mirf.csnPin = 8;
*/
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
/*
Configure reciving address.
*/
Mirf.setRADDR((byte *)"clie1");
/*
Set the payload length to sizeof(unsigned long) the
return type of millis().
NB: payload on client and server must be the same.
*/
Mirf.payload = sizeof(unsigned long);
/*
Write channel and payload config then power up reciver.
*/
/*
To change channel:
Mirf.channel = 10;
NB: Make sure channel is legal in your area.
*/
Mirf.config();
Serial.println("Beginning ... ");
}
void loop() {
unsigned long time = millis();
Mirf.setTADDR((byte *)"serv1");
Mirf.send((byte *)&time);
while (Mirf.isSending()) {
}
Serial.println("Finished sending");
delay(10);
while (!Mirf.dataReady()) {
//Serial.println("Waiting");
if ( ( millis() - time ) > 1000 ) {
Serial.println("Timeout on response from server!");
return;
}
}
Mirf.getData((byte *) &time);
Serial.print("Ping: ");
Serial.println((millis() - time));
delay(1000);
}
voici une image de mon pcb et quelques photos du montage:
Merci d'avance pour vos réponses