AI Ocean Sensor



There are a variety of ocean mood sensing modalities out there including highly accurate NOAA buoys and satellite systems that check wave action from above. On Maui we try to keep track of worrisome factors like E-Colli and turbidity. Turbidity, or the clarity of the ocean water, varies with the runoff from the sides of volcanoes that we live on. Rainfall on cow, deer and pig denuded landscapes crashes down the slopes and carries tons of brown debris into the ocean--covering the reefs. The sewer systems in the cities re-injects the effluent into wells that try to dissipate the outflow below the clean water lens that we sip our fresh water from. For the most part these systems work! E-colli contamination is rare and the ocean water is only turbid for a few days after one of the seasonal rains. I built a tiny floating buoy that remotely monitors the sea conditions near me and reports it on a web link.
There is a long history of building cheap and open source buoys...they are very tempting since the commercial variety are expensive yet the sensors that run them are cheap. Depending on what you want sensed the options are many: wave height, temperature, location and turbidity. Wave height is usually calculated from algorithms from a 9 DOF sensor or in rarer cases actual ocean pressure. This is the best writeup: https://www.mdpi.com/2076-3263/12/3/110. My buoy uses a simple version of an algorithm based on ChatGPT developed datasets for Edge-Impulse design software with a sleepy battery operated Xiao ESP32S3 with a turbidity sensor and thermometer transmitting data through LoRaWAN to The Things Stack. It is a simple introduction to the problems of amateur ocean sensing.
Supplies




The main unit is contained in a waterproof Pelican case. You can design and print your own but honestly these people know their waterproofing. You will also need clear epoxy, access to a 3D printer and perf board for assembly. The Xiao/LoRa module is incredibly small and gives you access to all the ESP32 pins for development.
- Pelican case 1010 micro case $20
- XIAO ESP32 S3 With Wio-SX1262 Kit for Meshtastic & LoRa For Arduino For SeeedStudio $12
- DF Robot turbidity sensor $12
- DF Robot 6 DOF MPU 6050 $12
- Temp Sensor $2
- Switch Battery/ 2000 mah Litho $4
- Meshtastic 915 MHZ LoRa Antenna 10dBi gain. $15
- TP4056 battery charger $2
Print Your Parts


I use a Bambu P1P printer for best results. All the parts were printed with PETG to minimize deterioration in the severe environment of the ocean. Nothing had to be waterproofed. The multilayer enclosure of the turbidity sensor was due to its sensitivity to external light.
Wire It




The wiring for this device is best done on a perf board. The Xiao unit with its accompanying Wio-SX1262 Kit is soldered to the perf board. The IMU unit is also soldered with pins to the board. The unit that accompanies the turbidity meter that amplifies the signal is bolted to the board with M2 screws. The IMU is connected to the Xiao by I2C. The IMU unit and the amplifier for the Turbidity unit are both powered through D2 and D3 and are powered up in the software to enable low voltage during sleep. The one-wire temp unit is connected to D0 and the turbidity unit is read through D1. Make sure you attach the small antenna for the LoRa sender before you power up the Xiao. The TP battery charger is wired to the battery and its output is sent through the on/off switch to the battery terminals on the back of the Xiao.
Build It










It's necessary to drill three holes through the case to accommodate the turbidity sensor, the temperature sensor and the antenna. The temp sensor is your cheap waterproof cable with three wires and it easily slips through a 1/4 inch hole in the bottom. A surrounding cuff is 3D printed and placed around the cable and filled with epoxy. Use a grinder to scuff the plastic bottom to provide better attachment for the epoxy. The turbidity sensor is a little more difficult as only the clear plastic housing is waterproof and its top portion must be totally potted in epoxy and the wires slipped through the hole in the 3D printed housing. The wires were placed in shrink tubing and carefully sealed at the ends with epoxy. The antenna was also easily potted in an epoxy enclosure with only its connecting wire going through the hole in the top. All the wired connections are made after their connections through the case. The orientation of the IMU unit is important with the Z axis pointing directly upward on the enclosed unit. By following these recommendations there was really no trouble with water ingress. Silicon grease was used on the enclosure inner liner.
Program It

This section was rather difficult for me and I relied on several very well documented case studies. The first problem was getting the Xiao/LoRa system to send data to the The Things Stack. I needed to use sensors connected through my own proprietary Arduino software and this detailed study helped: https://github.com/radiolib-org/radiolib-persistence/blob/main/examples/LoRaWAN_ESP32/notes.md . The config.h file is linked to the setup of your sensor and you must transfer the credentials that you develop on your dashboard on The Things Stack. The LoRaWAN system for communication with your unit requires a base station to get the transmission from your buoy up into the cloud. I have a SenseCap Multi-Platform LoRaWAN Indoor gateway. It allows transmission from multiple buoys up to a couple miles away as long as you have a clear view of the ocean. The connection with the Stack is problematic if you loose power to your unit and multiple checks are necessary to make the connection secure again. The complicated software allows this disruption to proceed without problems on power-up. The temperature reading of the one-wire is very straightforward. The IMU 6050 sensor adaptation to reading ocean waves was based on this great example: https://github.com/radiolib-org/radiolib-persistence/blob/main/examples/LoRaWAN_ESP32/notes.md I used ChatGPT to develop data for an edge impulse project that would represent wave actions of flat water, medium height waves and those over 10 feet. It modeled sinusoidal output series for each of these examples that were used as input for the AI impulse. Here is the project: https://studio.edgeimpulse.com/public/641730/live You can copy the project and play with the data. I then developed a small algorithm to transform the probability outputs of small, medium and large waves to a one to ten output. This information along with the temp and turbidity was sent as hex code to The Things Stack. The data can then be utilized by any web based data repository or dashboard for presentation.
Using It






To deploy the buoy I used a small 3 lb anchor designed for holding a paddle board in place. The buoy has barely enough buoyancy to keep it afloat so I surrounded the antenna with a round float to keep it upright. I deployed it in a series of increasing strength waves and the AI impulse performed rather well at arbitrating the wave height. I did not have access to a wave strength pool which would have made the analysis a lot easier. The device sleeps most of the time and uploads with this software about once every 5 minutes. This can be changed in the .h files. The battery will probably run the device for at least a month. The turbidity sensor was explored in this tutorial: https://www.teachmemicro.com/esp32-turbidity-sensor/ and mine seemed to differentiate beer from coffee. There is an algorithm on the website that makes the connection between voltage and NTU, which is the standard way of reporting water turbidity. The video at the start of the Instructable shows waves that were judged to be 2 ft by the AI. From swimming on a daily basis in the ocean, turbidity is a vague thing with many factors and very regional. Having these micro-sensors as a grid would provide adequate amounts of data to understand if these effects are just wave based sand turbulence or are mitigated by land based effects on the sea.