Building a mini drone use ESP32

@Leon90 i try now to modify default firmware ESP32buzz.h and i want add MPU6050.
Wich code i must add ?

#define HAL_INS_DEFAULT HAL_INS_MPU6050_I2C
#define HAL_INS_MPU6050_BUS 0
#define HAL_INS_MPU6050_ADDR (0x68)

SDA it’s ok in IO 26 and SCL in IO 27 ?

@skimans
you can find those define in ESP32buzz.h:

1.this is the i2c bus define(it means only one i2c bus 0 on gpio 12, 13):

//I2C bus list
#define HAL_ESP32_I2C_BUSES
{.port=I2C_NUM_0, .sda=GPIO_NUM_13, .scl=GPIO_NUM_12, .speed=400*KHZ, .internal=true}

2.if you want to add a mpu6050, just add this(it means a mpu6050 on i2c bus 0 with yaw rotation of 270 degree):

// IMU probing:
#define HAL_INS_PROBE_LIST PROBE_IMU_I2C(Invensensev2, 0, 0x68, ROTATION_YAW_270)

1 Like

@Leon90 i have problem with Compass.
In particular i have “Bad Compass Healt”
I have test with Arduino and address is 0x0D.
I have this code:

#define AP_COMPASS_QMC5883L_ENABLED 1
#define HAL_COMPASS_QMC5883L_I2C_ADDR 0x0D
#define HAL_MAG_PROBE_LIST PROBE_MAG_I2C(QMC5883L, 0, HAL_COMPASS_QMC5883L_I2C_ADDR, true, ROTATION_NONE)

#define HAL_INS_DEFAULT HAL_INS_MPU6050_I2C
#define HAL_INS_PROBE_LIST PROBE_IMU_I2C(Invensense, 0, 0x68, ROTATION_NONE)
PROBE_MAG_I2C(QMC5883L, 0, 0x0D, 0, ROTATION_YAW_270)
#define HAL_INS_MPU6050_NAME “mpu6050”

//I2C Buses
#define HAL_ESP32_I2C_BUSES {.port=I2C_NUM_0, .sda=GPIO_NUM_21, .scl=GPIO_NUM_22, .speed=400KHZ, .internal=true},
{.port=I2C_NUM_1, .sda=GPIO_NUM_18, .scl=GPIO_NUM_19, .speed=400
KHZ, .internal=true}

MPU work fine, but compass not work.
MPU6050 = SDA in GPIO21 and SCL in GPIO22
COMPASS QMC5883L = SDA is in GPIO18 and SCL GPIO19

hi can you send me the compiled firmware

mut20231097@std.psut.edu.jo

Hi! @Leon90 is an excellent project. If you have compiled firmware for a rover/boat?

could you mail me the above compiled files

@skimans With this message I think that the compass driver is work well, but there something makes the magnetic field in a bad conditions or you have put the compass in the wrong direction.

@Mutaz_Younis, I have Email your one piece of my firmware.

@McKey , now I have no time to work and try the firmware for a rover/boat, and I think if the firmware of copter is work well so the rover/boat must be better, because the scheduler of plane/rover/boat is slower than copter, this can help so much.

1 Like

Hi thanks for the firmware but iam running through some issues building the drone this is part of a university graduating project so please if you have time hit me up on discord i will send you my user name on email cause i am really in need of assistance @Leon90

@Leon90 excelent job, I would like learn more about your project: jjatienzo@gmail.com

Hola me gusta mucho la idea , muy buen trabajo podriais compartir el firmware para poder probar y contribuir en la medida de lo posible ??

joaquin.barbep08@gmail.com

Hello @Leon90 , thank you for showing us your copter and project, it is really impressive that you have it working and that too flawless.

I have followed the steps on Ardupilot github and compiled my esp32buzz files, after flashing them to my ESP32 DevKit 1 board, i was able to see below lines in my terminal.
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

configsip: 0, SPIWP:0xee

clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

mode:DIO, clock div:1

load:0x3fff0030,len:5288

load:0x40078000,len:14264

load:0x40080400,len:4244

entry 0x40080664

e[0;32mI (678) cpu_start: Pro cpu up.e[0m

e[0;32mI (678) cpu_start: Application information:e[0m

e[0;32mI (678) cpu_start: ELF file SHA256: 24b9ee33934dfed2…e[0m

e[0;32mI (681) cpu_start: ESP-IDF: v4.2.5-1-g5f8de192fae[0m

e[0;32mI (688) cpu_start: Starting app cpu, entry point is 0x40081c30e[0m

e[0;32mI (0) cpu_start: App cpu up.e[0m

e[0;32mI (698) heap_init: Initializing. RAM available for dynamic allocation:e[0m

e[0;32mI (705) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAMe[0m

e[0;32mI (711) heap_init: At 3FFC8E68 len 00017198 (92 KiB): DRAMe[0m

e[0;32mI (717) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAMe[0m

e[0;32mI (723) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAMe[0m

e[0;32mI (730) heap_init: At 400954D8 len 0000AB28 (42 KiB): IRAMe[0m

e[0;32mI (736) cpu_start: Pro cpu start user codee[0m

e[0;32mI (757) spi_flash: detected chip: generice[0m

e[0;32mI (758) spi_flash: flash io: qioe[0m

e[0;32mI (758) esp_core_dump_uart: Init core dump to UARTeV�Mounting sd

e[0;32mI (775) SD…: Initializing SD card as SDMMCe[0m

I (931) wifi:wifi driver task: 3ffda2e4, prio:23, stack:6656, core=0

e[0;32mI (931) system_api: Base MAC address is not sete[0m

e[0;32mI (931) system_api: read default base MAC address from EFUSEe[0m

I (937) wifi:wifi firmware version: 764a07b

I (941) wifi:wifi certification version: v7.0

I (945) wifi:config NVS flash: disabled

I (949) wifi:config nano formating: disabled

I (953) wifi:Init data frame dynamic rx buffer num: 16

I (957) wifi:Init management frame dynamic rx buffer num: 16

I (963) wifi:Init management short buffer num: 32

I (967) wifi:Init dynamic tx buffer num: 16

I (971) wifi:Init static rx buffer size: 1600

I (975) wifi:Init static rx buffer num: 2

I (979) wifi:Init dynamic rx buffer num: 16

e[0;32mI (983) wifi_init: tcpip mbox: 32e[0m

e[0;32mI (987) wifi_init: udp mbox: 6e[0m

e[0;32mI (991) wifi_init: tcp mbox: 6e[0m

e[0;32mI (995) wifi_init: tcp tx win: 5744e[0m

e[0;32mI (999) wifi_init: tcp rx win: 5744e[0m

e[0;32mI (1003) wifi_init: tcp mss: 1436e[0m

e[0;32mI (1007) wifi_init: WiFi RX IRAM OP enablede[0m

e[0;32mI (1347) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07e[0m
I (1431) wifi:mode : softAP (0a:d1:f9:34:51:60)

I (1433) wifi:Total power save buffer number: 8

I (1433) wifi:Init max length of beacon: 752/752

I (1433) wifi:Init max length of beacon: 752/752

AnalogIn: eFuse Two Point: NOT supported

AnalogIn: eFuse Vref: Supported

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

RCOutput::init() - channels available: 6

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

Init ArduCopter V4.4.1 (e010f979)

Free RAM: 113804

Firmware change: erasing EEPROM…

done.

e[0;31mE (1799) sdmmc_req: sdmmc_host_wait_for_event returned 0x107e[0m

e[0;31mE (1803) sdmmc_common: sdmmc_init_ocr: send_op_cond (1) returned 0x107e[0m

e[0;31mE (1803) vfs_fat_sdmmc: sdmmc_card_init failed (0x107).e[0m

sdcard is not mounted

load_all took 4800073us

AnalogIn: adding ardupin:255-> which is adc1_offset:-1

AnalogIn: channel:0 created but using delayed adc and gpio pin configuration

spi device constructed SPI:bmp280:0:0

AP_Logger_File: buffer size=16384

No Compass backends available

spi device constructed SPI:mpu9250:0:1

Also when i connect to Mission Planner via USB, it is not connecting. I tried TCP as well, no luck there.

My Misson Planner version is 4.4.1, any idea on what could be the porblem?

Aslo can u share me your compiled build files?

My email is pratikphadte19@gmail.com

Thank you so much!

I had the same problem, mostly this is due to incorrect wiring of the sensors. For me it was that I had forgotten the SPI Chip-Select pin. This is configured here:

#define HAL_ESP32_SPI_DEVICES \
    {.name= "bmp280", .bus=0, .device=0, .cs=GPIO_NUM_26, .mode = 3, .lspeed=1*MHZ, .hspeed=1*MHZ}, \
    {.name="mpu9250", .bus=0, .device=1, .cs=GPIO_NUM_5,  .mode = 0, .lspeed=2*MHZ, .hspeed=8*MHZ}

So the IMU needs its CS pin connected to GPIO5.

Hello Vabe, You are using the mpu9250, have you tried with MPU6050?

The Buzz firmware is set up for the mpu9250. I also used the 6050 ones but this requires a different setup. The 6050 doesn’t even have SPI so you must use I2C. Here is a setup that uses the GY87 which includes the mpu6050: Discord

Amazing project. Thank @Leon90 for sharing.
And question. I built ardupilot from GitHub scr, flush it to esp32. Reboot. Console log last lines:

I (20320) wifi:mode : softAP (32:ae:a4:96:f4:c4)
I (20322) wifi:Total power save buffer number: 8
I (20322) wifi:Init max length of beacon: 752/752
I (20322) wifi:Init max length of beacon: 752/752
WiFi softAP init finished. SSID: ardupilot123 password: ardupilot123 channel: 1
OK created task _wifi_thread on FASTCPU
AP_Logger_File: buffer size=16384
AnalogIn: adding ardupin:255-> which is adc1_offset:-1
AnalogIn: channel:0 created but using delayed adc and gpio pin configuration
spi device constructed SPI:bmp280:0:0
No Compass backends available
spi device constructed SPI:mpu9250:0:1

Now I have only esp32 board, no any sensors or SD card connected. I try to connect MP and QGC using serial on PC, connect to SoftAP and try to connect MP and QGC on android phone, but without success. This mean that I cant do this without connected to esp32 sensors?
And other question - Ardupilot esp32 console is only for log output? I cant execute any commands via it?
Thanks in advance.

you must connect sensor to connect in MP (need only IMU)
Also when flash firmware you must connect sensor.

1 Like

Hi again guys! I’m going to buy ESC for esp32-ardupilot solution. In this

paper DShot is in ‘Future development’ section. Also, it is in the ‘Old’ section. So the question is whether the firmware supports DShot right now, which ESC should I buy to work with esp32 FW?
Have a nice day!

I assume if DShot doesn’t work you go back to “standard” pwm?
Every modern ESC that supports DShot is also backwards compatible to normal pwm, so there’s no limitation.
I would recommend basically any BLHeli_32 or Bluejay-flashed BLHeli_S ESC

1 Like