AI-Powered Algae Classification System with ESP32-CAM

April 20, 2024

Introduction

Florida’s waterways are critical to its tourism industry and ecological balance, but they are threatened by recurring algae blooms fueled by nutrient runoff and rising temperatures. These blooms can deplete oxygen, harm marine life, and degrade water quality.

To address this, we developed a lightweight AI classification model capable of identifying algae species in real time using an ESP32-CAM chip. This allows researchers and authorities to detect harmful algae blooms quickly in the field.

The system targets species like Karenia brevis (red tide) and Microcystis aeruginosa, and aims to support ongoing ecological preservation efforts in Florida.

Current System Overview

  • Hardware: ESP32-CAM with OV2640 camera mounted on a Nikon microscope via a custom 3D-printed mount.
  • Model: Convolutional Neural Network (CNN) trained on 2000 images across 4 algae classes using TensorFlow.
  • Deployment: Model quantized using ESP-DL, manually ported to the ESP32-CAM using C++.
  • Functionality:
    • Live video stream available via onboard web server.
    • Image classification currently supported via manually uploaded images (live video classification pending).
  • Limitation: Live video-to-classification pipeline was not completed due to time constraints.

Purpose of the New System

Traditional microscopes are expensive and not field-deployable, while low-cost ones lack resolution and require manual classification. This system provides:

  • Field-ready, low-cost analysis
  • Automated classification using AI
  • Improved accuracy (from 50% → 80%)

Unlike previous approaches that used Edge Impulse (limiting code flexibility), this system implements the entire model lifecycle—from development to deployment—using TensorFlow and ESP-DL.

Project Plan

Development Approach

  • Agile methodology with sprint-based planning
  • Hardware and software resources carefully selected and iteratively tested

Hardware Resources

  • Nikon SKT Microscope (100–400x)
  • Aideepen ESP32-CAM board
  • Custom 3D-printed mount
  • USB-A to Micro-USB cable

Software Resources

  • IDE & Tooling: Arduino IDE 2.1.1, ESP-IDF
  • Libraries:
  • Programming: Python 3.10.6, TensorFlow 2.12.0, C++
  • Platforms: Google Colab, GitHub, Trello

Machine Learning Model

Dataset

  • 2000 images of algae and non-algae
  • Original resolution: 240×320 → downscaled to 92×92
  • 5 Classes:
    • Closterium
    • Nitzschia
    • Microcystis
    • Oscillatoria
    • Non-Algae

Model Architecture & Hyperparameters

  • Split: 80% train / 20% test
  • Epochs: 20
  • Optimizer: Adam
  • Loss: Sparse categorical crossentropy

The CNN architecture was specifically built for deployment to ESP32, balancing accuracy and lightweight performance.

Conclusion

This project delivers a deployable, accurate, and flexible AI model for real-time algae detection in the field. By improving on prior work and embracing full-stack control of the AI pipeline, we contribute a valuable tool for environmental monitoring in Florida’s waterways.