Control ESPcopter With Processing

After the Getting Started With Processing phase, You can control ESPcopter with Processing, First of All, you need to install there library to Processing which is

1-) controlP5

2-) game control plus

3-)opencv

To code please contact with espcopter@gmail.com

How to Add Library:

 

 

 

How to Connect ESPcopter

Click to Connect

Start to Program

İf you have no gamepad. Return to false from İfconsol = True;

İf you have a Gamepad you need to do the some setting 

First select your gamepad

 

 

 

 

 

 

 

 

 

 


Getting Started With Processing

Getting Started

Welcome to Processing! Start by visiting http://processing.org/download and selecting the Mac, Windows, or Linux version, depending on what machine you have. Installation on each machine is straightforward:

  • On Windows, you'll have a .zip file. Double-click it, and drag the folder inside to a location on your hard disk. It could be Program Files or simply the desktop, but the important thing is for the processing folder to be pulled out of that .zip file. Then double-click processing.exe to start.
  • The Mac OS X version is also a .zip file. Double-click it and drag the Processing icon to the Applications folder. If you're using someone else's machine and can't modify the Applications folder, just drag the application to the desktop. Then double-click the Processing icon to start.
  • The Linux version is a .tar.gz file, which should be familiar to most Linux users. Download the file to your home directory, then open a terminal window, and type:
    tar xvfz processing-xxxx.tgz
    (Replace xxxx with the rest of the file's name, which is the version number.) This will create a folder named processing-2.0 or something similar. Then change to that directory:
    cd processing-xxxx
    and run it:
    ./processing

With any luck, the main Processing window will now be visible. Everyone's setup is different, so if the program didn't start, or you're otherwise stuck, visit the troubleshooting page for possible solutions.

PDE
The Processing Development Environment.

Your First Program

You're now running the Processing Development Environment (or PDE). There's not much to it; the large area is the Text Editor, and there's a row of buttons across the top; this is the toolbar. Below the editor is the Message Area, and below that is the Console. The Message Area is used for one line messages, and the Console is used for more technical details.

In the editor, type the following:

ellipse(50, 50, 80, 80);

This line of code means "draw an ellipse, with the center 50 pixels over from the left and 50 pixels down from the top, with a width and height of 80 pixels." Click the Run button the (triangle button in the Toolbar).

If you've typed everything correctly, you'll see a circle on your screen. If you didn't type it correctly, the Message Area will turn red and complain about an error. If this happens, make sure that you've copied the example code exactly: the numbers should be contained within parentheses and have commas between each of them, and the line should end with a semicolon.

One of the most difficult things about getting started with programming is that you have to be very specific about the syntax. The Processing software isn't always smart enough to know what you mean, and can be quite fussy about the placement of punctuation. You'll get used to it with a little practice.

Next, we'll skip ahead to a sketch that's a little more exciting. Delete the text from the last example, and try this:

void setup() {
  size(480, 120);
}

void draw() {
  if (mousePressed) {
    fill(0);
  } else {
    fill(255);
  }
  ellipse(mouseX, mouseY, 80, 80);
}

This program creates a window that is 480 pixels wide and 120 pixels high, and then starts drawing white circles at the position of the mouse. When a mouse button is pressed, the circle color changes to black. We'll explain more about the elements of this program in detail later. For now, run the code, move the mouse, and click to see what it does. While the sketch is running, the Run button will change to a square “stop” icon, which you can click to halt the sketch.


Getting Started with BLYNK

 

IN ORDER TO USE BLYNK APP YOU WOULD NEED:

  • Hardware that works with Blynk. Check the full list of supported hardware here
  • If your hardware doesn't have connectivity on board, you can use shields like Ethernet, WiFi, GPRS and many others. Blynk also works over Bluetooth and USB (☝️ USB is not for newbies!)

 

1. DOWNLOAD BLYNK APP FOR ANDROID OR IOS

2. GET THE AUTH TOKEN

In order to connect Blynk App and your hardware, you need an Auth Token.

  1. Create a new account in Blynk App.
  2. Create a New Project. Then choose the board and connection you will use.
  3. After the project was created, we will send you Auth Token over email.
  4. Check your email inbox and find the Auth Token.

 

3. INSTALL BLYNK LIBRARY

☝️ Blynk library should be installed manually. Follow the instructions:

  1. Download the latest release .zip file.
  2. Unzip it. You will notice that archive contains several folders and several libraries.
  3. Copy all these libraries to your_sketchbook_folder of Arduino IDE. To find the location of your_sketchbook_folder, go to top menu in Arduino IDE: File -> Preferences (if you are using Mac OS - go to Arduino → Preferences)

The structure of your your_sketchbook_folder should now look like this, along with your other sketches (if you have them):

your_sketchbook_folder/libraries/Blynk
your_sketchbook_folder/libraries/BlynkESP8266_Lib
...
your_sketchbook_folder/tools/BlynkUpdater
your_sketchbook_folder/tools/BlynkUsbScript
...

☝️ Note that libraries should go to libraries and tools to tools

 

3. CREATE YOUR FIRST EXAMPLE SKETCH CODE

Blynk works with hundreds of hardware models and connection types. We prepared Blynk Examples Sketch Builder that allows you to create example code for your hardware.

OPEN BLYNK SKETCH CODE BUILDER
  1. Choose Your board (for example: Arduino UNO)
  2. Choose your connection (WiFi, Ethernet, Bluetooth, USB...)

 

The first example you need is:

GettingStarted/BlynkBlink

 

4. PASTE THE AUTH TOKEN

• In the example sketch, find this line:

char auth[] = "YourAuthToken";

 

• Change it with your Auth Token (it should be in your email inbox after you created the Project in the Blynk app. Now it should exactly like this (☝️ don't forget the " "):

char auth[] = "53e4da8793764b6197fc44a673ce4e21";

• 🔥 Flash the code to your hardware

• Open serial monitor in Arduino IDE. You should see something like this

     ___  __          __
    / _ )/ /_ _____  / /__
   / _  / / // / _ \/  '_/
  /____/_/\_, /_//_/_/\_\
         /___/    v0.4.4

    [1240] Connecting to YourWiFi
    [1240] Connected to YourWiFi
    [1240] My IP: 192.168.10.172
    [1240] Blynk v0.4.4
    [5001] Connecting to blynk-cloud.com:8442
    [5329] Ready (ping: 1ms)

 

Congrats! You are connected! 🎉

 


Installing ARDUİNO

Installing Arduino

Get the latest version from the download page. You can choose between the Installer (.exe) and the Zip packages. We suggest you use the first one that installs directly everything you need to use the Arduino Software (IDE), including the drivers. With the Zip package you need to install the drivers manually. The Zip file is also useful if you want to create aportable installation.

When the download finishes, proceed with the installation and please allow the driver installation process when you get a warning from the operating system.

Choose the components to install

Choose the installation directory (we suggest to keep the default one)

The process will extract and install all the required files to execute properly the Arduino Software (IDE)

Installing the ESP8266 Arduino Addon

There are a variety of development environments that can be equipped to program the ESP8266. You can go with a simple Notepad/gcc setup, or fine-tune an Eclipse environment, use a virtual machine provided by Espressif, or come up with something of your own.

Fortunately, the amazing ESP8266 community recently took the IDE selection a step further by creating an Arduino addon. If you’re just getting started programming the ESP8266, this is the environment we recommend beginning with, and the one we’ll document in this tutorial.

This ESP8266 addon for Arduino is based on the amazing work by Ivan Grokhotkov and the rest of the ESP8266 community. Check out the ESP8266 Arduino GitHub repository for more information.

Installing the Addon With the Arduino Boards Manager

With the release of Arduino 1.6.4, adding third party boards to the Arduino IDE is easily achieved through the new board manager. If you’re running an older version of Arduino (1.6.3 or earlier), we recommend upgrading now. As always, you can download the latest version of Arduino from arduino.cc.

To begin, we’ll need to update the board manager with a custom URL. Open up Arduino, then go to the Preferences (FilePreferences). Then, towards the bottom of the window, copy this URL into the “Additional Board Manager URLs” text box:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

If you already have a URL in there, and want to keep it, you can separate multiple URLs by placing a comma between them. (Arduino 1.6.5 added an expanded text box, separate links in here by line.)

Adding Board Manager URL to Arduino preferences

Hit OK. Then navigate to the Board Manager by going to Tools > Boards > Boards Manager. There should be a couple new entries in addition to the standard Arduino boards. Look for esp8266. Click on that entry, then select Install.

You need to install 2.3.0 version of esp8266  library. 

Installing additional boards from Board Manager

The board definitions and tools for the ESP8266 Thing include a whole new set of gcc, g++, and other reasonably large, compiled binaries, so it may take a few minutes to download and install (the archived file is ~110MB). Once the installation has completed, an Arduino-blue “INSTALLED” will appear next to the entry.

Selecting the ESP8266 Thing Board

With the Board addon installed, all that’s left to do is select “ESP8266 Thing” from the Tools > Boards menu.

then select your FTDI’s port number under the Tools > Port menu. İf you do not see com port, you need to install driver s software by using the following button.

 

ESPcopter Driver

 

If you are using mac diveces and espcopter is not list in your post list, you need to do following steps.

  1. Shut Down
  2. Hold mac+ R during boot to enter recovery mode
  3. Open a terminal
  4. type spctl kext-consent disable and press enter
  5. Reboot
  6. Go to “System Preferences” -> “Security & Privacy”
  7. In the bottom of the window, you will see a message “System software from developer “SiLabs” was blocked from loading.”
  8. Click on “Allow” button
  9. Restart your Mac
  10. Now my device is listed as /dev/cu.SLAB_USBtoUART and everything work as expected.


2-) Uploading Code

https://youtu.be/QAJTIhmGzuU?list=PLN1j_JuvrwOJYA5TVu8JF2AL8OXq1tAB_

Installing Arduino IDE

This tutorial will walk you through downloading, installing, and testing the Arduino software (also known as the Arduino IDE - short for Integrated Development Environment). Before you jump to the page for your operating system, make sure you’ve got all the right equipment.

What you will need:

  • A computer (Windows, Mac, or Linux)
  • An ESPcopter
  • A USB - micro USB

micro usb ile ilgili görsel sonucu

 

1-) Arduino Installation:

Download and install the latest version from the Arduino web site: https://www.arduino.cc/en/Main/Software

2-) Driver Installation:

The following driver is required for the ESPcopter to be recognized by the computer. Download and install the appropriate driver version for your OS.

https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

3-) ESP8266 Library

To begin, we’ll need to update the board manager with a custom URL. Open up Arduino, then go to the Preferences (File> Preferences). Then, towards the bottom of the window, copy this

URL into the “Additional Board Manager URLs” text box:

http://arduino.esp8266.com/stable/package_esp8266com_index.json

 

 

Hit OK. Then navigate to the Board Manager by going to Tools > Boards > Boards Manager. There should be a couple new entries in addition to the standard Arduino boards. Look for esp8266. Click on that entry, then select Install. You need to install 2.6.3 version of esp8266 library.

 

 

The download process can take up to 10 minutes depending on your internet speed. After the download is done, select NodeMCU 1.0 from the Tools tab and follow the other settings.

 

 

4-)Downloading the ESPcopter library:

Before downloading the code from the website, you must use the contacts page to request the source code. See the following site: http://espcopter.com/code-release/

After downloading, remove the zip file twice and put the file (ESPcopter ”(Files> Arduino> Library) into the file. In the Examples section, you will see the sample codes of the ESPcopter.

Open the following example program:

 

5-) Spiffs Memory Updater Installation:

  • What is Spiffs Memory?

Flash File System (SPIFFS) is a SPI Flash (64kBytes to 3Mbyte) In this flash memory ESP stores the program. This filing system can be used to store infrequently changing data such as; web pages, configurations, sensor calibration data etc.

Install Spiffs Memory Uploader?

Update Software:

6-) Update Main Software:

  • To update the code, the drone must be turned on and connected to the computer via USB cable. Open the ESPcopter code from the ESPcopter Library in the Examples section. Do not forget to select Com port from the tools section of Arduino.

 

  • Make the necessary settings from the Tools section.

 

  • Upload the code by clicking the Upload button.

 

7-) Update Spiffs Memory:

  • Make sure you have selected a board, port, and closed Serial Monitor.
  • If your board requires you to press a button (or other action) to enter bootload mode for flashing a sketch, do that now.
  • Select Tools > ESP8266 Sketch Data Upload. This should start uploading the files into ESP8266 flash file system. When done, IDE status bar will display SPIFFSImage Uploaded.

After updating the main software and spiffs memory, updating software is completed.


Lesson 5. VL53L0X Time-of-Flight Distance Sensor

Dowland VL53L0X  library:

https://github.com/pololu/vl53l0x-arduino

 

/* This example shows how to get single-shot range
measurements from the VL53L0X. The sensor can optionally be
configured with different ranging profiles, as described in
the VL53L0X API user manual, to get better performance for
a certain application. This code is based on the four
"SingleRanging" examples in the VL53L0X API.

The range readings are in units of mm. */

#include <Wire.h>
#include <VL53L0X.h>

VL53L0X sensor;

 

// Uncomment this line to use long range mode. This
// increases the sensitivity of the sensor and extends its
// potential range, but increases the likelihood of getting
// an inaccurate reading because of reflections from objects
// other than the intended target. It works best in dark
// conditions.

//#define LONG_RANGE

 

// Uncomment ONE of these two lines to get
// - higher speed at the cost of lower accuracy OR
// - higher accuracy at the cost of lower speed

//#define HIGH_SPEED
//#define HIGH_ACCURACY

 

void setup()
{
Serial.begin(9600);
Wire.begin();

sensor.init();
sensor.setTimeout(500);

#if defined LONG_RANGE
// lower the return signal rate limit (default is 0.25 MCPS)
sensor.setSignalRateLimit(0.1);
// increase laser pulse periods (defaults are 14 and 10 PCLKs)
sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);
sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14);
#endif

#if defined HIGH_SPEED
// reduce timing budget to 20 ms (default is about 33 ms)
sensor.setMeasurementTimingBudget(20000);
#elif defined HIGH_ACCURACY
// increase timing budget to 200 ms
sensor.setMeasurementTimingBudget(200000);
#endif
}

void loop()
{
Serial.print(sensor.readRangeSingleMillimeters());
if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }

Serial.println();
}

 

 

 


Lesson 3. 9250 Accelerometer and Gyroscope Sensor

9250 Accelerometer and Gyroscope Sensor

 

#include <Wire.h>

#define MPU9250_ADDRESS 0x68
#define MAG_ADDRESS 0x0C

#define GYRO_FULL_SCALE_250_DPS 0x00
#define GYRO_FULL_SCALE_500_DPS 0x08
#define GYRO_FULL_SCALE_1000_DPS 0x10
#define GYRO_FULL_SCALE_2000_DPS 0x18

#define ACC_FULL_SCALE_2_G 0x00
#define ACC_FULL_SCALE_4_G 0x08
#define ACC_FULL_SCALE_8_G 0x10
#define ACC_FULL_SCALE_16_G 0x18

// This function read Nbytes bytes from I2C device at address Address.
// Put read bytes starting at register Register in the Data array.

uint8_t ST1;
int16_t mag_int[3] = {0};

void writeBIT(int addr, int data, int adrrTrans){
Wire.beginTransmission(adrrTrans);
Wire.write(addr);
Wire.write(data);
Wire.endTransmission();
}
void I2Cread(uint8_t Address, uint8_t Register, uint8_t Nbytes, uint8_t* Data){
// Set register address
Wire.beginTransmission(Address);
Wire.write(Register);
Wire.endTransmission();
// Read Nbytes
Wire.requestFrom(Address, Nbytes);
uint8_t index=0;
while (Wire.available())
Data[index++]=Wire.read();
}

// Initializations
void setup()
{
// Arduino initializations
Wire.begin();
Serial.begin(115200);

Wire.setClock(400000L);
// Set accelerometers low pass filter at 5Hz
writeBIT(29, 0x06,MPU9250_ADDRESS);
// Set gyroscope low pass filter at 5Hz
writeBIT(26, 0x06,MPU9250_ADDRESS);
// Configure gyroscope range
writeBIT(27, GYRO_FULL_SCALE_2000_DPS,MPU9250_ADDRESS);
// Configure accelerometers range
writeBIT(28, ACC_FULL_SCALE_2_G,MPU9250_ADDRESS);
// Set by pass mode for the magnetometers
writeBIT(0x37, 0x02,MPU9250_ADDRESS);
// Request continuous magnetometer measurements in 16 bits
//writeBIT(0x0A, 0x16,MAG_ADDRESS);
delay(200);
// writeBIT(0x0A, mRes << 4 | 0x06 ,MAG_ADDRESS);

writeBIT(0x0A, 0x00 , MAG_ADDRESS); // Power down magnetometer
delay(20);
writeBIT(0x0A , 0x0F, MAG_ADDRESS); // Enter Fuse ROM access mode
delay(20);

}

// Main loop, read and display data
void loop()
{
// ____________________________________
// ::: accelerometer and gyroscope :::

// Read accelerometer and gyroscope
uint8_t Buf[14];
int16_t accel[3] = {0}, gyro_int[3] = {0}, MEAN_GYRO[3] = {0};;

I2Cread(MPU9250_ADDRESS,0x3B,14,Buf);

accel[0]=(Buf[0]<<8 | Buf[1]);
accel[1]=(Buf[2]<<8 | Buf[3]);
accel[2]=Buf[4]<<8 | Buf[5];

// Gyroscope
gyro_int[0]=(Buf[8]<<8 | Buf[9]);
gyro_int[1]=(Buf[10]<<8 | Buf[11]) ;
gyro_int[2]=Buf[12]<<8 | Buf[13] ;

// Display values

// Accelerometer
Serial.print (accel[0],DEC);
Serial.print ("\t");
Serial.print (accel[1],DEC);
Serial.print ("\t");
Serial.print (accel[2],DEC);
Serial.print ("\t");

// Gyroscope
Serial.print (gyro_int[0],DEC);
Serial.print ("\t");
Serial.print (gyro_int[1],DEC);
Serial.print ("\t");
Serial.print (gyro_int[2],DEC);
Serial.println ("\t");

}


Lesson 5. DC Motors

Overview

In this lesson, you will learn how to control ESPcopter DC motors.

void setup() {
// set pins 12 through 15 as outputs:
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(14, OUTPUT);
pinMode(15, OUTPUT);
}

void loop() {
// iterate over the pins:
for (int i = 0; i <= 200; i+++) {
analogWrite(12, i);
delay(10);
}
delay(100000);
}

}