NRF24L01 Wireless make flight controller

 

https://www.banggood.com/custlink/vKG3CE240H

1100 Meter Long Distance NRF24L01+PA+LNA Wireless Module With Antenna

Features:

NRF24L01P + PA + LNA Division for the ultra-long-distance data transmission, specially developed high-power and high sensitivity wireless module 2.4G ISM band NRF24L01P + PA + LNA wireless module to work in the license-free that can be point-to-point applications or be composed of a star network.
Digital transmission chip NRF24L01+ with the Division of Professional Design professional full two-way RF power amplifier high power PA and LNA chip, RF switches and band pass filters, makes effective communication distance greatly expand.
RF part, it has been done a lot of optimization matching debugging. The emission efficiency to achieve the highest harmonic minimum and make NRF24L01P + PA + LNA wireless module of RF interference to the external equipment reaches minimum, while not susceptible to interference from other devices.

NRF24L01P + PA + LNA wireless module integration is extremely high, the size is 41mm x 15.5mm to make conveniently embedded.

Description:
Voltage: 3-3.6V
Max output power: +20 dBm
Working current in transmit mode: 115mA
Working current in receiver mode: 45mA
Current in    mode: 4.2uA
Operating temperature: -20-70 degree
Receiver sensitivity: -92dBm in 2Mbps mode, -95dBm in 1Mbps mode, -104dBm in 250kbps mode
PA growth: 20dB
LAN growth: 10dB
LAN noise figure: 2.6dB
Antenna growth: 2dBI
2M rate: 520m

 

1100 Meter Long Distance NRF24L01+PA+LNA Wireless Module With Antenna

,

 

NRF24L01 -> Arduino

  • Vcc -> 3.3V   (5 V will kill immediately !!!)
  • Gnd -> Gnd
  • CSN -> 10
  • CE -> 8
  • MOSI -> 11
  • SCK -> 13
  • MISO -> 12

 

Plane receive all wiring

Part receive schematic

 

 

Motor drive

Q1,Q2, Transistor use NPN BD139  can take 3 amp but as I mention the surface mounting type would be better

 

Remote control side

 

 

CODE

Library need for this project

RHReliableDatagram : https://goo.gl/UJbziK

Remote  TX

 

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

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

// Define Joystick Connections
#define joyVert A0 
#define joyHorz A2

// Define Joystick Values - Start at 512 (middle position)
int joyposVert = 512;
int joyposHorz = 512;

// 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 motorcontrol array
// 2 Bytes for motor speeds plus 1 byte for direction control
uint8_t motorcontrol[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");

// Set initial motor direction as forward
motorcontrol[2] = 0;

}

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

// Read the Joystick X and Y positions
joyposVert = analogRead(joyVert); 
joyposHorz = analogRead(joyHorz);

// Determine if this is a forward or backward motion
// Do this by reading the Verticle Value
// Apply results to MotorSpeed and to Direction

if (joyposVert < 0)
{
// This is Backward
// Set Motors backward
motorcontrol[2] = 1;

//Determine Motor Speeds
// As we are going backwards we need to reverse readings
motorcontrol[0] = map(joyposVert, 0, 1023, 0, 255);
motorcontrol[1] = map(joyposVert, 0, 1023, 0, 255);

}
else if (joyposVert > 1)
{
// This is Forward
// Set Motors forward
motorcontrol[2] = 0;

//Determine Motor Speeds
motorcontrol[0] = map(joyposVert, 0, 1023, 0, 255);
motorcontrol[1] = map(joyposVert, 0, 1023, 0, 255); 

}
else
{
// This is Stopped
motorcontrol[0] = 0;
motorcontrol[1] = 0;
motorcontrol[2] = 0; 

}

// Now do the steering
// The Horizontal position will "weigh" the motor speed
// Values for each motor

if (joyposHorz < 460)
{
// Move Left
// As we are going left we need to reverse readings
// Map the number to a value of 255 maximum
joyposHorz = map(joyposHorz, 460, 0, 0, 255);

motorcontrol[0] = motorcontrol[0] - joyposHorz;
motorcontrol[1] = motorcontrol[1] + joyposHorz;

// Don't exceed range of 0-255 for motor speeds
if (motorcontrol[0] < 0)motorcontrol[0] = 0;
if (motorcontrol[1] > 255)motorcontrol[1] = 255;

}
else if (joyposHorz > 564)
{
// Move Right
// Map the number to a value of 255 maximum
joyposHorz = map(joyposHorz, 564, 1023, 0, 255);

motorcontrol[0] = motorcontrol[0] + joyposHorz;
motorcontrol[1] = motorcontrol[1] - joyposHorz;

// Don't exceed range of 0-255 for motor speeds
if (motorcontrol[0] > 255)motorcontrol[0] = 255;
if (motorcontrol[1] < 0)motorcontrol[1] = 0; 

}

// Adjust to prevent "buzzing" at very low speed
if (motorcontrol[0] < 8)motorcontrol[0] = 0;
if (motorcontrol[1] < 8)motorcontrol[1] = 0;

//Display the Motor Control values in the serial monitor.
Serial.print("Motor A: ");
Serial.print(motorcontrol[0]);
Serial.print(" - Motor B: ");
Serial.print(motorcontrol[1]);
Serial.print(" - Direction: ");
Serial.println(motorcontrol[2]);

//Send a message containing Motor Control data to manager_server
if (RadioManager.sendtoWait(motorcontrol, sizeof(motorcontrol), 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
}

 

Plane RX

// 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

// Motor A Connections
int motorA = 3;


// Motor B Connections
int motorB = 5;


// 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);

// Set all the motor control pins to outputs
pinMode(motorA, OUTPUT);
pinMode(motorB, OUTPUT);


// 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(": MotorA = ");
Serial.print(buf[0]);
Serial.print(" MotorB = ");
Serial.print(buf[1]);
Serial.print(" Dir = ");
Serial.println(buf[2]);




// Drive Motors
analogWrite(motorA, buf[1]);
analogWrite(motorB, buf[0]);

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




Dust + Humidity+temperature control IOT Blynk app + SSD1306 OLED display

Equipment

ESP8266 Node MCU : https://sea.banggood.com/custlink/D3vDysMjrj

OLED Display    : https://sea.banggood.com/custlink/KmDGEQ2O9i

Temperature Humidity  :  https://sea.banggood.com/custlink/3KGGYQzl8A

Dust sensor : https://goo.gl/Bd3Edm

 

Wiring

 

VDO

If my blog help full for all of my friend a cup of coffee for me would be help full for keep this blog online to share good information to community.

 

Code

#include <Adafruit_Sensor.h>

/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest

Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.

Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp


Blynk library is licensed under MIT license
This example code is in public domain.

*************************************************************
qwert7yip0[p=]\
This example shows how value can be pushed from Arduino to
the Blynk App.

WARNING :
For this example you'll need Adafruit DHT sensor libraries:
https://github.com/adafruit/Adafruit_Sensor
https://github.com/adafruit/DHT-sensor-library

App project setup:
Value Display widget attached to V5
Value Display widget attached to V6
*************************************************************/

// www.a-arduino.com

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include <SPI.h>

#include<ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

#include <DHT.h>


//////////oled display

#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"`

//////////////


// TimeClient settings


/*Dust sensor

*/
int measurePin = A0;
int ledPower = D6;

unsigned int samplingTime = 280;
unsigned int deltaTime = 40;
unsigned int sleepTime = 9680;

float voMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;

SSD1306 display(0x3c, D3, D4);

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "970a60d64416434c8e37cbc85efdbd5f";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "oppo";
char pass[] = "santi136";

#define DHTPIN D5 // What digital pin we're connected to GPIO14

// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);

/******************
* Dust
*****************/
digitalWrite(ledPower,LOW);
delayMicroseconds(samplingTime);

voMeasured = analogRead(measurePin);

delayMicroseconds(deltaTime);
digitalWrite(ledPower,HIGH);
delayMicroseconds(sleepTime);

calcVoltage = voMeasured*(3.0/1024);
dustDensity = 0.17*calcVoltage-0.1;

if ( dustDensity < 0)
{
dustDensity = 0.00;
}

Serial.println("temp:");
Serial.println(t);

Serial.println("Humi:");
Serial.println(h);

Serial.println("Raw Signal Value (0-1023):");
Serial.println(voMeasured);

Serial.println("Voltage:");
Serial.println(calcVoltage);

dustDensity = dustDensity*1000 ;

Serial.println("Dust Density micro gram/m^3:");
Serial.println(dustDensity);


Blynk.virtualWrite(V7,dustDensity);

///////////////////////////////

display.clear();
display.drawString(0, 16, String(t)+"C\t" + String(h) + "%\t"); 
//display.drawString(0, 16, "" + String(t) + "C"); 
display.drawString(0, 32, "Dust: " + String(dustDensity) + "ug/m^3"); 
delay(1000);
}

void setup()
{
// Debug console
Serial.begin(9600);

Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

dht.begin();

// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);


pinMode(ledPower,OUTPUT);


///////////////

display.init();

display.flipScreenVertically();
display.setFont(ArialMT_Plain_16);
display.setTextAlignment(TEXT_ALIGN_LEFT);
dht.begin(); // initialize dht
}

void loop()
{
Blynk.run();
timer.run();
display.display();
}