buenas estoy intentando comunicar dos arduino uno entre si con cons nRF24L01 conectados por SPI con la libreria R24-master y he probado varios ejemplos y pese a que detecta (vamos creo que lo detecta por que sin conectarlo lo ejecuto y me sale el estatus y las adress a 0) el dispositivo no consigo enviar nada
Por ejemplo con el ejemplo led_remote lo programo en las dos placas y en una de ellas pongo leds y el A4 a GDN en la otra swiches con pullups por si acaso el resultado es:
Este es el codigo que yo uso, modificado para enviar datos de presion y tensión de la bateria, pero básicamente es el mismo.
A mi me funciona perfecto.
Codigo parcial Receptor
* YourDuinoStarter Example: nRF24L01 Receive Joystick values
*
* - WHAT IT DOES: Receives data from another transceiver with
* 2 Analog values from a Joystick or 2 Potentiometers
* Displays received values on Serial Monitor
* - SEE the comments after "//" on each line below
* - CONNECTIONS: nRF24L01 Modules See:
* http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
* 1 - GND
* 2 - VCC 3.3V !!! NOT 5V
* 3 - CE to Arduino pin 9
* 4 - CSN to Arduino pin 10
* 5 - SCK to Arduino pin 13
* 6 - MOSI to Arduino pin 11
* 7 - MISO to Arduino pin 12
* 8 - UNUSED
*
* - V1.00 11/26/13
* Based on examples at http://www.bajdi.com/
* Questions: terry@yourduino.com
*
*
********************************************************/
/*-----( Import needed libraries )-----*/
#include <LiquidCrystal.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <LcdBarGraph.h>
#include <EEPROM.h>
#include <avr/eeprom.h> //needed for eeprom_read_block function
struct calib_t
{
float slope;
float offset;
} calib;
/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN 9
#define CSN_PIN 10
byte lcdNumCols = 24; // -- number of columns in the LCD
/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
// select the pins used on the LCD panel
LiquidCrystal lcd(6, 7, 5, 4, 3, 2);
LcdBarGraph lbg(&lcd, lcdNumCols, 0, 0); // -- creating
/*-----( Declare Variables )-----*/
// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe
int presion[2]; // 2 element array holding Joystick readings
// el ejemplo definia jostick[2] y luego lo usaba en todos los lugares que dicen presion
float porciento;
float Slope, Offset;
char junk;
float Temp[2] = {0};
float Raw[2] = {0};
unsigned int Mostrar = 0;
int constrainedValue = 0;
float tankLevel = 0.0;
boolean tanqueLleno = false;
unsigned long timeTanqueLleno = 0;
void setup() {
bool done = false;
Serial.begin(9600);
Serial.println("Nrf24L01 Receiver Starting");
lcd.begin(24, 2); // start the library
lcd.setCursor(0, 0);
lcd.print("NRF24L01 RX Starting"); // print a simple message
delay(2000);
lcd.clear();
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
// sigue el codigo similar al ejemplo citado
Aca parte del transmisor
/* YourDuinoStarter Example: nRF24L01 Transmit sensorData values
- WHAT IT DOES: Reads Analog values on A0, A1 and transmits
them over a nRF24L01 Radio Link to another transceiver.
- SEE the comments after "//" on each line below
- CONNECTIONS: nRF24L01 Modules See:
http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo
1 - GND
2 - VCC 3.3V !!! NOT 5V
3 - CE to Arduino pin 9
4 - CSN to Arduino pin 10
5 - SCK to Arduino pin 13
6 - MOSI to Arduino pin 11
7 - MISO to Arduino pin 12
8 - UNUSED
-
Analog sensorData or two 10K potentiometers:
GND to Arduino GND
VCC to Arduino +5V
X Pot to Arduino A0
Y Pot to Arduino A1
- V1.00 11/26/13
Based on examples at http://www.bajdi.com/
Questions: terry@yourduino.com */
/*-----( Import needed libraries )-----*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define CE_PIN 9
#define CSN_PIN 10
/*----- Sensor de Presion -----*/
#define Sensor A1
#define NUM_READS 200
// NOTE: the "LL" at the end of the constant is "LongLong" type
const uint64_t pipe = 0xE8E8F0F0E1LL; // Define the transmit pipe
/*-----( Declare objects )-----*/
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
/*-----( Declare Variables )-----*/
int sensorData[2]; // 2 element array holding sensorData readings
byte analogRef = 0;
void setup() /****** SETUP: RUNS ONCE ******/
{
Serial.begin(9600);
if(analogRef == 1)
analogReference(INTERNAL); //set analog reference to internal 1.1V
else
analogReference(DEFAULT);
radio.begin();
radio.openWritingPipe(pipe);
}//--(end setup )---
// contnua el còdigo similar al ejemplo
NO se si te ayudarà en algo... la verdad no se como hacerlo.
He probado el código led y funciona.
Revisaste las conexiones?
Yo estoy con un NANO en ambos lados pero funciona perfecto en todos los arduinos.