Building a Lego-powered Submarine 4.0 – automatic depth control

This radio-controlled submarine can maintain a steady depth or a certain distance from the bottom. It is equipped with a pressure sensor and a laser distance sensor. Raspberry Pi and PID control are used for automation. Tested in a swimming pool and a small river (at the end of the video). Enjoy!

0:00 building
2:36 tests in water
3:48 long journey in a small river
6:47 full Python code

SPECS
Displacement: 2.4 kg (5.3 lb)
Test depth: 1.5 m (5 ft)
Hull: acrylic plastic cylinder (250x110x3mm), SAN plastic lid (2mm thick)
Lid seal: o-ring 2.5 mm (NBR 70 shore)
Ballast tank: 60 ml syringe (Eotia marinade injector), Lego EV3 Medium Servo motor (45503)
Forward propeller: drone propeller (Diatone Bull Nose 4×4.5), Lego PF L-motor (88003)
Turn propeller: Lego propeller 3 blade (6041), Lego PF M-motor (8883)
Magnetic couplings: K&J Magnetics D38-N52 neodymium magnet, TapeCase 423-5 UHMW Tape, silicon spray
Motor driver: 2x Pololu 2130 DRV8833 Dual H-bridge
Radio control: 27 MHz controller dissembled from a toy submarine (no-name chinese Mini U Boat)
Pressure sensor: Honeywell SSCMANV030PA2A3 2 bar
Laser distance sensor: SparkFun TFMini-S Micro
Computer: Raspberry Pi Zero 2 W
Power supply: Lego Rechargeable Battery Box 9V (8878), Pololu 2123 S7V8F5 5V voltage regulator

MORE DETAILS
https://brickexperimentchannel.wordpress.com/rc-submarine-4-0-blog-post-series/

CODE
https://mega.nz/folder/wqhhxJoI#cHnVI6NjaPkfZcdZvFZZ0Q
or
https://www.dropbox.com/sh/u8a45maz3brrwrw/AADbUx9VZEw5UJPny1bJI-Lwa

PREVIOUS SUBS
1.0 syringe ballast https://www.youtube.com/watch?v=tGEZApd9MMk
2.0 magnetic couplings https://www.youtube.com/watch?v=MdfUSNzc0Xk
3.0 balloon and compressor https://www.youtube.com/watch?v=n83cSg3wohU

MUSIC
Tommy Baynen – Stone Paths
https://www.youtube.com/watch?v=zepP1zdiUPI
https://colorize.ffm.to/0364
https://soundcloud.com/tommybaynen