With ESP32 rover or sailboat autonomous

Good morning,

I would like to make a sailboat autonomous
I looked at Ardupilot and the project is very good but I would like it to work with an esp32 if possible ESP32S2 or ESP32C3.
It is indicated as under development…
Firstly, an installation on an electric car to familiarize yourself

Can someone give me a link please

Why? Use a supported Flight Controller.

“I want to use a BIC Lighter to make toast”…

Very funny but you should first find out or keep quiet if you are too lazy to do so.

You can also read up here and here.
Getting ArduPilot to run on an esp32 has been an ongoing endeavour for some time now with limited success so far.

That’s why Dave suggested to go with an existing and established flight controller to get your boat running.

And you didn’t answer his question: why do you want to use an esp32?
Do you want to tinker with an esp and ArduPilot is a good excuse or do you want your sailboat to be autonomous in a reasonable amount of time?

Why an esp32?
Because I practice it well, because I know how to use almost all the bricks:

  • AS5600 for controlling the outputs of power drivers for winches or rudders (I don’t trust the model servo) as well as the weather vane.
  • Mosfet control of DC motors
  • Reading RC receiver outputs
  • Reading GPS data
  • Reading roll and pitch data with an mpu9255 or BNO080
    But I don’t know how to make a compass with tilt compensation (useful for a sailboat which is never horizontal and which may have to do a reset due to a discharged battery)
    LiFe battery charging with solar cells and protection by providing microcontroller startup only from a voltage of 3V.
    Reading GPS data
    Use of recordings with preferences, Sd, transmission by wifi or even commands with espNow at a relatively short distance.
  • OTA

Not that I’m an expert but there are excellent tutorials on the Internet and I’m the type to start with something that works in coding and then adapt or add and checking step by step that it still works.

Why not get a Pixhawk microcontroller? Mainly a cost issue. If initially during the tests we can hope to recover the sailboat for long distance tests, the loss of the boat is probable and therefore of its equipment.
I am looking to reserve my budget for a satellite receiver

Finally, how to develop this activity towards others if we start by saying that the starting budget is high.

Seeing the increasingly small number of fans of Tenrater, Marblehead and IOM compared with the development in recent years of the Dragon Force 65, it is obvious that we must aim for small budgets.

In general, airplane, car and multicopter enthusiasts are not budget-conscious, model boat and sailboat modelers are.

Afterwards can we consider using Omnibus F4 Pro Flight Controller V3 from Ali https://fr.aliexpress.com/item/32786897764.html
the budget would be bearable for a rover which would allow one to become familiar with Ardupilot

I have followed the many futile attempts, and some successes, but still wonder why bother even after reading your lengthy post.
The Discord channel may be a better venue.

1 Like

If you’re at a point where you’re frustrated because it didn’t work out with the ESP32, please don’t buy an autopilot with F4 processor, but spend the $20 more to get an H7-based board. Even if you’re budget conscious (which, contrary to your claim, most people who are into the hobby are, at least from my experience. The ones who buy the expensive stuff are either newcomers who believe they’ll start out the “right” way if they just throw money at it, or experienced/commercial users who need all the features and redundancy).

Good luck with your project, genuinely. It’s not going to be easy.

I don’t really understand the budget consideration here. By the time you buy an ESP32 and all of the required peripheral components along with a mounting and wiring solution for all of it, your cost will almost certainly exceed that of the cheap F4 boards.

As an exercise in exploration, I get it. As a way to keep cost low…not so much.

1 Like

One thing to notice is that the ESP32 comes without any sensors. You need to add them, what will make the endeavor more expensive. Still if you go with a cheap MPU9250 IMU you should be cheaper off exclusive the time to solder everything together.

I’m experimenting with the ESP32, too. Mainly because I have a tons of ESP32 floating around and it’s not so hurtful when I break one.

I had quite some success getting the rover up to work. The newer version 4.6 works like a charm. Make sure you have a Linux dev environment

here we really start to make our mouths water.

Configuration of the whole?
Version 4.6: link to download

All I ask: to have a set that works even if it doesn’t quite do what I want; the important thing is to start with just one thing and make it evolve.

Just check out the latest version of the code from git GitHub - ArduPilot/ardupilot: ArduPlane, ArduCopter, ArduRover, ArduSub source. Follow the instructions to setup the ESP32 environment (works really well under Ubuntu) and compile it with ./waf

In AP_HAL_ESP32 I created this custom board for ESP32 devkit v4. It has limitations (only 6 Rcouts, and I’m still trying to figure out, if I can trade Rcouts for Aux) but for a sailboat it should be enough. Here’s my config. Give it a try. With the right enviroment it should be straightforward.
Happy coding!

/*
 * This file is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This file is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#pragma once

#define HAL_ESP32_BOARD_NAME "esp32-devv4"

// make sensor selection clearer
#define PROBE_IMU_I2C(driver, bus, addr, args ...) ADD_BACKEND(AP_InertialSensor_ ## driver::probe(*this,GET_I2C_DEVICE(bus, addr),##args))
#define PROBE_IMU_SPI(driver, devname, args ...) ADD_BACKEND(AP_InertialSensor_ ## driver::probe(*this,hal.spi->get_device(devname),##args))
#define PROBE_IMU_SPI2(driver, devname1, devname2, args ...) ADD_BACKEND(AP_InertialSensor_ ## driver::probe(*this,hal.spi->get_device(devname1),hal.spi->get_device(devname2),##args))

#define PROBE_BARO_I2C(driver, bus, addr, args ...) ADD_BACKEND(AP_Baro_ ## driver::probe(*this,std::move(GET_I2C_DEVICE(bus, addr)),##args))
#define PROBE_BARO_SPI(driver, devname, args ...) ADD_BACKEND(AP_Baro_ ## driver::probe(*this,std::move(hal.spi->get_device(devname)),##args))

#define PROBE_MAG_I2C(driver, bus, addr, args ...) ADD_BACKEND(DRIVER_ ##driver, AP_Compass_ ## driver::probe(GET_I2C_DEVICE(bus, addr),##args))
#define PROBE_MAG_SPI(driver, devname, args ...) ADD_BACKEND(DRIVER_ ##driver, AP_Compass_ ## driver::probe(hal.spi->get_device(devname),##args))
#define PROBE_MAG_IMU(driver, imudev, imu_instance, args ...) ADD_BACKEND(DRIVER_ ##driver, AP_Compass_ ## driver::probe_ ## imudev(imu_instance,##args))
#define PROBE_MAG_IMU_I2C(driver, imudev, bus, addr, args ...) ADD_BACKEND(DRIVER_ ##driver, AP_Compass_ ## driver::probe_ ## imudev(GET_I2C_DEVICE(bus,addr),##args))

//------------------------------------


//-----INS/IMU-----
#define HAL_INS_DEFAULT HAL_INS_MPU9250_SPI
#define HAL_INS_MPU9250_NAME "mpu9250"
#define HAL_INS_PROBE_LIST PROBE_IMU_SPI( Invensense, HAL_INS_MPU9250_NAME, ROTATION_NONE)


//-----COMPASS-----
// Not recognized
//#define AP_COMPASS_AK8963_ENABLED TRUE
//#define HAL_MAG_PROBE_LIST PROBE_MAG_IMU(AK8963, mpu9250, 0, ROTATION_NONE) // Default

// Check I2C PORT and enable flag when adding external I2C Compass
#define AP_COMPASS_QMC5883L_ENABLED TRUE
#define HAL_MAG_PROBE_LIST PROBE_MAG_I2C(QMC5883L, 0, 0x0D,true , ROTATION_NONE)


#define HAL_PROBE_EXTERNAL_I2C_COMPASSES 1


#define ALLOW_ARM_NO_COMPASS				1


// -----BARO-----
#define HAL_BARO_DEFAULT HAL_BARO_BMP280_SPI
#define HAL_BARO_BMP280_NAME "BMP280"
#define HAL_BARO_PROBE_LIST PROBE_BARO_SPI(BMP280, "bmp280")
// allow boot without a baro
#define HAL_BARO_ALLOW_INIT_NO_BARO 1


// -----no airspeed sensor-----
#define AP_AIRSPEED_MS4525_ENABLED 0
#define AP_AIRSPEED_ENABLED 0
#define AP_AIRSPEED_ANALOG_ENABLED 0
#define AP_AIRSPEED_BACKEND_DEFAULT_ENABLED 0

// -----ADC -----
// ADC is available on lots of pints on the esp32, but adc2 cant co-exist with wifi we choose to allow ADC on :
//#define HAL_DISABLE_ADC_DRIVER 1
#define TRUE 1
#define HAL_USE_ADC TRUE

// the pin number, the gain/multiplier associated with it, the ardupilot name for the pin in parameter/s.
//
// two different pin numbering schemes, both are ok, but only one at a time:
#define HAL_ESP32_ADC_PINS_OPTION1 {\
	{ADC1_GPIO35_CHANNEL, 11, 1},\
	{ADC1_GPIO34_CHANNEL, 11, 2},\
	{ADC1_GPIO39_CHANNEL, 11, 3},\
	{ADC1_GPIO36_CHANNEL, 11, 4}\
}
#define HAL_ESP32_ADC_PINS_OPTION2 {\
	{ADC1_GPIO35_CHANNEL, 11, 35},\
	{ADC1_GPIO34_CHANNEL, 11, 34},\
	{ADC1_GPIO39_CHANNEL, 11, 39},\
	{ADC1_GPIO36_CHANNEL, 11, 36}\
}
// pick one:
//#define HAL_ESP32_ADC_PINS HAL_ESP32_ADC_PINS_OPTION1
#define HAL_ESP32_ADC_PINS HAL_ESP32_ADC_PINS_OPTION2


// ------------------------------------------------------------------
// uncommenting one or more of these will give more console debug in certain areas.. ... 
// ...however all teh extra printf's use a lot of stack, so best to limit yourself to only uncommenting one at a time
//#define STORAGEDEBUG 1
//#define SCHEDDEBUG 1
//#define FSDEBUG 1
//#define BUSDEBUG 1 //ok
//#define WIFIDEBUG 1 //uses a lot?
//#define INS_TIMING_DEBUG 1 //define this to see all the imu-resets and temp resets and imu timing info on the console.

// 2 use udp, 1 use tcp...  for udp,client needs to connect as UDPCL in missionplanner etc to 192.168.4.1 14550  tcp: 5760
#define HAL_ESP32_WIFI 2

// tip: if u are ok getting mavlink-over-tcp or mavlink-over-udp and want to disable mavlink-over-serial-usb
//then set ardupilot parameter SERIAL0_PROTOCOL = 0 and reboot.
// u also will/may want..
//LOG_BACKEND_TYPE 1
//LOG_DISARMED 1
//SERIAL0_PROTOCOL 0
//#define SERIAL1_PROTOCOL 5
//#define SERIAL1_BAUD 115


// see boards.py
#ifndef ENABLE_HEAP
#define ENABLE_HEAP 1
#endif

#define WIFI_SSID "ardupilot123"
#define WIFI_PWD "ardupilot123"

// ------------------------------------------------------------------------------------
//RCOUT which pins are used?

#define HAL_ESP32_RCOUT { GPIO_NUM_25,GPIO_NUM_27, GPIO_NUM_33, GPIO_NUM_32, GPIO_NUM_13, GPIO_NUM_12 }
//#define HAL_ESP32_RCOUT { GPIO_NUM_25,GPIO_NUM_27, GPIO_NUM_33, GPIO_NUM_32, GPIO_NUM_13, GPIO_NUM_12, GPIO_NUM_26, GPIO_NUM_15, GPIO_NUM_8, GPIO_NUM_7}



// ------------------------------------------------------------------------------------
// SPI BUS setup, including gpio, dma, etc
// note... we use 'vspi' for the bmp280 and mpu9250
#define HAL_ESP32_SPI_BUSES \
    {.host=VSPI_HOST, .dma_ch=1, .mosi=GPIO_NUM_23, .miso=GPIO_NUM_19, .sclk=GPIO_NUM_18}
// tip:  VSPI_HOST  is an alternative name for esp's SPI3
//#define HAL_ESP32_SPI_BUSES {}


// SPI per-device setup, including speeds, etc.
#define HAL_ESP32_SPI_DEVICES \
    {.name= "bmp280", .bus=0, .device=0, .cs=GPIO_NUM_2,  .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}

// ------------------------------------------------------------------------------------
//I2C bus list
#define HAL_ESP32_I2C_BUSES \
	{.port=I2C_NUM_0, .sda=GPIO_NUM_21, .scl=GPIO_NUM_22, .speed=400*KHZ, .internal=true}
//#define HAL_ESP32_I2C_BUSES {} // using this embty block appears to cause crashes?

// ------------------------------------------------------------------------------------
// rcin on what pin?
#define HAL_ESP32_RCIN GPIO_NUM_4

// ------------------------------------------------------------------------------------
//HARDWARE UARTS
#define HAL_ESP32_UART_DEVICES \
  {.port=UART_NUM_0, .rx=GPIO_NUM_3, .tx=GPIO_NUM_1 },\
  {.port=UART_NUM_1, .rx=GPIO_NUM_16, .tx=GPIO_NUM_17 }
//  {.port=UART_NUM_2, .rx=GPIO_NUM_8, .tx=GPIO_NUM_7 } // Doesnt work, esp32dev doesnt start


// ------------------------------------------------------------------------------------

//#define AP_FILESYSTEM_ESP32_ENABLED 1

// Do u want to use mmc or spi mode for the sd card, this is board specific ,
//  as mmc uses specific pins but is quicker,
// #define HAL_ESP32_SDMMC 0
// // and spi is more flexible pinouts....  dont forget vspi/hspi should be selected to NOT conflict with SPI_BUSES above
// //#define HAL_ESP32_SDSPI {.host=VSPI_HOST, .dma_ch=2, .mosi=GPIO_NUM_2, .miso=GPIO_NUM_15, .sclk=GPIO_NUM_14, .cs=GPIO_NUM_21}

// #define HAL_ESP32_SDCARD 0
// #define LOGGER_MAVLINK_SUPPORT 0
#define HAL_BOARD_LOG_DIRECTORY "/SDCARD/APM/LOGS"
#define HAL_BOARD_TERRAIN_DIRECTORY "/SDCARD/APM/TERRAIN"
#define HAL_BOARD_STORAGE_DIRECTORY "/SDCARD/APM/STORAGE"

// // this becomes the default value for the ardupilot param LOG_BACKEND_TYPE, which most ppl want to be 1, for log-to-flash
// // setting to 2 means log-over-mavlink to a companion computer etc.
// #define HAL_LOGGING_BACKENDS_DEFAULT 1

// ------------------------------------------------------------------------------------
#define HAL_ESP32_RMT_RX_PIN_NUMBER 4

A big thank-you

However, I have a problem: I only use Linux with my raspberry pi…
I am comfortable in arduino IDE and I work under win10

So if I want to follow I will need more explanation.

When we arrive at GitHub - ArduPilot/ardupilot: ArduPlane, ArduCopter, ArduRover, ArduSub source

“Follow the instructions to configure the ESP32 environment”

Sorry but where are these instructions?

“(works very well under Ubuntu)”
Without starting a Windows/Linux war we should also get there with Win10

" and compile it with ./waf "
I can see a waf directory but it’s python I need more explanations.

I’ll keep looking but I’m very hopeful that I’ll get some help.

https://ardupilot.org/dev/docs/building-the-code.html

You seem out of your depth in a vain attempt at saving a very small amount of money. I’m not saying you won’t succeed, but you’re taking an awfully long road here.

1 Like

Use a VM with Ubuntu 22.04 LTS, install git, clone the Ardupilot repo, run ./install-prereqs-ubuntu.sh in Tools/environment_install.

The building instructions are in the ESP32 libraries folder.

thanks for the help

I’m going to do this.

Install a VM… It’s been a long time since I did this to test…

I will come back to you when I have progressed

WSL is the way to go. It’s in the docs.