I found my self stuck with this problem and I think its hardware problem but before buying new one
I would like to be sure its hardware problem. So its goes.
This code:
/*This sketch receives 2 analog values through an nRF24L01 wireless module.
*/
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
int joystick[1];
RF24 radio(9,10);
const uint64_t pipe[] = {0xE8E8F0F0E1LL,0xF0F0F0F0D2LL};
void setup(void)
{
pinMode(4,INPUT);
pinMode(2,OUTPUT);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1,pipe[1]);
radio.openWritingPipe(pipe[0]);
radio.startListening();
radio.printDetails();
}
void loop(void)
{
if(digitalRead(4)==1){
radio.stopListening();
Serial.println(digitalRead(4));
joystick[0]=1;
bool ok = radio.write(joystick,sizeof(joystick));
if (ok)Serial.println("OK");
else Serial.println(" Nije ok");
radio.startListening();
delay(100);}
if ( radio.available() )
{
radio.read( joystick, sizeof(joystick) );
if(joystick[0]==1){
if(digitalRead(2)==1)digitalWrite(2,LOW);
else digitalWrite(2,HIGH);}
Serial.println(joystick[0]);
}
else
{
Serial.println("No radio available");
}
delay(50);
}
Is uploaded to UNO (1).
And this code is uploaded to UNO(2).
/*This sketch receives 2 analog values through an nRF24L01 wireless module.
*/
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
int joystick;
RF24 radio(9,10);
const uint64_t pipe[] = {0xE8E8F0F0E1LL,0xF0F0F0F0D2LL};
void setup(void)
{
pinMode(4,INPUT);
pinMode(2,OUTPUT);
Serial.begin(9600);
radio.begin();
radio.setRetries(15,15);
radio.openReadingPipe(1,pipe[0]);
radio.openWritingPipe(pipe[1]);
radio.startListening();
radio.printDetails();
}
void loop(void)
{
if(digitalRead(4)==1){
radio.stopListening();
Serial.println(digitalRead(4));
joystick=1;
bool ok = radio.write(&joystick,sizeof(joystick));
if (ok)Serial.println("OK");
else Serial.println(" Nije ok");
radio.startListening();
delay(100);}
if ( radio.available() )
{
radio.read( &joystick, sizeof(joystick) );
if(joystick==1){
if(digitalRead(2)==1)digitalWrite(2,LOW);
else digitalWrite(2,HIGH);}
Serial.println(joystick);
}
else
{
Serial.println("No radio available");
}
delay(50);
}
Problem is that UNO(1) cant see transmit information from UNO(2).
How do I check is UNO(2) transmitting at all? Or any other solution?
Quick question... have you confirmed your wiring is all OK by running the ping pair example? Have you got 10uF capacitors across the power of the NRF24L01s?
Tried everything i could 've think of...Array,integer ...I'm planning to transmit bigger array but for now size 1 is ok for testing.
Just to mention codes are almost the same except for addreses for radio pipes. I tried switching codes between arduinos but same problem with same arduino UNO R3. The other one is UNO R2.
Is it possible that problem is in the libraries because it is working fine on R2 but not on R3.
Looks like you are getting garbage out of the serial monitor which would indicate a speed ore settings mismatch.
Did you try to get the ping pair working? Once you have that, you know most of the hard ware works. Then try reading your joystick to serial, once that works, send over the wireless devices.
Arduino UNO R3 is not transmitting in any case, tried all of them.
UNO R2 works perfectly. I guess i'll try to get another one and try with it. Will post if got any changes.
Have you tried it with the ping pair example? Have you checked your serial com settings against your sketch? (As in have you checked the serial monitor is also set to 9600?)
@Docedison Interesting. I got 30 feet with the 10uF. How far did you get with 220uF? I also powered it with a 3 amp switching power regulator, and needed at least a 10uF on the power lines, possibly to remove noise on the power lines.
Are the antenna's at least 1 meter apart..
Were you able to pass the basic ping pair test after cycling power?
There is a Gotcha that you would have found in the purpose of the role pin, Had you spent the time to Google the project or for that matter searched the Arduino Data Base first...