OK UKHeliBob so you think it's more appropriate for the programming questions section.
Thanks, even though I don't think code is the problem.
I copied it right from the tutorial and I think Robin2 knew what he was doing.
The list of other problems I had;
bad board got hot and made squares in the serial monitor,
wouldn't upload until I used old bootloader
weren't code related, just problems with my project that I listed because others might run into them if they try working with nerfs and nanos.
...and instead of just linking to the page with the code I'll post it here:
receiver:
// SimpleRx - the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 8
#define CSN_PIN 10
const byte thisSlaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};
RF24 radio(CE_PIN, CSN_PIN);
char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;
//===========
void setup() {
Serial.begin(9600);
Serial.println("SimpleRx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
}
//=============
void loop() {
getData();
showData();
}
//==============
void getData() {
if ( radio.available() ) {
radio.read( &dataReceived, sizeof(dataReceived) );
newData = true;
}
}
void showData() {
if (newData == true) {
Serial.print("Data received ");
Serial.println(dataReceived);
newData = false;
}
}
And for the transmitter:
// SimpleTx - the master or the transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 8
#define CSN_PIN 10
const byte slaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
char dataToSend[10] = "Message 0";
char txNum = '0';
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second
void setup() {
Serial.begin(9600);
Serial.println("SimpleTx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.setRetries(3,5); // delay, count
radio.openWritingPipe(slaveAddress);
}
//====================
void loop() {
currentMillis = millis();
if (currentMillis - prevMillis >= txIntervalMillis) {
send();
prevMillis = millis();
}
}
//====================
void send() {
bool rslt;
rslt = radio.write( &dataToSend, sizeof(dataToSend) );
// Always use sizeof() as it gives the size as the number of bytes.
// For example if dataToSend was an int sizeof() would correctly return 2
Serial.print("Data Sent ");
Serial.print(dataToSend);
if (rslt) {
Serial.println(" Acknowledge received");
updateMessage();
}
else {
Serial.println(" Tx failed");
}
}
//================
void updateMessage() {
// so you can see that new data is being sent
txNum += 1;
if (txNum > '9') {
txNum = '0';
}
dataToSend[8] = txNum;
}
Components are 2 arduino nanos.
Transmit and receive.
This nerf:
Addicore NRF24L01+PA+LNA with Antenna 2.4GHz Wireless Transceiver
This adapter between the 2:
Addicore nRF24L01+ Adapter Board
The adapter makes it so I can run the nerf on 5 volts from the nano.
A schematic:
Any tips on how to draw and post a schematic let me know.
I couldn't find a how to for posting pictures and the one from dronebot doesn't seem to want to load on my flicker.
So of course
SCK goes to 13 on the nano
MOSI to pin 11
MISO to pin 12
and
CSN to pin 10
CE to pin 8
Power for the adapter goes to 5Volts on the nano, where it is regulated down to 3.3 to power the nrf24.
ground is to ground.
A picture of it is a little ways down on this page:
nRF24L01 Wireless Joystick for Arduino Robot Car | DroneBot Workshop
mrburnette, Thanks for the link. I see it uses the radiohead library like dronebot's page.
For this simple beginners attempt to get them to "talk" I'm trying the TMRh20 version of the RF24 library like Robin2 suggested. But I will be switching to the radiohead library to complete the project the way dronebot did it.
So I guess the question is what it's failing to do?
Is it not sending the message to the receiver,
or not bouncing back when it shows this message in the serial monitor:
"SimpleTx Starting
Data Sent Message 0 Tx failed
Data Sent Message 0 Tx failed"
Am I supposed to hook the receiver up to another power source then check the serial monitor for the transceiver? Other way around?
Since I have both hooked to the same laptop is the serial monitor for the master or slave? Since the message is the same whichever serial monitor I click on. I was thinking the serial monitor would relate to the Arduino window it was hooked to.