Doddy's PolyTunnel Controller

This year I've invested in a polytunnel for the allotment that I rent in the UK, for growing vegetables. A polytunnel (PT) presents a number of challenges, particularly if - like me - you're in full time employment and can't really afford the time to visit it each morning to open the ventilation screen and close at night (depending on temperature), plus keeping the vegetables watered.

So, hello Mr Arduino Mega, and a bunch of his friends...

Basically, a Meta 2560, a Sainsmart SSD1289 display (TFT01) with an ElecFreaks shield; an 8-channel relay board, a Real Time Clock, a Temp/Humidity Sensor and a secondary power-supply. Remotely, there are two Ultrasonic ping sensors, 2 submersible pumps and a motor/worm gear box.

The gist here is that there's a solar-charged car battery that provides the main power to the board, and the secondary PSU. This PSU supplies the relay board, and the +5v for the various boards and sensors.

The RTC and Temp/Humidity sensor are on a single IIC bus (wire-wrapped from the early development phase)

Is the main interface, giving options to set the clock, control irrigation on the north, and separately south row of the PT, water-level monitoring, temperature monitoring and control, ventilation controls and info on the project.

Setting the RTC time and date. A clumsy interface but it allows for simple re-use of a button-library I knocked together for the SSD1289.

Allows for the auto-irrigation of the north face of the tunnel. This allows (in this case) a 10-minute duration for a pumped-overhead spray hose early in the morning before the sun gets up.

Same for the south face (although less on-time for this, since the spray hosed area is shorter (taking into account my IBC and workbench)

Very basic, but monitors the water level in the IBC - this is achieved by a Ping sensor set in the cap on the IBC tank, but, more interesting is the "Trend" button that provides a generic trending-store of a value over 24 hours, 30 days, 52 weeks...

9am is blank - as this is the "current" hour being sampled for min/max levels, everything to the right (10am-11pm) is yesterday's trend, with the samples to the left being today's water level. You can see that yesterday the tank started around 55% full, but it started raining around 11am, filling the tank to around 68%. The blue/red bars show min and max levels - showing a clear problem with the ping sensor and spurious readings - I need to get an oversampling filter implemented in software to avoid rogue readings.

Shows the same detail over 30 days (well about 15 of those), with a clear down-pour early May filling the IBC and a gradual decline in the water level since then, with a bit of a refill over the last couple of days.

The temperature control is pretty basic, showing the current temperature and the desired set-temperature (Top buttons are "temp -", "store", "temp +" for setting the desired temperature). Again, a nice trend button allows the temperature trends to be monitored...

...an extremely poor picture for the Vent Controls - allowing the ventilation blind to be manually raised/lowered, with min/max heights being stored to NVM, and an Auto-control (this will raise/lower the blind every 2 minutes by +/- 20% of the travel, depending on the actual vs desired set-temperature). A trend button allows the blind position to be monitored as before - daily/ monthly / yearly -not that useful except for debugging but it's essentially free to me given the generic trend software.

Is the motor/worm drive to raise/lower the blind vent, driven from two of the relays on the 8-channel control board. Another two channels control the pumps for north/south irrigation.

The dull "about" screen - mostly to offer some personal info should the whole thing get nicked and thrown onto the 2nd hand market, but also offers the curious "HBOX" (history box) window....

Which stores any startup / errors in a cyclic, 32-deep error log.

Apologies for the ... erm... rather large pictures (I might get around to shrinking those later).

Some of the things I've encountered:

Ping Sensors in a rather hostile environment (humidity / breezes, not using screened cables etc) should be filtered for rogue readings. Currently the height sensor for the blind samples every 200ms, and the level is determined from the average of 10 samples. I really should re-wire those with screened cable, though.

Projects like this which are designed to be unattended - store all your settings into EEPROM, and reload these on power-up to avoid losing state/setting data to inadvertent crashes or resets (I had a mouse (I think) fiddling with the wiring at one stage).

Decouple the microcontroller from any heavy switching devices (i.e. use a separate PSU) - reduce the load from the Arduino's PSU.

The ElecFreaks shield for the TFT01 display is badly designed - it presents the backlight anode connections (spec'd at 3.2v 80mA) to the Arduino's 3.3v supply via a 33R resistor - giving something like 10mA forward current - and a very dim display. I sweated off the resistor, replaced with a 27R resistor up to the 5V on the secondary PSU - which gives a much healthier display brightness. There's a microswitch winging its way to me via eBay to switch this on/off when the crude flap over the electronics is opened.

Software is running at around 20% utilization of the 2560, 1kB given to the history box, another 768 bytes for trend data (and random setting/state data). I'm happy to share with anyone who's interested, also, happy for ideas or suggestions for the way forward.

Good job ! Your problem when you start dealing with the PolyTunnel is like mine... I realy nead to monitor and auto control the green house like you did. I also allready buy an Arduino Mega + Ethernet shiel + 8 Relay shiel and some LCD's.
Can you share with me youre scretch code for the project please?
I think you use an touch screen lcd.

If you want to give me your code and schematic diagram that you usit please send me by e-mail on: barbudancristian@yahoo.com

Thank you very much and good luck with the GreenHouse and vegetables!

Keep in touch
Dan Barbu

Very nice work, I am just getting into Arduino. And want to tackle a project with similar I/O as you have done here. What version of the elec freaks sheild do you have? I ordered the V2.0 one hopefully they had fixed the 3.3V cureent supply issue with this one.
Cheers!

You should make a list of objectives.
That way we can offer assistance or ideas.

Spot on! Project.

Oh great project!!! :smiley:

Well done. The menu system really sets the whole thing off - looks very pro.

contribution that good fellow, I congratulate me I would like you to collaborate with your project to study the menus I really liked that inplemento in lcd, i want to study your code and learn alongside the schematic you would greatly appreciate this. juliogarcia625@hotmail.com :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: