Home

Project idea

So, here we are with the final project. The idea of my project was simply that I will build a glove-shaped part that will control a drone wirelessly, meaning to move it through the motion of that part, up and down, left and right.

This idea is split into two parts:

  1. The transmitter part which contains an MPU6050 gyroscope accelerometer module which measures the position and orientation of controller. It also has on board the NRF24l01 wireless communication module (as transmitter), it will send the data sensed by the MPU6050 wirelessly to the other part which is mounted on the drone.
  2. The receiver part which is mounted on the drone. It has the NRF24l01 wireless communication module (as receiver).

3D model

At first I imagined it to be a glove, but then it developed to be like a disk. Here is the design made by Fusion 360.

It consists of three parts:

  1. The handle.
  2. The top.
  3. The bottom.

Here are the 3D printed parts:

Interfacing

Receiver circuit

First we deal with the reciever circuit, since it is simpler.

Here is the NRF24l01 module pinout, it works based on the SPI(Serial Peripheral Interface) communication.




Transmitter circuit

As I mentioned before, we are also using an NRF24l01 module in this part in addition to the gyroscope MPU6050 module.

We will only have different connections to the NRF24l01 because the transmitter circuit doesn't have arduino uno board, but my board.

Here are the connections:

Now the gyroscope. Here is the pinout of the MPU6050:

Here is the whole ciruit:

Programming

Transmitter

So first of all we have to include the Wire.h library for the gyroscope, the SPI.h, nRF24L01.h and the RF24.h libraries for the nrf24l01. Declare some variables that we'll need for the data.

Create an object for the RF24 wireless communication defining the CE and the CSN pins.

Define the address of the module, which will be the same on the receiver module part, which is the communication channel.

In the void setup we almost always start the serial monitor to check the data.

Start the I2C communication for the gyroscope (Wire.begin).

Then we have the setupMPU() function which we'll look at in a while.

For the nrf24l01 we also need to start the communication (radio.begin()). Set the address (radio.openWritingPipe(address)). Setting the PA level (radio.setPALevel(RF24_PA_MIN)), you just set it either MIN or MAX which one you need. Lastely (radio.stopListening()) to set the module as a transmitter.

In the void loop we're juct calling other functions. The sendData() function, as we'll see later, is for sending the gyroscope readings through the nrf24l01. The printData() is to show the data on the transmitter side, I just needed it while I was checking the code with arduino. And then of course we need to delay.

In the first function we'll set the parameters for the gyroscope. Before you make a change,

  1. you have first to access the right address of the nrf24l01.
  2. Then access the register you want to change.
  3. Then do the change, for that you need to look up the datasheet.
  4. Then end the access to the nrf24l01.

Here we are getting the accelerometer readings and doing some calibrations.

Here we are getting the gyroscope readings and doing some calibrations.

In the printData() function we're printing the data on the trasmitter side.

In the sendData() function we're sending the data through the nrf24l01 module to the receiver.



Receiver

Starting with including the same libraires except the Wire.h, since we don't have a gyroscope here.

Declaring the same variables to hold the data.

Define the nrf24l01 object with the same CE and CSN pins.

Define the same address of the transmitter.

In the void setup() we start the serial communication, since we need to show the data on the serial monitor. Start the wireless communication, set the address, set the PA leve, and then set as a receiver (startListening()).

In the void loop() we start with (if (radio.available())) to see if there is any data coming to the receiver module, and if there is then read it.

Here we're just printing the data through the serial monitor.

Readings

Here I was just testing the transmission between the two arduinos by sending just a number.

Here are the gyroscope data on the receiver side.