Tutorials
September 16, 2024

Automated agriculture: Building a DIY hydroponic gardening system

Written by
Arielle Mella
Developer Advocate

Outdoor gardening and nurturing indoor plants have been a long-time hobby of mine. There's something truly refreshing about being surrounded by beautiful, lush greenery.

My outdoor garden, in particular, has always been focused on flowers. I’ve carefully tended to a mix of annuals and perennials throughout the seasons, killing and bringing to life many species of flora over the years, trying to put the jungle in my concrete jungle apartment.

Arielle's garden in New York City is begin shown. In it, you can see her dog sniffing the flowers on her porch.
A look into the current plant setup in my apartment.

I’ve always been intrigued by the idea of growing my own vegetables and herbs. The thought of cultivating fresh produce is appealing, but I’ve often felt overwhelmed by the perceived complexity—the care, knowledge, monitoring, and maintenance that produce requires. 

I began to wonder: could I create a system that allows me to grow plants with the precision and care of a professional botanist and transform from city girl to farmer with a few lines of code? 

This curiosity led me to the concept of building a hydroponic garden indoors. 

My vision is to grow herbs and vegetables from the comfort of my own home while integrating hardware and software to collect data, leverage machine learning, and manage my garden remotely. This system would provide real-time insights into my garden’s needs, ensuring each plant gets exactly what it needs to thrive. 

Developing my hydroponic gardening system

My research began with exploring existing indoor hydroponic grow systems.

It felt like a real-life Goldilocks situation: one system was far too extravagant—both in size and cost, priced at several months’ rent—yet it featured an appealing remote monitoring app. Another system was too small, producing only three herb varieties per month, which wouldn’t satisfy my constant need for cilantro. 

As I dug deeper into the soil of my research, I stumbled upon online communities that built their own hydroponic setups. I was surprised to discover just how vast this sub-community is, with enthusiasts creating everything from compact desktop systems to large-scale setups that fill entire backyards, growing enough arugula to feed entire neighborhoods.

The videos found within the #hydroponicgardening on TikTok. Views from the top posts are as high as 4.7 million.
A quick look into hydroponic gardening on TikTok shows a large and engaged community.

This vibrant community inspired me to build my own setup with Viam— one where I could have complete control over my plants’ growth, lighting, water, and nutrient distribution, and, most importantly, design the smart monitoring system of my dreams. 

A screenshot showing that Reddit has a thriving hydroponics community, made up of 135 thousand garden enthusiasts. The specific post highlighted shows someone's hydroponic gardening system set up within their own home. They're growing tomatoes, avocados, lettuce, basil, and a lemon tree.
Reddit has a thriving hydroponics community, made up of 135 thousand garden enthusiasts.

Leaning into the Kratky method for hydroponics 

What is the Kratky method?

After researching various hydroponic techniques, I used the Kratky method for my garden. The Kratky method is a passive form of hydroponics, making it ideal for beginners or anyone looking for a simple, cost-effective setup. 

This approach allows me to monitor the root system and water nutrient levels closely, which is crucial for ensuring healthy plant growth.

Diagram describing the Kratky method enabling a plant's growth. The image shows the container fit with a nutrient solution with water filled to the top. After 30 days, the plant sitting on top of the container has grown drastically, while the water has depleted.
Diagram describing the Kratky method enabling a plant's growth. (source)

How does the Kratky method work?

The Kratky method is essentially a simplified version of the Deep Water Culture (DWC) technique, another common hydroponic method. In a typical DWC setup, plants are suspended in special pots or nets, with their roots fully submerged in a reservoir of aerated, nutrient-rich water. 

This setup provides continuous access to nutrients while requiring air pumps to oxygenate the water.

Diagram describing the Deep Water Culture approach, the non-ideal version for this project.
Diagram describing the Deep Water Culture approach, the non-ideal version for this project (source

The Kratky method, however, offers a clever twist on the DWC approach by eliminating the need for air pumps. Instead, it maintains a 3-4 cm gap between the plant holder and the water surface. This gap allows air to circulate around the roots, providing the necessary oxygen without the need for additional equipment.

By suspending the plants slightly above the water level instead of having them float directly on top, the Kratky method simplifies the overall hydroponic setup. It reduces both the cost and complexity while still providing an efficient way to grow a variety of plants indoors.

Designing my hydroponic garden

Hydroponics is relatively straightforward: germinate seeds, grow them in oxygenated water without soil, and, ideally, enjoy the benefits of a flourishing indoor garden. 

To keep costs low, I started by exploring inexpensive PVC pipe systems that I could build indoors.

Arielle's initial concept sketch for the hydroponic garden. This shows how the plants would sit within a glass enclosure, on top of a water tray.
My initial concept sketch for the hydroponic garden.

Setting up visual tracking

To document the growth process of my plants, I wanted to create a timelapse with images and use the images to train custom ML models. For this, I’m using Viam to collect image data from a camera, capturing every stage of my plants’ development. 

Monitoring the garden’s environment and health

Alongside visual tracking, I needed to to monitor crucial environmental factors such as ambient temperature, humidity, and other conditions to ensure my plants were thriving. 

Viam’s built-in sensor modules make it easy to monitor these variables without having to write extensive code, streamlining the setup and management of the system.

A look at some of the built-in environmental sensor modules found in the Viam app.
A look at some of the built-in environmental sensor modules found in the Viam app.

Maintaining the right nutrient balance is essential in hydroponics, so I needed a way to track the pH levels of the water and the nutrients I’m adding. I found an affordable pH sensor compatible with a Raspberry Pi, which I plan to integrate into Viam’s Registry by creating a custom module. 

I’m also incorporating flow sensors to monitor water circulation and ensure that plant roots aren't clogging the system.

Materials needed for this project include (from left to right): PH sensor, BME280, BME680, Raspberry Pi 5, and a webcam. 
Materials needed for this project include (from left to right): PH sensor, BME280, BME680, Raspberry Pi 5, and a webcam. 

By gathering all this data, I can create a customized app using Viam, centralizing all the monitoring and data collection. This will allow me to build a truly smart hydroponic system with all the functionalities I need to maintain my garden effortlessly.

Kicking off germination

To kickstart my indoor hydroponic garden, I bought a variety of seeds to experiment with and chose those with relatively low germination times. I decided to begin with arugula, basil, buttercrunch lettuce, cilantro, parsley, and bibb lettuce—all favorites that I love to use in salads and as meal toppings. 

Photos of the germination process on day 0 and day 12. 

The germination process itself is quite hands-on: I place the seeds between damp paper towels, moisten them with filtered water to maintain a neutral pH, and then seal them in Ziploc bags to create a humid environment. 

Then comes the most exciting part—waiting for the first signs of sprouting and building a robot to monitor that process.

Building the Germination Station

While waiting for the seeds to sprout, I used Viam to set up a simple yet effective monitoring system to ensure ideal conditions for germination. I built this system using a webcam, a BME680 environmental sensor, and a Raspberry Pi, allowing me to capture thousands of images to visually track the growth process

Real-time sensor data visualized through Viam's app interface.
Monitoring the seeds’ germination within Viam’s Data Management Service.

Alongside the images, I also gathered sensor data to monitor critical environmental factors such as temperature, pressure, humidity, and gas levels—all essential for maintaining a balanced greenhouse environment. 

Real-time sensor data visualized through Viam's app interface.
Real-time sensor data visualized through Viam's app interface.

For successful germination, I aimed to keep the temperature within the ideal range of 65–70 degrees Fahrenheit. Initially, I placed the germination bags by a window in a plastic container, but the sensors quickly showed that temperatures reached up to 90 degrees in direct sunlight. 

This data alerted me to relocate my seedlings promptly to prevent them from overheating and ensure they stayed in a nurturing environment. 

Taking my DIY hydroponic system to the next level

This project began with a simple question: Can I grow my herbs and vegetables indoors with the precision of a professional botanist? 

By combining a DIY hydroponic setup with a smart monitoring system using Viam, I was able to create an environment where I could control and optimize every aspect of plant growth, from the nutrient levels in the water to environmental conditions. 

Using sensors, a webcam, and a Raspberry Pi 5, I’ve built a system to help monitor key variables like temperature, humidity, and the visual rate of growth remotely to ensure ideal growing conditions. This approach has not only demystified the process of hydroponic gardening but also made it more accessible and manageable for a small indoor setting.

There’s still work to be done, many variables to test and refine, and more data to collect as the plants grow. The progress so far proves that with the right tools and the power of open-source software, it’s entirely possible to design a smart hydroponic system. The next steps in this project include: 

  • Training custom ML models on the plants' growth to use that data for future crops
  • Building a module for a pH sensor to track nutrient changes in the hydroponic setup 
  • Building a custom monitoring app leveraging Viam’s APIs to have a dashboard of information available about the garden 

Build your own hydroponic gardening system

If you’re considering starting your own smart hydroponic garden, don’t let the perceived complexity hold you back– start small, learn as you go, build your system modularly, and build a system with Viam that fits your plant-growing needs. 

Check out our Codelabs for more tutorials, and if you have any questions, join the conversation in our Discord community or connect with me on TikTok!

On this page

Get started with Viam today!