hydroponics IoT controller

Discussion in 'Hobby Engineering' started by ShadowBurger, May 15, 2019.

  1. ShadowBurger

    ShadowBurger Member

    Joined:
    Feb 19, 2008
    Messages:
    1,607
    Location:
    Melbourne
    Have been having a bit of fun lately developing a controller for a hydroponics project :D I've named it HydroTek and decided to go open-source with it, but if you're a re-seller and want to line my pockets, shoot me a PM... :lol:

    The hardware is designed to either run 2 separate hydro setups or a single more complex hydro setup and can interface with:
    • 2x temperature / humidity sensors
    • 2x float switches
    • 2x flow sensors
    • 2x grow lamps
    • 2x nutrient pumps
    On board, it has:
    • 128x64 mono (white on black) OLED display
    • real time clock with rechargeable backup battery
    • 5 - 28V input voltage regulator with good filtering
    • WiFi
    • a buzzer, a button, and an LED
    Feature-wise, it can:
    • Upload the sensor readings every x seconds/minutes to a web endpoint (the main point of this thing)
    • Depending on how it's configured, if the float sensors read full / empty (depending what they're used for), or if the temperatures are getting uncomfortable for the plant/s, or if the flow sensor doesn't see anything when the controller is running the pump, it can make a racket with the buzzer, flash the LED, and the web component can fire off emails and display alerts on the dashboard
    • The web server can handle multiple users, with multiple devices configured in different ways
    • The dashboards by default show you the last few hours and the latest known state of the float sensors but can also show history and trends and zoom into a period of time
    The setup it is controlling. The substrate is re-usable clay balls and the nutrient is continuous flow, although the controller does support run-to-waste, airponics and other types of setups. Ventilation is always-on and while I thought about adding control of fans (which can be done with use of one of the lamp or pump outputs) I didn't have enough I/O pins or need to include it.
    [​IMG]
    [​IMG]

    The first prototype consisted of an Arduino Mega and a 128x128 RGB OLED display. This was a bit overkill, the Mega is huge, and the displays were a bit expensive so progressing with this hardware was decided against pretty quickly.
    [​IMG]

    This first iteration with a custom PCB was designed around a Sparkfun Pro Micro clone coupled with either a NodeMCU v0.9 or a v3 for WiFi and POST operations, an SSD1306 128x64 OLED display, and an I2C-based RTC module. The board had a few obvious wiring errors and I'd forgotten all about pinouts for lamp / pump control, so a revision was on its way almost as soon as it had arrived. This one never saw the light of day.
    [​IMG]

    For the second iteration, I went with the newer NodeMCU v3. Unfortunately I found incorrect pin spacings listed online, so the second iteration also had a pretty big flaw in that the ESP didn't fit on it at all :thumbup: On this and the previous version, you'll see that I allocated space for a choice between either a combination of a barrel-jack and a 5V LDO, or a mini 240vac to 5V converter - the HLK-PM01 - but I opted never to use one due to mains being scary and not legal in this context. That component was dropped from the next design.
    [​IMG][​IMG]

    The third iteration was a partial success and is at the time of writing running the hydro setup, albeit in a fairly temporary manner. Once I had it assembled, I realised my decision to use an off-the-shelf LC-filter to handle filtering the output from a 5V LDO was a poor one as using any of my 5v - 9v plug packs to power the device would cause it to oscillate and get very hot. That said, this version still works using a decent phone charger via the USB port on the Pro Micro. I also found that some of the pins assigned to the various sensors can't work in the way that I intended (some don't support interrupts, etc), so some firmware and pinout changes were needed, meaning cutting traces and running shunts. Off it went back to the board house for a fourth iteration. Nonetheless I had whipped up a 3D printed case in the meantime which at least demonstrates this might just come together as a fairly polished product...
    [​IMG][​IMG]
    [​IMG][​IMG]

    The fourth iteration is where I'm at now. This was when I picked the HydroTek name for it which I got silk-screened on the PCB :) This board is a lot more compact due to ditching the enormous NodeMCU and instead using a Wemos D1 Mini, which along with the Pro Micro is mounted on the reverse side of the PCB saving heaps of space. I included the .33uF and .1uF ceramic filter caps the LDO was designed to be used with, as well as some low-ESR electro caps for belt and braces, which have proven really effective. The LDO itself is on the reverse side now, and has a big pad which the tab can be soldered or adhered to for heatsinking - I noticed on rev3 it was running at about 70degC thanks to the ESP's phat current draw.
    [​IMG][​IMG]

    Annoyingly I've found that some of the pads (L1, L2, P1, P2) have mysteriously have picked up thermal joins to the surrounding copper, which on the topside is VCC. Not hard to work around, but again a pain to fix neatly, so it's back off to the board house for another revision :rolleyes: As pictured above, I did build one regardless, so I'll stick with the board layout and start designing a case.
    [​IMG]

    On the subject of the web UI, that has come together fairly nicely. The front-end is built in reactJS, while the back-end has been built in PHP. They both still need some work but are doing the job in the meantime
    [​IMG]

    The below setup is operating a soil-based run-to-waste system rather than hydroponics, so you can see the nutrient pump operating every 4 hours to feed a small amount of nutrient. The idea with that is to water the right amount to have about 15% run-off which is then discarded.
    [​IMG]
     
    Last edited: May 15, 2019
    LayZ and Technics like this.
  2. Technics

    Technics Member

    Joined:
    Apr 29, 2002
    Messages:
    1,506
    Location:
    Brisbane, AU
    I've always wanted to give something like this a go. The web interface you've done looks great. Probably a good move with the 240V input. The ground pour is way too close to the mains tracks. My only suggestion (based on a few years working in embedded design) is that if you are going to open source this would be to try and get it down to a single micro if possible (I.e. an ESP32 or similar) and I get that it may not be due to the amount of IO required or real-time requirements. While it's entirely possible to firmware update multiple micros the process tends to be more complex and less reliable. You'd think the formula would be (complexity = numMCU) but it's often more like (complexity = numMCU * numMCU).
     
    ShadowBurger likes this.
  3. OP
    OP
    ShadowBurger

    ShadowBurger Member

    Joined:
    Feb 19, 2008
    Messages:
    1,607
    Location:
    Melbourne
    That's good feedback, cheers! My intention is to do a version using the ESP32 which has loads more I/O than the 8266 not to mention processing power and flash storage.

    Got to say, thanks to the arduino IDE and these modular gadgets that go with it, the ease with which a pleb like me can develop hardware now is awesome
     
    Technics likes this.
  4. OP
    OP
    ShadowBurger

    ShadowBurger Member

    Joined:
    Feb 19, 2008
    Messages:
    1,607
    Location:
    Melbourne
    Have switched over to the ESP32. Upsides include; only a single MCU so easier to update and no complicated serial comms involved, 260Mhz dual-core, bluetooth as well as wifi, lower power consumption (~250mA while transmitting on WiFI vs up to 1.2A on the 8266), more flash storage which I ran out of on the Pro Micro, and of course a bunch more flexible I/O

    It is still 3.3v logic but all of the sensors are compatible, although I have yet to test with the RTC and the LCD. Working on a PCB to suit as we speak

    [​IMG]
     

Share This Page