Thanks again @PCBWay for sponsoring my project. PCBWay You can have your PCB boards produced for 10$. And it provides all kinds of printing and assembly services.
PCBWay: https://www.pcbway.com/
PCBWay+ my profile: https://www.pcbway.com/project/member/?bmbno=188E1A91-204D-49Project name: Multi-Controlled Robot Card_V1Names of Used Modules:
ESP12-F
MPU6050
L293D
NRF24
GY-NEO6MV2 GPS ModulePurpose of the project and places of use:I implemented a simple autonomous vehicle project using Arduino IDE, ESP12-F, MPU6050, L293D, NRF24 and GY-NEO6MV2 GPS module. In my project, there are sensors and modules used to detect objects around the autonomous vehicle and go to a certain place.
ESP12-F was the microcontroller we used in the project. This is the brain where all other modules are controlled. The MPU6050 was used to measure the vehicle's accelerometer and gyroscope characteristics. These features are used to track the vehicle's movements and help prevent undesirable situations.
L293D is a motor driver module used to make the vehicle move. This controls the motors used to make the vehicle move forward or backward, turn right or left. NRF24 provides wireless control of the vehicle and receives the signals from the remote control and converts them into a format that the microcontroller can understand.
Finally, the GY-NEO6MV2 GPS module is used to track the vehicle's location and navigate to a specific location. This module reads the GPS coordinates and allows the vehicle to move towards the desired location.
First of all, the aim of the project was to make an autonomous vehicle. It was a vehicle that could sense surrounding objects, move towards a specific target, and be controlled by a wireless remote control. To this end, the modules and sensors used in the project were:
ESP12-F: This microcontroller was the main control unit that controlled all the modules of the vehicle.
MPU6050: This sensor was used to track the vehicle's movements by measuring the vehicle's accelerometer and gyroscope features.
L293D: This motor driver module controlled the motors used to drive the vehicle.
NRF24: This wireless module provided wireless control of the vehicle.
GY-NEO6MV2 GPS module: This module was used to track the vehicle's location and navigate to a specific location.
All modules are connected to pins on the ESP12-F and programmed using the Arduino IDE. The program processed the data the vehicle received from the sensors and controlled the movement of the vehicle.
The vehicle's motion was controlled by the L293D motor driver module. This module controlled the motors used to move the vehicle forward or backward. He also controlled the motors, which were also used to make the vehicle turn right or left.
Wireless control of the vehicle was provided with the NRF24 module. This module takes the signals from the remote control to control the movement of the vehicle and converts them into a format that the microcontroller can understand.
While doing the project, I first provided the necessary materials and drew the design of the vehicle. Then, I examined the datasheets of the modules to learn the connections and working principles of the modules.
Using the ESP12-F microcontroller, I was able to communicate with other modules and control the movement of the vehicle. The ESP12-F was an ideal choice for project use thanks to its small size and Wi-Fi capability. I programmed this microcontroller in Arduino IDE.
The MPU6050 sensor was used to measure the vehicle's accelerometer and gyroscope characteristics. This sensor was crucial for tracking the correct position of the vehicle. MPU6050 is connected with ESP12-F using I2C communication protocol.
The L293D motor driver module was used to control the motors required for vehicle movement. This module provided the movement of the vehicle by controlling the motors in the right direction and speed. The L293D module was connected to the ESP12-F along with other modules.
The NRF24 wireless module provided wireless control of the vehicle. This module controlled the movement of the vehicle by receiving signals from the remote control. The NRF24 module was connected to the ESP12-F along with the other modules of the vehicle.
The GY-NEO6MV2 GPS module was used to track the vehicle's location. This module enabled the vehicle to move towards the target location by reading the GPS coordinates. The GY-NEO6MV2 module was connected to the ESP12-F along with other modules.
The aim of the project was to make a vehicle that can be controlled wirelessly and that can move towards a specific target thanks to the GPS module. This project was an opportunity to gain experience and improve myself in robotics, programming and electronics.
While doing the project, I first procured the necessary materials. Materials included ESP12-F microcontroller, MPU6050 sensor, L293D motor driver module, NRF24 wireless module, GY-NEO6MV2 GPS module and various other electronic components.
Then, I drew the design of the vehicle and examined the datasheets of the modules to learn the connections and working principles of the modules. At this stage, I learned which connections and protocols should be used for the modules to work correctly.
The next step was to write a program that could communicate with other modules using the ESP12-F microcontroller. In this program, we could control the movement of the vehicle by receiving the signals received from the wireless controller, measure the accelerometer and gyroscope features of the vehicle thanks to the MPU6050 sensor, control the engines with the L293D motor driver module and track the position of the vehicle thanks to the GY-NEO6MV2 GPS module.
During the programming phase, I used the Arduino IDE programming interface. This interface is a very popular tool for programming the ESP12-F microcontroller. While writing the program, I took into account the connections of the microcontroller and the protocols it will use.
Next, I made the connections of the modules and loaded the program. While making the connections, I took care to use the correct polarity and voltage. Thanks to the program I downloaded, I was able to control the vehicle with the wireless remote control and thanks to the GPS module, I enabled the vehicle to move towards a certain target.
At the end of the project, it was successfully tested that the vehicle could be controlled by wireless control and moved towards a specific target thanks to the GPS module. While doing the project, I gained experience in robotics, programming and electronics and improved myself on these issues.
CODE:
Identifying libraries and determining pin numbers:
#include <SPI.h>
#include <RF24.h>
#include <RF24Network.h>
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>
#include <TinyGPS++.h>
#define CE_PIN 5
#define CSN_PIN 15
#define LEFT_MOTOR_PIN1 12
#define LEFT_MOTOR_PIN2 13
#define RIGHT_MOTOR_PIN1 4
#define RIGHT_MOTOR_PIN2 0
Here, the libraries to be used are defined. SPI, RF24, RF24Network, Wire, I2Cdev, MPU6050 and TinyGPS++ libraries are used in this code. Pin numbers are also defined.
Defining variables:
MPU6050 accelgyro;
TinyGPSPlus gps;
RF24 radio(CE_PIN, CSN_PIN);
RF24Network network(radio);
Here, variables are defined for the MPU6050 accelerometer module, the TinyGPS++ GPS module, the NRF24L01 wireless module, and the RF24Network module.
setup() function:
void setup() {
pinMode(LEFT_MOTOR_PIN1, OUTPUT);
pinMode(LEFT_MOTOR_PIN2, OUTPUT);
pinMode(RIGHT_MOTOR_PIN1, OUTPUT);
pinMode(RIGHT_MOTOR_PIN2, OUTPUT);
Serial.begin(9600);
WiFi.begin("SSID", "PASSWORD");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
radio.begin();
network.begin(90, 1);
Wire.begin();
accelgyro.initialize();
Serial.println("Starting GPS");
Serial.println("GPS started");
}
Here, the GPIO pins to be used for the motor driver module are set as outputs. Then the serial communication speed is set and connected to the WiFi module. The NRF24L01 wireless module and the RF24Network library are initialized. The MPU6050 accelerometer module is initialized using the I2C interface, and the GY-NEO6MV2 GPS module is also initialized.
loop() function:
void loop() {
network.update();
if (network.available()) {
RF24NetworkHeader header;
char message[32];
network.read(header, &message, sizeof(message));
Serial.print("Received: ");
Serial.println(message);
}
int16_t ax, month, az;
accelgyro.getAcceleration(&ax, &ay, &az);
Serial.print("Acceleration: ");
Serial.print(ax);
Serial.print(", ");
Serial.print(month);
Serial.print(", ");
Serial.println(az);
while (Serial.available() > 0) {
gps.encode(Serial.read());
}
if (gps.location.isValid()) {
Serial.print("Latitude: ");
Serial.println(gps.location.lat());
Serial.print("Longitude: ");
Serial.println(gps.location.lng());
}
Wireless data transmission:
String data = String(gps.location.lat(), 6) + "," + String(gps.location.lng(), 6);
char message[32];
data.toCharArray(message, 32);
RF24NetworkHeader header(1);
network.write(header, &message, sizeof(message));
Serial.print("Sent: ");
Serial.println(message);
Here, the location data received from the GY-NEO6MV2 GPS module is stored in a string variable. This string is then converted to a character string and sent to other devices using the NRF24L01 wireless module.
Engine control:
if (ax > 10000) {
digitalWrite(LEFT_MOTOR_PIN1, HIGH);
digitalWrite(LEFT_MOTOR_PIN2, LOW);
digitalWrite(RIGHT_MOTOR_PIN1, LOW);
digitalWrite(RIGHT_MOTOR_PIN2, HIGH);
} else if (ax < -10000) {
digitalWrite(LEFT_MOTOR_PIN1, LOW);
digitalWrite(LEFT_MOTOR_PIN2, HIGH);
digitalWrite(RIGHT_MOTOR_PIN1, HIGH);
digitalWrite(RIGHT_MOTOR_PIN2, LOW);
} else {
digitalWrite(LEFT_MOTOR_PIN1, LOW);
digitalWrite(LEFT_MOTOR_PIN2, LOW);
digitalWrite(RIGHT_MOTOR_PIN1, LOW);
digitalWrite(RIGHT_MOTOR_PIN2, LOW);
}
Here, the motors are controlled according to the data read from the accelerometer module. If the acceleration in the x-axis is greater than 10000, the left motors move forward while the right motors move backwards. If the acceleration in the x-axis is less than -10000, the left motors move forward while the left motors move backwards. If the acceleration in the x-axis is between these values, both motors will stop.
setup()
Serial.begin(9600);
while (!Serial);
Serial.println("Initializing MPU6050...");
mpu.initialize();
pinMode(LEFT_MOTOR_PIN1, OUTPUT);
pinMode(LEFT_MOTOR_PIN2, OUTPUT);
pinMode(RIGHT_MOTOR_PIN1, OUTPUT);
pinMode(RIGHT_MOTOR_PIN2, OUTPUT);
Serial.println("Initializing NRF24L01...");
radio.begin();
network.begin(90, node_address);
Serial.println("Initializing GPS module...");
Serial1.begin(9600);
gps.begin(9600);
delay(1000);
This function makes the initial settings of the device. The serial communication speed is set, the MPU6050 accelerometer module and the NRF24L01 wireless module are initialized, the mode of the pins to which the motors are connected is set, and the GPS module is initialized.
readData()
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
double month = month / 16384.0;
double azg = az / 16384.0;
double angle = alan2(ayg, azg) * 180.0 / PI;
if (angle < 0) {
angle += 360;
}
Serial.print("Angle: ");
Serial.println(angle);
This function receives the acceleration and angular velocity data read from the MPU6050 module and determines the direction of the device by performing the calculations mentioned above. Then, the calculated angle is sent over the serial port.
updateGPS()
while (Serial1.available() > 0) {
gps.encode(Serial1.read());
}
This function reads the data from the GY-NEO6MV2 GPS module by serial communication and parses the data if GPS data block is available.
sendGPSData()
scss
copy code
if (gps.location.isValid()) {
String data = String(gps.location.lat(), 6) + "," + String(gps.location.lng(), 6);
char message[32];
data.toCharArray(message, 32);
RF24NetworkHeader header(1);
network.write(header, &message, sizeof(message));
Serial.print("Sent: ");
Serial.println(message);
}
This function wirelessly sends the location data read from the GPS module to other devices. The data is first stored in a string variable and then converted to a string of characters. Finally, this data is sent to other devices using the wireless module.
motorControl()
if (ax > 10000) {
digitalWrite(LEFT_MOTOR_PIN1, HIGH);
digitalWrite(LEFT_MOTOR_PIN2, LOW);
digitalWrite(RIGHT_MOTOR_PIN1, LOW);
digitalWrite(RIGHT_MOTOR_PIN2, HIGH);
} else if (ax < -10000) {
digitalWrite(LEFT_MOTOR_PIN1,
motorControl() (continued)
digitalWrite(LEFT_MOTOR_PIN2, HIGH);
digitalWrite(RIGHT_MOTOR_PIN1, HIGH);
digitalWrite(RIGHT_MOTOR_PIN2, LOW);
} else {
digitalWrite(LEFT_MOTOR_PIN1, LOW);
digitalWrite(LEFT_MOTOR_PIN2, LOW);
digitalWrite(RIGHT_MOTOR_PIN1, LOW);
digitalWrite(RIGHT_MOTOR_PIN2, LOW);
}
This function controls the movement of the device. Using the acceleration data read from the MPU6050 module, it adjusts the speed of the motors depending on the acceleration of the device. If the device is accelerating to the left, the left motors will move and the device will rotate to the right. Similarly, in case of acceleration to the right, the right motors move and the device turns to the left. Also, if the acceleration of the device is too low, the motors will stall and the device will stand still.
loop()
readData();
updateGPS();
sendGPSData();
motorControl();
This function is the loop that continues running after the setup() function. This function reads device acceleration, updates GPS data, sends GPS data to other devices and controls motors.Purposes of using the modules:
ESP12-F: This is a WiFi module and provides wireless internet connection. By using this module in your project, you can enable your device to connect to the wireless network.
MPU6050: This is an accelerometer and gyroscope module. By using this module in your project, you can measure the movement of your device. For example, you can measure whether the device turns right or left, moves forward or backward.
L293D: This is a motor driver module. By using this module in your project, you can control the engines of your device. For example, you can have your device turn right or left, go forward or backward.
NRF24: This is a wireless communication module. By using this module in your project, you can enable your device to communicate wirelessly with other devices. For example, you can use your device to send or receive GPS data from other devices.
GY-NEO6MV2 GPS Module: This is a GPS module. By using this module in your project, you can measure the position of your device. For example, you can measure where your device is or which way it's headed.
What is PCBWay:
PCBWAY is a professional Printed Circuit Board Manufacturer (PCB) company. Founded in 2003, the company was established to support its designers during the design and production stages.
PCBWAY provides versatile PCB design and manufacturing services for simple and complex projects. The quality, speed and reasonable prices of their products work to help meet their customers' needs.
The most important features of PCBWAY are:
1. PCB Design Support: PCBWAY offers designers professional design support to help you realize your design.
2. Low Prices: PCBWAY offers lower prices compared to its competitors and offers its customers the best price-performance ratio.
3. Fast Production: PCBWAY offers fast production times to meet customers' expectations.
4. Quality Products: PCBWAY takes care to comply with the highest quality standards during the production phase and offers its customers the best quality products.
5. Global Supplier: PCBWAY serves many customers around the world and provides fast and reliable service to customers in different geographical regions.
PCBWAY is a reliable and professional option providing professional PCB services for your electronics projects. As a company that appeals to everyone from beginner level designers to professionals, it distinguishes itself from other competitors with the quality, speed and price advantages of its products.
How to order?
The process of ordering a printed circuit on PCBWAY consists of these steps:
1. Registration: To become a member of PCBWAY, go to https://www.pcbway.com and click "Register". Fill in your e-mail address, password and other necessary information to become a member.
2. Design Upload: Click "Order" of PCBWAY and upload your design files. Files should be like Gerber files, BOM file, design file.
3. Order Customization: Fill in the order form and choose customization options, for example PCB thickness, color, coating etc.
4. Payment: Pay after confirming your order. PCBWAY offers many payment methods such as credit card, PayPal, bank transfer.
5. Production and Delivery: Once your order is confirmed, PCBWAY goes into production and is prepared for delivery. You can always observe your order status and get information about the production process.
PCBWAY offers an easy and fast ordering process and strives to provide the best service to its customers. At the end of the ordering process, PCBWAY will work to deliver your products as soon as possible and with the highest quality.
Comments