DESIGNED & ENGINEERED IN LONDON, UK

© 2019 Creoqode

In this chapter of the Educational Guide to Nova, we will be using the nRF24L01 WiFi module in order to control Nova wirelessly. nRF24L01 is a highly integrated, ultra low power 2Mbps RF transceiver module for the 2.4GHz band. With peak RX/TX currents lower than 14mA, this module is very efficient and affordable.

You can easily purchase this module on many online platforms including Ebay and Amazon. Additionally, we will need another Arduino board (any model would work) and some jumper wires.

 

nRF24L01 runs on 3.3V, but this module normally comes with an additional circuit board which also accommodates a voltage regulator allowing users to supply 5V as well. We will need 2 of these modules as shown in the below picture. One module will be used as a transceiver, the other module will be used as a receiver, and the additional circuit boards will be used for wiring.

If you decide not to use the additional circuit boards, make sure you provide 3.3V to the module! Otherwise you will damage the IC.

 

 

Let's start by removing the front panel of Nova that covers the joysticks and part of Creoqode Mini Mega. While connecting this module to Mini Mega, we will need to use the SPI pins and they are not available through the Nova servo shield.

 

 

 

You can see below which pins of the Wifi module needs to be connected to which pins of the Mini Mega. 

 

 

 

nRF24L01

 

GND

VCC

CE

CSN

SCK

MOSI

MISO

IRQ

 

 

Creoqode Mini Mega

 

GND

5V

4

6

52

51

50

Not in use (leave empty).

 

 

First, connect VCC to 5V, and GND to GND. As said earlier, make sure you are using the additional circuit board with the voltage regulator if you are supplying 5V.

 

 

 

Then, make rest of the connections as shown in the table above. For SPI connections, which are SCK, MOSI and MISO, you can either use ICSP pins of ATmega2560, or simply use the pins 50, 51 and 52 of Mini Mega. They are the same.

 

 

 

Finally, attach the nRF24L01 to the circuit board we have wired, and mount the front panel of Nova back in its place. Wifi module fits nicely between the casing panels of Nova, so you can hide it nicely. 

 

 

 

Since we are done with Nova, we have to do the same wiring between the other Arduino board you will be using and the other nRF24L01. Depending on the Arduino board you use, SPI pins will be different. You can see below the assigned pins for SCK, MOSI and MISO in various Arduino boards.

 

 

 

That's it! Now we have connected a nRF24L01 to Nova (to use it as a receiver) and another nRF24L01 to the other Arduino board (to use it as transceiver).

Before we open Arduino IDE, we need to download the necessary library by clicking here, or through the link below:

 

https://github.com/maniacbug/RF24

D

Download the library by clicking the green button on top right corner in the link and select "download zip". Uncompress the downloaded .zip file. Create two new folders under Arduino's library folder, and name one of them as "RF24" and the other one as "nRF24L01". From the uncompressed library folder, copy "nRF24L01.h" to the folder "nRF24L01". Again from the same uncompressed library folder, copy "nRF24L01.h, RF24.cpp, RF24.h and RF24_config.h" and paste these four files to the folder "RF24".

Now, open Arduino IDE and start by including the lines shown below. The first sketch we will be writing is the receiver sketch, which will be uploaded to Nova.

 

 

 

 

 

#include <Servo.h>
#include <SPI.h>        
//Communication interface with the modem
#include "RF24.h"       //Library to control the radio modem

Servo NovaServo_2;    //One servo will be used for this tutorial

 

RF24 radio(4,6);           //Defines pins assigned for CE and CSN

const uint64_t pipe = 0xE8E8F0F0E1LL;        //the address of the modem

int data[1];                  //Array that the received data is stored

int x = 0;          

The above lines need to be placed before the setup() function. Pay attention that the array defined above, "data[1]", has only one integer to store. For this tutorial, we will be sending a single data from the transmitter Arduino to Nova in order to control only one servo.

 

 

 

 

 

 

 

NovaServo_2.attach(34);

  

radio.begin();                                       //Activate modem
radio.openReadingPipe(1, pipe);      //Determine comm. channel
radio.startListening();                        //Receive data via modem

         

The above lines need to be placed in the setup() function. We are activating the Wifi module, determining which communication channel (pipe) it will use, and starting the module to look for available data.

 

 

 

 

 

 

 

if(radio.available()){             //Checks whether data is received
    bool done = false;            //Returns "true" if data is received
    while (!done) {
        done = radio.read(data, sizeof(data));
     
if(data[0] == 1){
    x++;
    delay(30);}

if(data[0] == 2){
    x--;
    delay(30);}
 
NovaServo_2.write(90 + x);
    }
}

         

The above lines need to be placed in the loop() function. We are first checking if there is data available to receive. If this is true, we are receiving the data and saving it into the first (and only) element of the array we previously defined, "data[0]". Then, according to the data received, we are moving Nova's head accordingly.

That's it for Nova! The above code lines are for the receiving module for this tutorial. Upload this sketch to Nova, and then connect the other Arduino board your computer. We will start programming the transmitter module now.

 

 

 

 

 

 

 

#include <SPI.h>          //Communication interface with the modem
#include "RF24.h"        //Library to control the radio modem

 

RF24 radio(4,6);            //Defines pins assigned for CE and CSN
                                     
const uint64_t pipe = 0xE8E8F0F0E1LL;         
//the address of the modem

int data[1];

int button1 = 7;            //Pins assigned for buttons
int button2 = 8;

int button1_state;         //Variables to save the state of buttons
int button2_state;

         

The above lines need to be placed before the setup() function. For this tutorial, we will use two switches (any switch would work, and if you do not have a switch you can use a jumper wire as well) for this tutorial.

 

 

 

 

 

 

 

  radio.begin();                               //Activate modem
  radio.openWritingPipe(pipe);      //Determine comm. channel

  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);

         

The above lines need to be placed in the setup() function. By defining pin modes as INPUT_PULLUP's, we are avoiding the need of an additional resistor when connecting the switches/buttons. This function enables the usage of internal pull up resistors.

 

 

 

 

 

 

 

data[0] = 0;

button1_state = digitalRead(button1);
button2_state = digitalRead(button2);

if(button1_state == LOW)   data[0] = 1;
if(button2_state == LOW)   data[0] = 2;

 

radio.write(data, sizeof(data));

 

delay(5);

         

The above lines need to be placed in the loop() function. We are simply sending data via the Wifi module. If the data sent is 0, nothing happens. If the data sent is 1, we are increasing the angle of the servo shaft of Nova. If the data sent is 2, we are decreasing the angle of the servo shaft of Nova.

You can simply connect any switch or button with one terminal attached to digital pin 7, and the other to GND. Similarly, one terminal of the other switch to digital pin 8, and the other terminal to GND. If you do not have switches to use for this tutorial, connect one end of a jumper wire to GND and touch with the other end of the jumper wire to digital pin 7 and digital pin 8 as you want to move Nova.

When the transmitting Arduino board reads LOW for digital pin 7 or digital pin 8 (when they are connected to GND), it will send the data to Nova telling it how to move the servo shaft.

That's it! Now you can control your Nova wirelessly through another Arduino board.