---
title: "Let's Make Your Underwater Drones - A Foundation for Sensor-Based Mobility Project"
url: "https://maker.wiznet.io/TheoIm/projects/lets-make-your-underwater-drones-a-foundation-for-sensor-based-mobility-project/"
markdown_url: "https://maker.wiznet.io/TheoIm/projects/lets-make-your-underwater-drones-a-foundation-for-sensor-based-mobility-project/md"
type: "UCC: User Created Content"
author: "e-masafumi"
author_url: "https://github.com/e-masafumi/AUV-EM-W5500pico2-N100/blob/main/main.cpp"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "e-masafumi"
original_url: "https://github.com/e-masafumi/AUV-EM-W5500pico2-N100/blob/main/main.cpp"
published: "2025-05-28"
language: "en"
hardware: ["WIZnet W5500-EVB-Pico2"]
likes: 0
views: 1469
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Let's Make Your Underwater Drones - A Foundation for Sensor-Based Mobility Project

> This project provides an automatic depth control and sensor logging system for an underwater drone. But it's more than just a drone controller.

Original author: e-masafumi (source: https://github.com/e-masafumi/AUV-EM-W5500pico2-N100/blob/main/main.cpp)

## Components

- **WIZnet W5500-EVB-Pico2** x 1 ([docs](https://wiznet.io/products/powered-by-raspberry-pi/w5500-evb-pico2))

## Article

This project provides an automatic depth control and sensor logging system for an underwater drone. But it's more than just a drone controller — it demonstrates a solid architecture for a wide range of **sensor-based mobility systems** (e.g., underwater ROVs, ground robots, autonomous platforms). With features like sensor integration, multicore processing, real-time control, and a UART-based command interface, this structure can be directly adapted for various maker applications.

---

## 🧠 Key Features Overview

| Feature | Description |
| --- | --- |
| **Auto Depth Control** | Maintains target depth using pressure sensor and PID control logic to adjust thruster output |
| **Sensor Integration** | Collects real-time data from MS5837 (temperature/pressure), BNO055 (IMU), INA228 (voltage/current), and GPS (NMEA) |
| **Manual/Auto Mode Switch** | Receives UART commands to switch control modes or issue manual motor control |
| **Multicore Logging** | Core0 handles control loop; Core1 handles CSV data logging to SD card |
| **Structured Logging** | Uses FATFS on SD card to store structured log entries in `log.txt` |
| **Power Safety Check** | Stops thrusters and activates LED warning if voltage drops below safe threshold |

---

## 🔧 Used Libraries and Interfaces

| Library / Driver | Purpose |
| --- | --- |
| `func-pwm.h` | Motor PWM control (0–100%) |
| `func-i2c.h` | I2C setup and communication |
| `func-MS5837-02BA.h` | Pressure + temperature sensor driver |
| `func-BNO055.h` | IMU and magnetometer driver |
| `func-INA228.h` | Voltage/current/power sensing |
| `func-usbuart.h` | USB-UART command interface |
| `sd_card.h`, `ff.h` | FATFS-based SD card logging |

---

## ⚙️ System Flow Overview

Initializes sensors, PWM, and SD card

Core1 creates and prepares the log file

Core0 collects sensor data and performs PID control every loop

UART commands change control mode, target depth, or gain in real-time

Sends `LOG_WRITE_COM` to Core1 to trigger log entry

Stops all motors + flashes LED on power fault

---

## 📦 Applications

This code structure can be applied directly to:

Depth-stable underwater drones (ROVs)

RC boats with autonomous navigation

Land robots with GPS/IMU integration

Data-logging platforms with SD card backup

Multi-sensor integration testbeds

---

## 🎮 UART Command Examples

| Command | Description |
| --- | --- |
| `12345` | Initiates start sequence |
| `0` | Confirms start and begins loop |
| `-1111` | Switch to manual mode |
| `-8888` | Return to auto mode |
| `-9999` | Stop system immediately |
| `n000m` | Sets motor n to m% duty (e.g., 30045 = motor 3, 45%) |

---

## 📎 Final Thoughts

This is more than a depth controller for drones — it’s a **template for structured, sensor-centric control systems**. The modular design supports reuse across various robotics and mobility projects.

📁 The code includes everything from driver-level I2C communication and PWM logic to FATFS logging and multicore operation. You can extract and apply any part of it to your own builds.

What makers often need isn't more hardware — it's a good starting point. **This project can be that starting point.**

---

Source: https://maker.wiznet.io/TheoIm/projects/lets-make-your-underwater-drones-a-foundation-for-sensor-based-mobility-project/
