Hi ,
im working on this diy nrf radio controller to control a drone. The transmitter circuit includes a nano, the nrf, joysticks, and a potentiometer .
the receiver circuit includes another nano and nrf. The receiver circuit on the drone is connected to the arduino Uno and an mpu6050 .
I conducted a test to check the transmission by changing the values of the potentiometer and checking receiver output. the transmission part works fine . However, when we run the whole code with the joysticks , the joysticks give no output whatsoever . even upon moving the joysticks , there is no output.
i am following this site for making the controller . the entire controller is based off this site including the circuit as well as the codes.
the joystick shows digital output 8 for all which is incorrect . when the circuit is on and we check with a mulitimeter , all the joystick inputs 8 to 11 are short .
link : Arduino radio controller DIY NRF24
please help.
If you think the problem is the joysticks, why did you not give any information about the joysticks? Not even a picture or a data sheet or even the manufacturer's name and a product number.
You write that you used a DVM for something, but never mention the resistance your meter showas for the joy sticks. Are you certain the joysticks are potentiometers? Some are just switches. Why not use your meter to investigate?
Paul
Please don't post pictures of text. Just copy and paste the text.
Also, you need to explain what the text is supposed to be telling us.
It would be a good idea to write a short program to get the values from the joystick and show them on the Serial Monitor.
I conducted a test to check the transmission by changing the values of the potentiometer and checking receiver output. the transmission part works fine .
How do you know the transmission part works?
I recommend that you read the rf24 tutorial linked by Robin2. Pay special attention to the part about powering the radios. Lack of proper power is the main (my opinion) problem that new users face when starting with the rf24.
I have a setup with 2 Unos with rf24 radios that have there own 3.3V regulators powered form the Uno 5V. Here is example code (modified from Robin2's rf24 tutorial) that reads a joystick and one switch, transmits, receives, parses the data and prints the data to serial monitor of the receiver. Tested and functions as described. Hardware hook up is shown in the programs.
Send code:
// Example from Robin2's simple rf24 tutorial modified by c goulding
// to transmit 2 joystick axes and one switch state.
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define JoyX A0 // Joystick X pin connected to A0 on the UNO
#define JoyY A1 // Joystick Y pin connected to A2 on the UNO
int Switchpin = 3; // Digital pin connected to switch output
#define CE_PIN 9
#define CSN_PIN 10
const byte slaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
int dataToSend[3];
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second
void setup()
{
pinMode(JoyX, INPUT);
pinMode(JoyY, INPUT);
pinMode(Switchpin, INPUT_PULLUP);
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;
dataToSend[0] = (analogRead(JoyX));
dataToSend[1] = (analogRead(JoyY));
dataToSend[2] = (digitalRead(Switchpin));
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("Joy X : ");
Serial.println(dataToSend[0]);
Serial.print("Joy Y : ");
Serial.println(dataToSend[1]);
Serial.print("Button : ");
Serial.println(dataToSend[2]);
Serial.println("========");
if (rslt)
{
Serial.println(" Acknowledge received");
}
else
{
Serial.println(" Tx failed");
}
}
//================
Receive code:
// SimpleRx - the slave or the receiver
// Modified by c. goulding (AKA groundfungus) to receive
// 2 joystick inputs and a switch state
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9 // **** change for your setup
#define CSN_PIN 10 // **** change for your setup
const byte thisSlaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};
RF24 radio(CE_PIN, CSN_PIN);
int dataReceived[3]; // this must match dataToSend in the TX
bool newData = false;
int xData = 0;
int yData = 0;
boolean switchState = true;
//===========
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 ");
xData = dataReceived[0];
yData = dataReceived[1];
switchState = dataReceived[2];
Serial.print("\nx pos ");
Serial.print(xData);
Serial.print(" y pos ");
Serial.print(yData);
Serial.print(" switch ");
Serial.println(switchState);
newData = false;
}
}