Gerrit Niezen

day64

For my ebb-and-flood (also called flood-and-drain, or ebb-and-flow) hydroponics system, I need to pump water over the flood table at regular intervals. The time between flooding depends on various things, of which the growing medium is the deciding factor:

  • Expanded clay pebbles: 4 to 8 times a day (every 2 to 4 hours)
  • Coconut coir: 3 to 5 times a day (every 3 to 5 hours)
  • Rockwool: 1 to 5 times a day (once a day to every 3 hours)

I'm going to put rockwool starter cubes in expanded clay pebbles, so every 3 hours sounds like a good idea. I then also need to figure out how long to flood the table for, which depends on how quickly the pump floods the table. Let's say it's around 30 seconds, which then leads to the following Espruino script for my Pixl.js:

const floodIntervalMinutes = 180;
const floodDurationSeconds = 30;

const pumpPin = B15;
const waterSensorPin = B3;

setInterval(() => {
  if (!digitalRead(waterSensorPin)) {
    console.log('Water detected!');
    digitalWrite(pumpPin, 0);
  }
}, 1000);

setInterval(() => {
  // TODO: check if daylight
  // TODO: max delay between floodings

  digitalWrite(pumpPin, 1);

  setTimeout(() => {
    digitalWrite(pumpPin, 0);
  }, floodDurationSeconds * 1000);

}, floodIntervalMinutes * 60 * 1000);

function onInit() {
  pinMode(waterSensorPin, 'input');
  pinMode(pumpPin, 'output');

  E.setTimeZone(1);
  console.log('Current time:', (new Date()).toString());
  digitalWrite(pumpPin, 0); // make sure pump is off
}

Note that I also added a water sensor for switching off the pump in case there's an overflow.

What I still need to do is to add a light sensor to check if there's daylight, and then only flood during daylight hours. I then also need add a maximum delay between floodings, so that the plants don't go for more than 12 hours without water. Thanks to ChilliChump for these ideas.


I’m publishing this as part of 100 Days To Offload. You can join in yourself by visiting https://100daystooffload.com.

#100DaysToOffload #day64 #hydroponics