Alright, and now some details from Stage 1 of the build.
Here is a sketch of my “functional diagram” to illustrate the plan with the Dev. Kit tube.
Initially I wanted to fit a rechargeable battery pack inside the tube and mount everything to a smart mooring. But the battery pack was too big to fit inside the tube. So I figured this was a good time to try an power the camera from the BM bus.
My first challenge was to setup the Raspberry Pi Zero W with the Debian Bullseye Lite distribution. I used the Raspberry Pi imager tool to setup the SD card and preconfigure the wifi settings. I setup the RPi as a “headless” install so that I could wirelessly SSH into the RPi to update code and transfer files. This will be helpful in the future when the RPi is inside a pressure housing or fully encapsulated in potting and I can’t access the USB ports.
Pro tip: if you plan to SSH into the RPi over wifi, make sure you have the RPi Zero W
or 2W
. I spent two frustrating evenings trying to configure the hardware and get the device to logon to my home wifi network, only to discover that I had an older RPi Zero didn’t have onboard wifi…doh.
Hook up the USB camera and save a picture
My first test was getting a USB camera to save an image to the local disk. I used an early generation DeepWater exploreHD camera. This is an awesome little waterproof camera rated for depths up to 400m. Later on I will switch over to a Raspberry Pi Camera Module v3 since I want to design my own pressure housing - but for now this is a great starting point.
Setup MJPG-Streamer for a USB Camera
Now that I had a RPi wired up to a USB camera it was time to setup a video stream. I followed this tutorial to setup MJPG-Streamer on the RPi. I ran into a few issues installing the correct versions of all the dependencies but eventually I got it to work. For me, the trick was installing this version of NumPy and OpenCV together.
pip install numpy==1.20.0
pip install opencv-python-headless==4.5.3.56
Now I could have the RPi stream video to a web server and access the video stream on my laptop. This was by far the most frustrating AND rewarding part of the project yet. It took me three evenings of reading tutorials + asking Chat GPT for help before I was finally able to get this screen shot, but totally worth it.
Quick power test to see how much juice this unit draws
It was important to quantify how much power the RPi + camera would need because the Bristlefin dev board has limitations on how much power it can supply. To run this test I use a niffty USB power monitor from Adafruit . You plug one side of the power monitor (blue thing) into a power source, then plug the load into the other end and it will display voltage, current , and mAH while the device is running. It’s a fast + easy way to establish the baseline power consumption for a project if you don’t need micro-amp accuracy. The camera was pulling around 1.4 watts while streaming video.
At this point I decided to place the camera inside the Dev. Kit tube behind a clear dome port from Bluerobotics. You could also install this particular camera outside the tube since it is rated for 400m water depth, but I didn’t want to deal with a cable penetration to run the cable from inside the tube to the outside lid. I have access to a 3D printer so it’s easier for me to 3D print a bracket that holds the camera behind the dome port and keep all electronics inside the tube.
I ran a quick test with the camera behind the dome port to check the image quality. Here’s a good write up on the differences between flat and dome ports for underwater photography, which includes illustrations. For best results, the camera sensor should be located at the center of curvature of the dome port. My test was in air so these was not significant difference with and without the dome. That will be different underwater.
Mount the camera to end cap + wire it up
Below is an image of the assembly with the USB camera mounted + wired to a 5V Buck Converter + RPi. During testing I found that the 5V pin on the Dev Kit board could not provide enough current to the RPi to keep it running continuously. To get around this limitation, I wired a Buck Converter to the 12V VOUT
pin. The 12V regulator on the Bristlefin PCBA (big orange board) has a higher max current rating than the 5V regulator and was enough to keep the RPi running and happy.
In this iteration the USB camera is NOT at the center of curvature of the dome port. I was limited on space inside the clear tube so I move the camera closer to the dome to get everything to fit. Not ideal as this will further increase image distortion, but it will work for this first test.
Close up the tube
I used plenty of electrical tape to secure the RPi to one side of the Bristlefin and then shoved the wires inside the tube being careful not to pinch anything when installing the end cap. If this was going to be used for an underwater test then I’d have lubed the o’rings with grease before closing up the tube.
Note on assembly: The tube has a decent volume of air inside that acts like an air spring and fights against you. Bluerobotics sells a pressure vent to make this assembly easier. Worth a try if you plan to open and close your tubes frequently.
Setup RPi for Ad-Hoc network
I wanted to be able to wirelessly SSH into the RPi from my laptop independent of having a local internet connection so that I was not limited to testing my hardware indoors. So I setup the RPi to act as a Hotspot following this tutorial . I hit a few problems when trying to turn DHCP on/off which resulted in me bricking the unit, but luckily I could still access the SD card and fix the issue. That was a good lesson to learn BEFORE I potted the assembly and lost access to the SD card.
Power it up + SSH in + take a picture
Back at the Sofar Pier 28 office I setup my Ebox to power the BM bus continuously and then wired up the camera. After a quick boot I logged onto the hotspot and ran the script to setup the video stream.
Here’s what I captured. Beautiful sunny day in our San Francisco office!
By this point I had discovered a few issues with my assembly that prevented me from getting a completely waterproof seal with the end caps. Unfortunatly the 3D printed bracket that I made was too thick and caused an interference between the Bristlefin PCBA and the end cap with the dome port. This made it impossible to get a sufficient seal to keep the tube dry.
But before making any changes to the hardware I decided to review my goals for STAGE 1. Everything was complete since it did not need to be waterproof.
STAGE 1: use the dev kit as a proof of concept
a. [DONE] get something working quickly, build + test + break ⇒ repeat
b. [DONE] powered by Bristlemouth, but no data transfer over Bristlemouth (yet)
c. [DONE] focus on the software + electrical bits
d. [DONE] don’t worry about waterproofing
Now, on to STAGE 2!