Hi
I got everything wired up between a receiving Uno and a sending nano. I started by powering the nano sender from a power bank and I got garbled data. Second try I soldered a 10uF capacitor between Vcc and Gnd on the module pins but still got the same similar data. Thirdly I powered the sender from a dc regulator set to 3.3v powered by the same power bank and I still get similar results.
Wiring:
UNO RECEIVER
3.3V-----------VCC
GND-----------GND
7---------------CE
8---------------CSN
11--------------MOSI
12--------------MISO
13--------------SCK
Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.
The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work
I still got the same data. I deleted the old rf-master and put in the new one. I used your sketches and only changed pins 9,10 to 7,8 because that's what I had wired up.
Marciokoko:
I still got the same data. I deleted the old rf-master and put in the new one. I used your sketches and only changed pins 9,10 to 7,8 because that's what I had wired up.
I don't understand how you could "still got the same data" if you are using a different program (i.e. my program) that you had not used before?
Post the two programs that YOU have uploaded to your Arduinos and also post a sample of the output from each of them.
ok I didnt mean to say that I got the exact same garbled data. I mean that I didnt receive the data that was expected, and instead I got some strange symbols. I didnt take a capture of the SM from your sketches so Ill post those later, but I was basically getting "Data Received" without anything else appended and then every now and then I would get some symbols like "Data Received &>a" or something. Ill post everything in a few minutes...
// SimpleRx - the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 7
#define CSN_PIN 8
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;
}
}
// SimpleTx - the master or the transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 7
#define CSN_PIN 8
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;
}
There is no need for a lengthy piece of text. What's happening should be fairly obvious from 10 or 12 lines. That way you can just include it in your next Reply.
Although are not using pin 10 for your nRF24 it would be wise to set it as OUTPUT to ensure the Arduinos act as SPI master.
ceivreceived
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data receivedSimpleRx Starting
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮0
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮0
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮o&
Data received
Data received
and a few lines later of more "Data received" it has more of this:
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮
Data received ⸮
Data received ⸮
Data received
Data received
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮/f
Data received
Data received ⸮
Data received ⸮
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮(⸮
Data received
Data received ⸮
Data received ⸮
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮
After setting pinMode(10,OUTPUT); I get something similar:
Data received
Data received
Data receiveSimpleRx Starting
Data received
....
Data received
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮a
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮
Data received ⸮⸮⸮⸮
Data received ⸮⸮⸮⸮⸮
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮;j
Data received ⸮⸮⸮⸮⸮⸮
Data received
...
Data received
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮4,
Data received ⸮⸮⸮⸮⸮⸮⸮
Data received ⸮⸮⸮⸮⸮⸮
Data received ⸮⸮⸮⸮⸮⸮⸮
Data received
...
Data received
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮w⸮B
Data received ⸮⸮⸮⸮⸮⸮?
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮%8B
Data received
...
Data received
Data received ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮&cU
Data received ⸮⸮⸮⸮⸮⸮
Data received
...
I also just replaced the nano with a other uno and I have the same results.
It clearly shows the Arduino restarting. Did you press the reset button?
If not I would expect that there is a power problem.
My other question is what is the time interval between successive lines of
Data received
Data received
Data received
They should be appearing at about 1 second intervals. If they are printing very much faster it suggests that the Arduino is not communicating properly with its own nRF24 - either a wrong connection or a loose connection.
The Simple Rx starting is near the beginning. So my receiving Uno is on from the beginning. I actually never unplug it so it's there right now, receiving. Then I'll turn on the sender uno and look over at the serial monitor to look for received data.
Data Received obviously gets logged continuously but it seems to get garbled data about 1x a second but not consistently.
Marciokoko:
I have a video of it but I dont know where to upload it...
YouTube.
There are certainly times when a video is useful - generally when showing the behaviour of a mechanical device.
I suspect in this case a coherent written description would be better. Reply #10 is not it. And it does not answer a key question in Reply #9. I would like to help, but I need your detailed input.
Writing a good description forces you to think. Making a video does not.
OK sorry, about the restarting the Arduino question, no I did not restart it. I wasn't being evasive on purpose, i was actually trying to explain what I do in chronological order so you might find something wrong in my procedure. That starting Rx line shows up as soon as I open the SM. I do believe that opening up the serial monitor resets the Arduino in some way or at least the serial port, maybe it's a Mac thing.
The Data Received lines are continuous from the moment I open the serial monitor. I mean at least 10-20 per second.
Data received Message 1
Data received Message 2
Data received Message 3
Data received Message 4
Data received Message 5
Data received Message 6
Data received Message 7
Data received Message 8
Data received Message 9
Marciokoko:
The Data Received lines are continuous from the moment I open the serial monitor. I mean at least 10-20 per second.
That is the first thing to fix. Nothing will work until that is fixed.
It means that the Arduino is not working properly with the nRF24 it is connected to. When it happens for me it is always because I have a wiring error.
If you notice, the begin returns a bool. I would advise checking that return, assuming this is the library that you are using. If it returns false, chances are your wiring is incorrect.