Hey guys, welcome back in my new makelog. Few days ago I decided to make a self balancing robot. To make a self balancing robot we need to prepare software part & hardware part. So here I'm preparing Software part of my robot my robot. You can also call a brain of it. Because we will use this pcb to provide commands to our robot.
Required Components
ESP32
MPU6050
Capacitor
Header Pins
Screw Terminal
Professional PCB
Stepper Motor Driver
Step 1: PCB Design
Start by finalizing my PCB design using mine preferred design software. Once satisfied, I saved design files in Gerber formats. For designing a PCB I recommend Kicad Because it's preferred for beginner.
I designed this PCB according to me needs;) it has some additional features like I can control two Nema17 stepper motor one Servo Motor and even a Buzzer & LEDs wirelessly, using my smartphone.
Step 2: Order PCB After Successfully designing of PCB. I ordered my coustom PCBs from PCBWAY. Head to PCBWAY's website. If you don't have an account, sign up, it's quick and easy. Sign up PCBWAY now to get a US $5 coupon. That means your first order is free of cost only you have to pay the shipping charges. After Sign Up Upload your Gerber files and specify your requirements. Choose the quantity, PCB thickness, and color to match your project needs.
Step 3: Solder Components After Receiving PCB, Solder some remaining components like Header Pins, Buzzer, Capacitor & Screw Terminal. After the process of soldering use a IPA to clean the PCB and provide a professional look. For better soldering, I recommend to use Sequre SI012 Pro Soldering Iron, Because I love it have a lot of features and powerful Also.
Step 4: Place the Components After Soldering Process, place the necessary components like stepper motor driver, ESP32, MPU6050, etc.
Step 5: Upload the Code To upload the code you doesn't need laptop or PC. Because you can even program it using your smartphone. For this go to (Play Store/ App Store) and search for Bluino Electronics and download the application. After Successfully download, open it and click on (Sketch/Code). Here you will see a option to upload the code you can use your smartphone to directly upload firmware to ESP32 either via USB or Wifi OTA, by pressing the upload icon.
If you need to edit the sketch with computer using Arduino IDE, you can find full source code on github
Step 6: Ready to use Now it's ready to use, In my next makelog, I will make a self balancing robot using this PCB. So stay tuned for next one until enjoy it.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for SSD1306 display connected using I2C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// WiFi credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
// NTP Client setup
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "pool.ntp.org", 0, 60000); // UTC timezone
void setup() {
// Initialize Serial
Serial.begin(115200);
// Initialize OLED display
if(!display.begin(SSD1306_I2C_ADDRESS, 0x3C)) { // 0x3C is the I2C address for the OLED
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay();
// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi connected");
// Initialize NTPClient
timeClient.begin();
}
void loop() {
// Update time
timeClient.update();
// Clear display buffer
display.clearDisplay();
// Display current time
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 10);
display.print(timeClient.getFormattedTime());
// Display buffer to OLED
display.display();
delay(1000); // Update time every second
}