NANO DRONE EP3 : Connect +BARO+GYRO+GPS

 

Wiring

 

6DOF MPU-6050 3 Axis Gyro With Accelerometer Sensor Module For Arduino

MPU6050 :   https://www.banggood.com/custlink/3mvK5s3Gz8

 

GY-68 BMP180 Digital Barometric Pressure Sensor Board Module for for RC Drone FPV Racing Multi Rotor

BMP180 baro meter :  https://www.banggood.com/custlink/mvDvFNKK1d

GY GPS Module Board 9600 Baud Rate With Antenna For Arduino

GPS Module : https://www.banggood.com/custlink/DKvK5QKDfH

Code

This code not professional code for flight controller just example for learn how to add all sensor please under stand !!

Download from link below

https://drive.google.com/drive/folders/1LJNr3Zmuv7MkJ4mpGKmBya4CeUyqdhKT?usp=sharing

3018 Mini CNC Upload GRBL program for control Mini CNC

3018 3 แกนมินิ DIY เราเตอร์ CNC w/ 2500 มิลลิวัตต์โมดูลเลเซอร์ไม้แกะสลักตัดมิลลิ่งเครื่องแกะสลัก

https://sea.banggood.com/custlink/v3v3CBNov5

The first thing for my friend to do before order mini cnc is this machine have no program include in this package you have to in stall GRBL to control

GRBL you can download from Github   :   https://github.com/grbl/grbl

Procedure to include in Sketch  library

load grbl :  https://drive.google.com/file/d/1JuOf4wx2kM0PAe4spcfd4RDwVYe4qvQv/view?usp=sharing

 

Load grbl controller :

https://drive.google.com/file/d/1PYlI7p9kkXg_6zVRE7ezVeHauigKUK4L/view?usp=sharing

 

GRBL meaning

This table show example data when we install in the begining  this value machine can not run correctly have to adjust the important think that we need is the meaning of each parameter show in table below original information from

https://github.com/gnea/grbl/wiki/Grbl-v1.1-Configuration#—view-grbl-settings

Settings and sample values Description
$0=10 Step pulse, microseconds
$1=25 Step idle delay, milliseconds
$2=0 Step port invert, mask
$3=0 Direction port invert, mask
$4=0 Step enable invert, boolean
$5=0 Limit pins invert, boolean
$6=0 Probe pin invert, boolean
$10=1 Status report, mask
$11=0.010 Junction deviation, mm
$12=0.002 Arc tolerance, mm
$13=0 Report inches, boolean
$20=0 Soft limits, boolean
$21=0 Hard limits, boolean
$22=1 Homing cycle, boolean
$23=0 Homing dir invert, mask
$24=25.000 Homing feed, mm/min
$25=500.000 Homing seek, mm/min
$26=250 Homing debounce, milliseconds
$27=1.000 Homing pull-off, mm
$30=1000. Max spindle speed, RPM
$31=0. Min spindle speed, RPM
$32=0 Laser mode, boolean
$100=250.000 X steps/mm
$101=250.000 Y steps/mm
$102=250.000 Z steps/mm
$110=500.000 X Max rate, mm/min
$111=500.000 Y Max rate, mm/min
$112=500.000 Z Max rate, mm/min
$120=10.000 X Acceleration, mm/sec^2
$121=10.000 Y Acceleration, mm/sec^2
$122=10.000 Z Acceleration, mm/sec^2
$130=200.000 X Max travel, mm
$131=200.000 Y Max travel, mm
$132=200.000 Z Max travel, mm

 

How to change GRBL parameter

Optimize GRBL set up for 3810 GRBL mini CNC

$0=10
$1=25
$2=0
$3=5
$4=0
$5=0
$6=0
$10=3
$11=0.010
$12=0.002
$13=0
$20=0
$21=0
$22=0
$23=0
$24=25.000
$25=500.000
$26=250
$27=1.000
$30=1000
$31=0
$32=0
$100=800.000
$101=800.000
$102=800.000
$110=2500.000
$111=2000.000
$112=1500.000
$120=20.000
$121=20.000
$122=10.000
$130=300.000
$131=200.000
$132=44.000

 

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");
}
} 
}




MIT Inventor application control robot using WiFi

 

VDO

 

Code

#include <ESP8266WiFi.h>

/* define port */
WiFiClient client;
WiFiServer server(80);

/* WIFI settings */
const char* ssid = "your wifi";
const char* password = "wifi password";

/* connect WiFi*/

/* data received from application */
String  data =""; 

/* define L298N or L293D motor control pins */
int leftMotorForward = 2;     /* GPIO2(D4) -> IN3   */
int rightMotorForward = 15;   /* GPIO15(D8) -> IN1  */
int leftMotorBackward = 0;    /* GPIO0(D3) -> IN4   */
int rightMotorBackward = 13;  /* GPIO13(D7) -> IN2  */


/* define L298N or L293D enable pins */
int rightMotorENB = 14; /* GPIO14(D5) -> Motor-A Enable */
int leftMotorENB = 12;  /* GPIO12(D6) -> Motor-B Enable */

void setup()
{

  Serial.begin(9600);
  
  /* initialize motor control pins as output */
  pinMode(leftMotorForward, OUTPUT);
  pinMode(rightMotorForward, OUTPUT); 
  pinMode(leftMotorBackward, OUTPUT);  
  pinMode(rightMotorBackward, OUTPUT);

  /* initialize motor enable pins as output */
  pinMode(leftMotorENB, OUTPUT); 
  pinMode(rightMotorENB, OUTPUT);

  /* start server communication */
  connectWiFi();
  server.begin();
}

void loop()
{
    /* If the server available, run the "checkClient" function */  
    client = server.available();
    if (!client) return; 
    data = checkClient ();

/************************ Run function according to incoming data from application *************************/

    /* If the incoming data is "forward", run the "MotorForward" function */
    if (data == "forward") MotorForward();
    /* If the incoming data is "backward", run the "MotorBackward" function */
    else if (data == "backward") MotorBackward();
    /* If the incoming data is "left", run the "TurnLeft" function */
    else if (data == "left") TurnLeft();
    /* If the incoming data is "right", run the "TurnRight" function */
    else if (data == "right") TurnRight();
    /* If the incoming data is "stop", run the "MotorStop" function */
    else if (data == "stop") MotorStop();

    Serial.println(data);
} 

/********************************************* FORWARD *****************************************************/
void MotorForward(void)   
{
  digitalWrite(leftMotorENB,HIGH);
  digitalWrite(rightMotorENB,HIGH);
  digitalWrite(leftMotorForward,HIGH);
  digitalWrite(rightMotorForward,HIGH);
  digitalWrite(leftMotorBackward,LOW);
  digitalWrite(rightMotorBackward,LOW);
}

/********************************************* BACKWARD *****************************************************/
void MotorBackward(void)   
{
  digitalWrite(leftMotorENB,HIGH);
  digitalWrite(rightMotorENB,HIGH);
  digitalWrite(leftMotorBackward,HIGH);
  digitalWrite(rightMotorBackward,HIGH);
  digitalWrite(leftMotorForward,LOW);
  digitalWrite(rightMotorForward,LOW);
}

/********************************************* TURN LEFT *****************************************************/
void TurnLeft(void)   
{
  digitalWrite(leftMotorENB,HIGH);
  digitalWrite(rightMotorENB,HIGH); 
  digitalWrite(leftMotorForward,LOW);
  digitalWrite(rightMotorForward,HIGH);
  digitalWrite(rightMotorBackward,LOW);
  digitalWrite(leftMotorBackward,HIGH);  
}

/********************************************* TURN RIGHT *****************************************************/
void TurnRight(void)   
{
  digitalWrite(leftMotorENB,HIGH);
  digitalWrite(rightMotorENB,HIGH);
  digitalWrite(leftMotorForward,HIGH);
  digitalWrite(rightMotorForward,LOW);
  digitalWrite(rightMotorBackward,HIGH);
  digitalWrite(leftMotorBackward,LOW);
}

/********************************************* STOP *****************************************************/
void MotorStop(void)   
{
  digitalWrite(leftMotorENB,LOW);
  digitalWrite(rightMotorENB,LOW);
  digitalWrite(leftMotorForward,LOW);
  digitalWrite(leftMotorBackward,LOW);
  digitalWrite(rightMotorForward,LOW);
  digitalWrite(rightMotorBackward,LOW);
}

/********************************** RECEIVE DATA FROM the APP ******************************************/
String checkClient (void)
{
  while(!client.available()) delay(1); 
  String request = client.readStringUntil('\r');
  request.remove(0, 5);
  request.remove(request.length()-9,9);
  return request;
}

void connectWiFi()
{
  Serial.println("Connecting to WIFI");
  WiFi.begin(ssid, password);
  while ((!(WiFi.status() == WL_CONNECTED)))
  {
    delay(300);
    Serial.print("..");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("NodeMCU Local IP is : ");
  Serial.print((WiFi.localIP()));
}




Firebase + Arduino + Multi Input/Output

ESP8266 Node MCU : https://goo.gl/fmXdoB

 

 

Part#1

Load Fire base library for Arduino from link below
https://github.com/firebase/firebase-arduino

Add Fire base Zip file to Arduino Library

Make sure you add successfull

 

Part#2 Firebase server configuration

1. Search google : firebase

 

Code

Code from IDE sketch

File >> Example >> FirebaseArduino

// Copyright 2015 Google Inc.//// Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at////     http://www.apache.org/licenses/LICENSE-2.0//// Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License.//
// FirebaseRoom_ESP8266 is a sample that demo using multiple sensors// and actuactor with the FirebaseArduino library.


#include <ESP8266WiFi.h>#include <FirebaseArduino.h>


#define FIREBASE_HOST "example.firebaseio.com"
#define FIREBASE_AUTH "token_or_secret"
#define WIFI_SSID "SSID"
#define WIFI_PASSWORD "PASSWORD"
const int grovePowerPin = 15;
const int vibratorPin = 5;
const int lightSensorPin = A0;
const int ledPin = 12;const int buttonPin = 14;
const int fanPin = 13;


void setup() 

{  Serial.begin(9600);
  pinMode(grovePowerPin, OUTPUT);  
digitalWrite(grovePowerPin, HIGH);
  pinMode(vibratorPin, OUTPUT);  
pinMode(lightSensorPin, INPUT); 
 pinMode(ledPin, OUTPUT);  
pinMode(buttonPin, INPUT); 
 pinMode(fanPin, OUTPUT);
 

 // connect to wifi.  
WiFi.begin(WIFI_SSID, WIFI_PASSWORD); 
 Serial.print("connecting");  
while (WiFi.status() != WL_CONNECTED)
{Serial.print(".");    delay(500);  } 
Serial.println();  Serial.print("connected: "); 
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);  Firebase.set("pushbutton", 0);  
Firebase.set("sunlight", 0); 
 Firebase.set("redlight", 0);  
Firebase.set("cooldown", 0); 
 Firebase.set("brrr", 0);}
int button = 0;float light = 0.0;

void loop() 

{  

digitalWrite(ledPin, Firebase.getInt("redlight")); 
 digitalWrite(fanPin, Firebase.getInt("cooldown"));  
digitalWrite(vibratorPin, Firebase.getInt("brrr"));  
int newButton = digitalRead(buttonPin); 


 if (newButton != button) 
{    button = newButton;    
Firebase.setInt("pushbutton", button);  }  
float newLight = analogRead(lightSensorPin);  
if (abs(newLight - light) > 100) 
{    light = newLight;    F
irebase.setFloat("sunlight", light);  } 
(200);}



VDO