Hydro 9000

ABOUT

In this project, I create a device to water five indoor potted plants by measuring the moisture level in the soil and automatically pumping water when it becomes too dry. The device is powered by a standard 5 volt USB cable and pumps water from a reservoir (I reuse an empty tub of peanut-butter pretzels).

This was the first time I’ve used a 3D printer and it was incredibly fun! I learned how to use an XYZ Da Vinci Mini printer, how not to model parts in CAD, and just how small 8Kb of RAM is. Below is a step by step overview on how I created the Hydro9000.

THE PROBLEM

So…let me start by saying I love having plants indoors. However, my plants don’t seem to last as long as they should…due to a lack of water. SO! The problem is: plants need water and I’m terrible at giving them water.

THE SOLUTION

Water the plants. NO. That’s boring and as stated previously, I kill plants.

THEBETTER SOLUTION

I need to create a machine to water the plants for me! Obviously, I’ll need a control panel, a soil moisture sensor for each plant, a big red emergency stop button, a color display, a key to lock out my roommate, colorful 3D printed housing for the pumps,…okay, okay, let’s get started!

RESOURCES

Github

COMPONENTS

Arduino Mega 2560 R3

Buy at Arduino.cc

Soil Moisture Sensor Module

Buy on Amazon

Prototyping Board for Arduino Mega 2560

Buy on Aliexpress

Step Up Converter
(6V to 12V DV transformer, 3 amps)

Buy on Amazon

SOFTWARE TOOLS

CODING SAMPLE

void setup() {
  Serial.begin(115200);
  Serial.println("Starting...");
            
  Hydro9000::setCurrentMillis(0);
  unsigned char sensorPins[PLANT_COUNT] = {54, 55, 56, 57, 58};
  unsigned char pumpPins[PLANT_COUNT] = {30, 34, 38, 42, 46};
  String plantNames[PLANT_COUNT] = {"Basil", "Cilantro", "Oregano", "Thyme", "Rosemary"};
  for (unsigned int i = 0; i < PLANT_COUNT; i++) {
    MoistureSensor sensor(sensorPins[i]);
    WaterPump pump(pumpPins[i]);

    PlantController plant(sensor, pump);
    plant.name = "plant_"+String(i);
    plant.displayName = plantNames[i];

    hydro.addPlantController(plant);
  }
  
  ControlPanel controlPanel;

  attachInterrupt(digitalPinToInterrupt(SELECT_WHEEL_ENCODER_PIN_A), doEncoderPinARising, RISING);
  attachInterrupt(digitalPinToInterrupt(SELECT_WHEEL_ENCODER_PIN_B), doEncoderPinBFalling, FALLING);
  selectWheel = SelectWheel(SELECT_WHEEL_ENCODER_PIN_A, SELECT_WHEEL_ENCODER_PIN_B);
  selectWheel.readPinA();
  selectWheel.readPinB();
  controlPanel.addSelectWheel(selectWheel);

  /* Add buttons to control panel */
  Button blueButton(BLUE_BUTTON_PIN, BLUE_BUTTON_LED_PIN);
  Button redButton(RED_BUTTON_PIN, RED_BUTTON_LED_PIN);
  Button selectWheelButton(SELECT_WHEEL_BUTTON_PIN);
  Button emergencyStopButton(EMERGENCY_STOP_BUTTON_PIN);
  Button keySwitch(KEY_SWITCH_PIN);
  blueButton.stateWhenButtonPressed = LOW;
  redButton.stateWhenButtonPressed = LOW;
  selectWheelButton.stateWhenButtonPressed = LOW;
  controlPanel.addButton(ControlPanel::ButtonName::BLUE, blueButton);
  controlPanel.addButton(ControlPanel::ButtonName::RED, redButton);
  controlPanel.addButton(ControlPanel::ButtonName::SELECT_WHEEL, selectWheelButton);
  controlPanel.addButton(ControlPanel::ButtonName::EMERGENCY_STOP, emergencyStopButton);
  controlPanel.addButton(ControlPanel::ButtonName::KEY_SWITCH, keySwitch);
  
  hydro.addControlPanel(controlPanel);
  hydro.setup();

  Serial.println("Hydro900 setup complete");
}

void loop() {
  hydro.update();
}