PeachBot
PeachBot Editorial

I Built AgriVision AI: A Smart Agriculture Project with Raspberry Pi and Edge AI

Academic and industry insights into AI-powered life science platforms.

I Built AgriVision AI: A Smart Agriculture Project with Raspberry Pi and Edge AI

I Built AgriVision AI: A Smart Agriculture Project with Raspberry Pi and Edge AI

Isis Saritha Swapin
Isis Saritha Swapin
Student Researcher (Precision Agriculture)

Agronomy Notice: This article provides general information and insights related to agriculture. It does not replace professional agronomic advice tailored to local conditions, crop types, or regulatory requirements.

I enjoy robotics, electronics and machine learning, so for my school science project I wanted to build something that combines all three. I did not want to make only a display model. I wanted the sensors, pump, camera and AI to actually work.

That is how I started AgriVision AI, a small smart-agriculture system built using a Raspberry Pi 4, a Google Coral USB Accelerator, sensors, a camera and an automatic irrigation pump.

What is AgriVision AI?

AgriVision AI is a working model that watches both the plant and the soil. A soil-moisture sensor checks whether the soil is dry. A temperature and humidity sensor checks the environment. A Raspberry Pi Camera can take a picture of a leaf.

The Raspberry Pi is the main computer. It reads the sensors, controls the pump, runs the dashboard and sends the leaf image to the AI model.

I also use a Google Coral USB Accelerator. It contains an Edge TPU, which is a small processor made for running compatible machine-learning models. This means the AI can work locally instead of sending every picture to a cloud server.

What My Project Can Do

The system can read soil moisture, temperature and humidity. If the soil becomes too dry, it can switch on a small 5 V water pump for a short time.

When I press SCAN LEAF on the dashboard, the camera takes a new image. The machine-learning model checks that image and gives a plant-health result with a confidence score.

LEDs make the result easy to understand during a school exhibition. The dashboard also shows the soil value, temperature, humidity, pump status and the latest AI scan.

How the System Works

CAMERA
   ↓
RASPBERRY PI
   ↓
AI MODEL
   ↓
PLANT HEALTH RESULT


SOIL SENSOR
   ↓
ADS1115
   ↓
RASPBERRY PI
   ↓
SAFETY LOGIC
   ↓
MOSFET
   ↓
5 V WATER PUMP


BME280
   ↓
TEMPERATURE + HUMIDITY
   ↓
RASPBERRY PI
   ↓
DASHBOARD
    

I like this design because the AI part and the irrigation part are separate. Even if I am not scanning a leaf, the Raspberry Pi can still monitor the soil and control the pump.

The Main Parts I Used

Part What I Use It For
Raspberry Pi 4 Main computer and controller
Google Coral USB Accelerator Edge AI inference
Raspberry Pi Camera Module 3 Capturing leaf images
Capacitive soil-moisture sensor Checking whether the soil is dry or wet
ADS1115 Converting the analog soil-sensor signal into a digital value
BME280 Temperature and humidity
5 V mini pump Automatic watering
MOSFET module Safely switching the pump
LEDs and buzzer Showing alerts and results

Why I Needed an ADS1115

This was one of the interesting electronics parts of the project.

The Raspberry Pi GPIO pins are digital. But the soil-moisture sensor gives an analog voltage. So I cannot connect the analog output directly and expect the Raspberry Pi to measure it.

I use an ADS1115 analog-to-digital converter. The soil sensor connects to channel A0 of the ADS1115, and the ADS1115 talks to the Raspberry Pi using I2C.

Soil sensor → ADS1115 A0

ADS1115 SDA → GPIO2
ADS1115 SCL → GPIO3
ADS1115 VDD → 3.3 V
ADS1115 GND → GND
    

Calibrating the Soil Sensor

One thing I learned is that I should not just copy a moisture percentage from somebody else's project.

Different sensors can give different raw values. So I measure my own sensor in dry conditions and call that value DRY_RAW. Then I put it in wet soil and record WET_RAW.

My Python program can then convert readings between those two values into an approximate moisture percentage.

For an exhibition, I can set the pump to start when moisture falls below about 30% and stop when it goes above about 45%.

Having two different values is useful because the pump does not keep rapidly switching ON and OFF around one number. This is called hysteresis.

How I Control the Pump Safely

A Raspberry Pi GPIO pin cannot power a water pump.

The GPIO only gives a small control signal. I use that signal to control a MOSFET, and the MOSFET switches the pump using a separate 5 V power supply.

GPIO17
   ↓
MOSFET
   ↓
5 V PUMP
    

I also added a maximum pump time and a cooldown in the software. This is important because if a sensor gives a wrong reading, I do not want the pump to stay ON and flood the project.

The Machine-Learning Part

The Coral Edge TPU does not train the AI model. Training happens on a computer or cloud machine first.

The process I use is:

Plant images
     ↓
Train MobileNetV2
     ↓
Evaluate the model
     ↓
Convert to TensorFlow Lite
     ↓
INT8 quantization
     ↓
Compile for Edge TPU
     ↓
Run on Raspberry Pi + Coral
    

For the first AgriVision model I selected a small MobileNetV2 with alpha 0.35. The input image size is 224 × 224 pixels.

I selected a small model because Raspberry Pi and Coral are edge devices. I do not need a huge neural network if a smaller one can do the job reliably.

Why My First Model Uses Healthy and Problem

At first, it may sound more exciting to make the AI predict many different diseases. But I think a school project should first be reliable.

So the first public version of my model uses two classes:

HEALTHY
PROBLEM
    

Later I can experiment with more detailed classes.

A two-class model is also easier for me to explain properly. The AI is not claiming to diagnose an exact disease. It is checking whether the leaf looks normal or whether there may be a visible problem that needs inspection.

What is INT8 Quantization?

This sounds complicated, but the basic idea is simple.

Machine-learning models normally use numbers for their calculations. A large model may use higher-precision numbers that need more memory and computing power.

With INT8 quantization, many calculations use 8-bit integers. This can make the model smaller and more suitable for edge hardware.

It is also important for running compatible models efficiently on the Coral Edge TPU.

What is Edge AI?

Edge AI means running AI close to where the data is created.

In my project, the camera is connected to the Raspberry Pi. The plant image can be processed locally using the Coral instead of sending every image over the Internet.

That is useful for places where Internet access is slow or unavailable.

Training and Inference Are Different

This is an important machine-learning concept.

Training is when the model learns patterns from labelled images.

Inference is when I give the already-trained model a new leaf image and ask it to make a prediction.

TRAINING

Many labelled images
        ↓
Model learns


INFERENCE

One new leaf image
        ↓
Model predicts
    

The Dashboard

I made a local web dashboard so I can see what the system is doing.

It shows plant status, AI confidence, soil moisture, temperature, humidity, pump status and the latest scan.

I also added a SCAN LEAF button. When I press it, the Raspberry Pi takes a new picture and runs inference.

Because it is a local Flask dashboard, I can open it on the Raspberry Pi or another device connected to the same local network.

How I Would Demonstrate It at School

First I would explain that AgriVision AI combines robotics, sensors, automation and machine learning.

Then I would show the soil sensor. I can move it into a prepared cup of dry soil. The moisture percentage drops, and when it crosses the set value, the Raspberry Pi safely activates the pump.

Next I would place a leaf or test image in front of the camera and press SCAN LEAF.

The dashboard then shows the AI result and confidence.

Finally, I would point to the Coral USB Accelerator and explain that the neural-network inference is running locally at the edge.

If You Want to Build This for Your School

My suggestion is not to connect everything on the first day.

First make the Raspberry Pi work. Then test the camera. After that test the soil sensor and ADS1115. Then test the LEDs and buzzer. Then test the MOSFET and pump for only one or two seconds.

Test the Coral separately with an example model before trying the AgriVision model.

When every part works separately, connect them into one system.

Debugging becomes much easier this way.

Important Safety

Water and electronics are not a good combination, so I keep the water tank physically lower and away from the Raspberry Pi.

I use only a small low-voltage 5 V pump for the school model.

The pump is never powered from a GPIO pin, and I always switch off the Raspberry Pi before changing the camera cable or rewiring the breadboard.

If you are building this project at school, ask a teacher or an adult who understands electronics to check the wiring before switching it on.

What the AI Cannot Do

AgriVision AI is a school and research prototype.

I do not say that it can professionally diagnose a crop disease.

Real farms have many things that can confuse an image model, including sunlight, shadows, dust, damaged leaves, insects, different cameras and different plant varieties.

So I prefer the result:

Possible visible plant-health problem. Inspect the plant.

instead of saying:

This plant definitely has a particular disease.

Machine learning is useful, but we should also understand its limits.

Things I Want to Try Next

After the basic system works well, I want to experiment with more plant classes, crop-specific models, multiple soil sensors, different irrigation zones, pest detection, long-term sensor graphs, solar power and LoRa communication.

I also want to test how well the AI works on real outdoor images instead of only controlled leaf images.

Get the Code

I have made the AgriVision AI source code public so other students and teachers can study it, build it and improve it.

GitHub:
github.com/swapins/agrivision-ai-pi

You can clone it using:

git clone https://github.com/swapins/agrivision-ai-pi.git
cd agrivision-ai-pi
    

AgriVision AI Model

PeachBot also has a Hugging Face repository for the AgriVision model. Verified model files will be added there after training and testing.

Hugging Face:
peachbotAI/agrivision-mobilenetv2-edge-tpu

I think publishing the code and model is useful because another student should be able to see how the project works instead of treating the AI as a black box.

What I Learned

The biggest thing I learned from AgriVision AI is that machine learning by itself is only one part of a real system.

The camera has to give a good image. The sensors have to be calibrated. The pump has to be controlled safely. The software has to handle errors. The AI model has to be tested properly.

Robotics becomes much more interesting when sensors, programming, electronics and machine learning all work together.

About the Project

AgriVision AI
Raspberry Pi + Coral Edge TPU Smart Agriculture Project

Developed by: Isis Saritha Swapin
Class VIII • PeachBot Author

Contributor: Swapin Vidya

Published by: PeachBot AI

peachbot.in  •  Author Profile  •  Source Code

I think the best science project is one where I can explain every part, not just show that it works.