nRF24L01 Wireless Joystick transmitter and receiver module

Hello, I have a rc 7 channel transmitter that I took the electronics out of it and only left the joysticks, the potentiometer, and the 2 toggle switches. Im only working with the joysticks for now but I'm trying to put an Arduino nano into the transmitter and an nRF24L01 module with an antenna. The receiver will have an Arduino Nano, the nRF24L01, and some Male pin headers to plug in a brushless esc and motor. I followed this tutorial (link below) by Drone Bot Workshop and I am currently on the Receiver and Transmitter DEMO Code and I have the correct pin connections and program, but for some reason, the code values that are displayed on the serial monitor dont change when i move the joysticks like they should?
->Link to Drone Bot workshop Project: nRF24L01 Wireless Joystick for Arduino Robot Car | DroneBot Workshop
Basically, I uploaded these programs(the transmitter demo to the transmitter, and the receiver demo to the receiver) and connected the wires correctly to the arduino nano for both the transmitter and receiver but the joystick values are not changing when I move the joysticks.

Transmitter code I am currently using: /*
nRF24L01+ Joystick Transmitter
nrf24l01-joy-xmit-demo.ino
nRF24L01+ Transmitter with Joystick
Use with Joystick Receiver Demo
DroneBot Workshop 2018
https://dronebotworkshop.com
*/

// Include RadioHead ReliableDatagram & NRF24 Libraries
#include <RHReliableDatagram.h>
#include <RH_NRF24.h>

// Include dependant SPI Library
#include <SPI.h>

// Define Joystick Connections
#define JoyStick_X_PIN A0
#define JoyStick_Y_PIN A1

// Define addresses for radio channels
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

// Create an instance of the radio driver
RH_NRF24 RadioDriver;

// Sets the radio driver to NRF24 and the client address to 1
RHReliableDatagram RadioManager(RadioDriver, CLIENT_ADDRESS);

// Declare unsigned 8-bit joystick array
uint8_t joystick[3];

// Define the Message Buffer
uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];

void setup()
{
// Setup Serial Monitor
Serial.begin(9600);

// Initialize RadioManager with defaults - 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!RadioManager.init())
Serial.println("init failed");
}

void loop()
{
// Print to Serial Monitor
Serial.println("Reading joystick values ");

// Read Joystick values and map to values of 0 - 255
joystick[0] = map(analogRead(JoyStick_X_PIN), 0, 1023, 0, 255);
joystick[1] = map(analogRead(JoyStick_Y_PIN), 0, 1023, 0, 255);
joystick[2] = 100;

//Display the joystick values in the serial monitor.
Serial.println("-----------");
Serial.print("x:");
Serial.println(joystick[0]);
Serial.print("y:");
Serial.println(joystick[1]);

Serial.println("Sending Joystick data to nrf24_reliable_datagram_server");

//Send a message containing Joystick data to manager_server
if (RadioManager.sendtoWait(joystick, sizeof(joystick), SERVER_ADDRESS))
{
// Now wait for a reply from the server
uint8_t len = sizeof(buf);
uint8_t from;
if (RadioManager.recvfromAckTimeout(buf, &len, 2000, &from))
{
Serial.print("got reply from : 0x");
Serial.print(from, HEX);
Serial.print(": ");
Serial.println((char*)buf);
}
else
{
Serial.println("No reply, is nrf24_reliable_datagram_server running?");
}
}
else
Serial.println("sendtoWait failed");

delay(100); // Wait a bit before next transmission
}

Receiever Code I am currently using:

/*
nRF24L01+ Joystick Receiver Demo
nrf24l01-joy-rcv-demo.ino
nRF24L01+ Receiver with Joystick Decode
Use with Joystick Transmitter Demo
DroneBot Workshop 2018
https://dronebotworkshop.com
*/

// Include RadioHead ReliableDatagram & NRF24 Libraries
#include <RHReliableDatagram.h>
#include <RH_NRF24.h>

// Include dependant SPI Library
#include <SPI.h>

// Define addresses for radio channels
#define CLIENT_ADDRESS 1
#define SERVER_ADDRESS 2

// Create an instance of the radio driver
RH_NRF24 RadioDriver;

// Sets the radio driver to NRF24 and the server address to 2
RHReliableDatagram RadioManager(RadioDriver, SERVER_ADDRESS);

// Define a message to return if values received
uint8_t ReturnMessage = "JoyStick Data Received";

// Define the Message Buffer
uint8_t buf[RH_NRF24_MAX_MESSAGE_LEN];

void setup()
{
// Setup Serial Monitor
Serial.begin(9600);

// Initialize RadioManager with defaults - 2.402 GHz (channel 2), 2Mbps, 0dBm
if (!RadioManager.init())
Serial.println("init failed");
}

void loop()
{
if (RadioManager.available())
{
// Wait for a message addressed to us from the client
uint8_t len = sizeof(buf);
uint8_t from;
if (RadioManager.recvfromAck(buf, &len, &from))
//Serial Print the values of joystick
{
Serial.print("got request from : 0x");
Serial.print(from, HEX);
Serial.print(": X = ");
Serial.print(buf[0]);
Serial.print(" Y = ");
Serial.print(buf[1]);
Serial.print(" Z = ");
Serial.println(buf[2]);

  // Send a reply back to the originator client, check for error
  if (!RadioManager.sendtoWait(ReturnMessage, sizeof(ReturnMessage), from))
    Serial.println("sendtoWait failed");
}

}
}

This is a picture of the transmitter that I’m using and of the receiver so far
Receiver:


Transmitter:

If anyone could help me to realize why the joystick value isnt changing, that would be great! Thanks!

Did you confirm the voltage at the analog input pin?

What do you mean by that? Is there an analog input pin on the Arduino nano? And do I confirm the analog input pin on the program? Thanks!

I might understand. Do you mean did I come y the 5V wire from the 4 joystick potentiometers to the Arduino? If that is what you mean, I did not do that. The controller that I have has 1 wire on each pot used for the analog pin, and the other wire is the ground(I’m pretty sure) that connects all the ground wires from the 4 pots and plugs into ground on the Arduino.

There is so much ambiguity in verbal descriptions. Circuits are so critical and interdependent that even one small connection can make or break it. So schematics are a requirement for any useful analysis. You see, everything you say could be perfectly accurate, but one missing piece that you took for granted or didn't know about, could be the key to solving the problem. So we need a drawing.

Originally, I was suggesting measuring the voltage on one of the analog pins, such as A0. That would be done with a multimeter or scope. It would help decide on which side of it, the problem lives.

The idea is to get some confirmation that the potentiometer circuit actually works. That would be along with taking ADC readings and comparing with the measured voltages. Although, the answer will probably jump out before you spend much time on that. If the voltage (like say 1/2 Vcc for the mid pot setting) is measured right at the Arduino board input pin, it's good, and you still get bad readings in software, well then it's a software problem or the chip is blown.

BUT! you are replacing that controller with an Arduino, I believe. One end of the pots are ground and the other end MUST be connected to 5 volts, so when you change the pot, you change the voltage going to the analog pin on the Arduino.
Paul

1 Like

I will provide you with a schematic drawing tomorrow and thank you all!! I don’t know if you can answer this with out a schematic but how do I know which pin on the potentiometer is positive, negative, and signal? Thanks

Use a digital multimeter set on an ohms range. Set the potentiometer to approximately the middle position. Measure the resistance between each combination of two pins (there are 3 such combinations). The two pins which have the highest resistance between them are the two poles. The other pin is the wiper which you have called the “signal” pin. Usually the wiper is the “middle” pin. Turn the potentiometer to the “minimum” position and measure the resistance between (a) the wiper and (b) each pole. The negative pole has the lowest resistance between it and the wiper.

I wrote a simple RC control program, as it happens for LoRa.

The first program I wrote was a test program that read the joysticks and displayed the values read on the serial monitor.

I did not carry on with the rest of the program till I had the joystick test program working.

Starting with a very large program that 'does it all' and wondering why it does not work, is rarely a good idea.

Another way is to read the specification sheet. Believe it or not, they do exist even for a humble potentiometer (because they are used in commercial products).

I will try that! Thanks!! Since I don’t have a multimeter, I left the potentiometer pins as they came and one of the end pins are the “signal” (wiper) pin while the middle pin is the gnd and the other end pin is open and has no wires. I will still draw a schematic and post some pictures soon!

That sounds weird. Are they linear action pots (sliders)? What do you mean you left the pot pins "as they came"? How did they come? Aren't they in an unknown circuit?

This is what I mean. This picture below is of the potentiometers on the joysticks and you are right, it is an unknown circuit because I took the electronics out of the transmitter. So these are the potentiometers.

Potentiometer:


*the red wire connects all of the middle pins of each pot, and the white wire underneath goes to gnd. The brown wire next to it is the analog pin and the open pin I would assume is the 5V pin but idk.

I have not changed anything between the pit wires. The solder placement is exactly where it was when I took apart the transmitter.

All 4 pots:


*As you can see, all 4 pots are connected via the red wire in the middle pin, and they all have an open pin on the outside

What you have to do, is apply a fixed voltage (like +5V) to the unconnected pins of the potentiometers.

Their circuit is a little "goofy". Usually the end pins would be common, not the center pins. You will have to change that.

That is also what I’m thinking. I will apply 5V to one of the open pins, than write a simple joystick case that will display the value than see if the 5V voltage helps me see the value change. If so, I will solder a wire to all of the open pins! Thank you!!

Yes, but... the way they are currently connected is incorrect for your circuit. You need to connect all the presently wired end pins together and ground them, connect all the open end pins to 5V, and run each center pin to an Arduino input.

In order to do that, some of the existing wires have to come off.

1 Like

Yeah, thank you!

Is this what you mean by changing the wiring?

-how it currently is:

-new version with wire changes:

Almost. You can't just relabel the "analog" one between the two sticks in the second drawing, it's two separate wires, not one. But, basically, you have it correct.

Get one. It will save hours of grief and usable ones are dirt cheap on Aliexpress etc:

1 Like