Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 |
Created for an Arduino-based drone, the Pilot RC has headers for the common nRF24L01+ modules that can give you range of up to 1,100 meters! The onboard joysticks are the same as the ones in an Xbox 360 controller, and the board has a built-in voltage sensor to measure battery voltage! There is also an LCD header that allows you to plug in your LCD Screen and receive live telemetry from your project! We were initially a project that was funded on Kickstarter, and we now want to share our open source design with the community!
Interested in learning how to code for wireless communication, LCD screens, joysticks, or voltage sensors? We have detailed tutorials available on our website as well!
Simple Transmit Code
ArduinoThis is the code to transmit Wireless Information with the Arduino and the NRF24L01+ module. This code uses the RF24 Library.
/* Simple Transmit Version 1.02
* Author: Schindler Electronics
* Data: 6/1/2019
*
* This code demonstrates how to use the NRF module to
* transmit simple data to another NRF module.
*
* Note: This code requires another Arduino receiving data
* from another NRF module using the Simple_Recieve Sketch
*
* Note: This code requires the use of the RF24 Library.
* You can easily download this library in the Arduino Library Manager.
*
* Changes: The code now transmits the values of the joysticks rather
* than fixed values.
*/
#include <SPI.h> //Comes with Arduino IDE
#include "RF24.h" //Download and Install (See above)
#define CE_PIN 7 //The pins to be used for CE and CSN
#define CSN_PIN 8
RF24 radio(CE_PIN, CSN_PIN);
byte addresses[][6] = {"1Node", "2Node"}; //These will be the names of the "Pipes"
struct dataStruct { //this is the NRF data. Max of 32 bytes
int Xposition; //int = 2 bytes
int Yposition; //double = 4 bytes
bool switchOn; //boolean = 1 byte
int X2position;
int Y2position;
bool switch2On;
} myData; //This can be accessed in the form: myData.Xposition etc.
void setup() {
Serial.begin(115200);
pinMode(5, OUTPUT); //Set up the Joysticks
pinMode(4, OUTPUT);
digitalWrite(5, HIGH);
digitalWrite(4, HIGH);
radio.begin(); //Initialize the nRF24L01 Radio
radio.setChannel(108); //Above most WiFi frequencies
radio.setDataRate(RF24_250KBPS); //Fast enough.. Better range
radio.setPALevel(RF24_PA_MIN); //This allows it to be used with only USB power. Use of RF24_PA_MAX requires battery connection
radio.openWritingPipe(addresses[0]); //Open a writing "Pipe" to send data out
radio.openReadingPipe(1, addresses[1]); //Open a reading "Pipe" to receive data
radio.stopListening(); //Stop Listening so we can start transmitting data
Serial.println("Set Up Complete");
}
void loop() {
//This is the values that will be transmitted in the myData Struct
myData.Xposition = analogRead(A0);
myData.Yposition = analogRead(A1);
myData.switchOn = digitalRead(5);
myData.X2position = analogRead(A2);
myData.Y2position = analogRead(A3);
myData.switch2On = digitalRead(4);
radio.write(&myData, sizeof(myData), 1); //Transmit Data using the write command
Serial.println("Sent");
delay(10);
}
Simple Receive
ArduinoThis is the code to receive wireless communication from the Arduino and the NRF24L01+ module.
/* Simple Recieve Version 1.02
* Author: Schindler Electronics
* Data: 6/1/2019
*
* This code demonstrates how to use the NRF module to
* receive simple data from another NRF module.
*
* Note: This code requires another Arduino transmitting data
* from another NRF module using the Simple_Transmit Sketch
*
* Note: This code requires the use of the RF24 Library.
* You can easily download this library in the Arduino Library Manager.
*/
#include <SPI.h> //Comes with Arduino IDE
#include "RF24.h" //Download and Install (See above)
#define CE_PIN 7 //The pins to be used for CE and CSN
#define CSN_PIN 8
RF24 radio(CE_PIN, CSN_PIN);
byte addresses[][6] = {"1Node", "2Node"}; //These will be the names of the "Pipes"
struct dataStruct { //this is the NRF data. Max of 32 bytes
int Xposition; //int = 2 bytes
int Yposition; //double = 4 bytes
bool switchOn; //boolean = 1 byte
int X2position;
int Y2position;
bool switch2On;
} myData; //This can be accessed in the form: myData.Xposition etc.
void setup() {
Serial.begin(115200);
radio.begin(); //Initialize the nRF24L01 Radio
radio.setChannel(108); //Above most WiFi frequencies (2.4Ghz + 0.108Ghz = 2.508Ghz)
radio.setDataRate(RF24_250KBPS); //Fast enough.. Better range
radio.setPALevel(RF24_PA_MIN); //This allows it to be used with only USB power. Use of RF24_PA_MAX requires battery connection
radio.openWritingPipe(addresses[1]); //Open a writing "Pipe" to send data out
radio.openReadingPipe(1, addresses[0]); //Open a reading "Pipe" to receive data
radio.startListening(); //Start listening for incoming data
}
void loop() {
if (radio.available()) {
radio.read( &myData, sizeof(myData) ); //If the NRF receives data on a Pipe read the data
Serial.print(myData.Xposition); Serial.print("\t"); //Print the data received
Serial.print(myData.Yposition); Serial.print("\t");
Serial.print(myData.switchOn); Serial.print("\t");
Serial.print(myData.X2position); Serial.print("\t");
Serial.print(myData.Y2position); Serial.print("\t");
Serial.print(myData.switch2On); Serial.print("\t");
Serial.println();
}
}
/* Joystick_Basic Version 1.01
* Author: Schindler Electronics
* Data: 5/23/2019
*
* This code reads the value of each joystick
* axis using the Analog Read function.
*
* Each value for the joystick range should from 0-1023.
* The push-buttons should read 0 when pushed and 1 when not pushed.
*
*/
void setup() {
Serial.begin(115200);
pinMode(5, OUTPUT); //Set the pins connected to the joystick button to an output
pinMode(4, OUTPUT);
digitalWrite(5, HIGH); //Set the pins to HIGH (5V). When the button is pressed it will pull the pin to ground (0V)
digitalWrite(4, HIGH);
}
void loop() {
Serial.print("Joystick L: ");
Serial.print(analogRead(A2)); //Read the Joystick value
Serial.print("\t");
Serial.print(analogRead(A3)); //Read the Joystick value
Serial.print("\t");
Serial.print(digitalRead(4)); //Read the Button value
Serial.print("\t");
Serial.print("Joystick R: "); //Read the Joystick value
Serial.print(analogRead(A0));
Serial.print("\t");
Serial.print(analogRead(A1)); //Read the Joystick value
Serial.print("\t");
Serial.print(digitalRead(5)); //Read the Button value
Serial.print("\t");
Serial.println();
delay(10);
}
/* Voltage Version 1.01
* Author: Schindler Electronics
* Data: 5/23/2019
*
* This code demostrates how to read the voltage
* applied to the Battery pins of the Pilot RC
*
* Note: This will display around 4.5 Volts when no battery is
* applied to the pins. This is because the pins are reading the
* voltage coming out of the 5V voltage regulator.
*/
float vPow = 5.0; //constant for calculations (5V devices)
float r1 = 49900; //Value of Resistor 1
float r2 = 10000; //Value of Resistor 2
float v, v2, vAvg, rcV, drV;
int vNum;
void setup() {
Serial.begin(115200);
}
void loop() {
v = (analogRead(A4) * vPow) / 1024.0; //Value of the voltage coming out of the voltage divider
v2 = v / (r2 / (r1 + r2)); //Actual voltage applied to the voltage divider (Battery Voltage)
vAvg += v2; //We want to average 100 readings of the battery voltage to achieve an accurate result
vNum++;
if (vNum == 100) { //Print the Voltage being read by the Pilot RC and reset the counters
rcV = vAvg/100;
Serial.print("Voltage: ");
Serial.println(rcV);
vNum=0;
vAvg=0;
}
delay(10);
}
Comments