I currently have two Arduino Micros connected to nRF25L01 modules. The receiver spits out the number 255 while I'm trying to send 1023 (The number sent through the transmitter is connected to a pot, but I've left the pot at the max rotation.).
Here my wiring & code:
Transmitter:
Wiring
RF24 Arduino
Gnd Gnd
VCC 3v
CE 9
CSN 10
SCK 13
MOSI 11
MISO 12
IRQ 2
Pot A0
Code:
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
int val;
void setup () {
Serial.begin(9600);
Mirf.csnPin = 10;
Mirf.cePin = 9;
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.payload = sizeof(int);
Mirf.config();
Mirf.setTADDR((byte *)"roarm");
while (!Serial);
Serial.println("Starting Transmitter");
}
void loop () {
val = analogRead(0);
Mirf.send((byte *)&val);
while (Mirf.isSending()) {
Serial.println(val);
}
}
Receiver:
Wiring:
RF24 Arduino
Gnd Gnd
VCC 3v
CE 9
CSN 10
SCK 13
MOSI 11
MISO 12
IRQ 2
Code:
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
void setup () {
// Start Serial stream
Serial. begin(9600);
// Setup Mirf
Mirf.csnPin = 10;
Mirf.cePin = 9;
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.payload = sizeof(int);
Mirf.config();
Mirf.setRADDR((byte *)"roarm");
// Checks to see if Serial stream is open. If not, do nothing.
while(!Serial);
Serial.print("Starting Receiver");
}
void loop () {
byte data[Mirf.payload]; //data[0]
if (!Mirf.isSending() && Mirf.dataReady()) {
Mirf.getData(data);
Serial.println(data[0]);
} else {
Serial.println("No data is being received.");
}
}
It does seem to be sending as the code in the while isSending loop is running and the code in the if dataReady loop is receiving but the receiver shows in the serial stream 255, while the transmitter is showing 1023. Did I do something wrong?