Greenhouse master controller in the middle of nowhere

Hi!

I'm very happy to join the community, I've been looking forward to have some time to create my first Arduino project and here I am!

I am automating a medium greenhouse I own. I've seen some other threads here and learnt a lot, but I still have a couple questions:

  • I'm estimating I'll need about 10 sensors (temperature, humidity etc). That's too much for Arduino ONE, isn't it? Should I get a MEGA?

  • And here's the tough part. I want it to be constantly uploading all the data to a webserver to monitor and give orders (turn on fan etc.), but the greenhouse is too far away from Wifi/Ethernet, so I'm only left with a 3G USB modem (thankfully I do have electricity there). What's the best/cheapest/easiest way to pull off this?

Thank you!!

What's the best/cheapest/easiest way to pull off this?

That depends on the actual conditions and how much $$$ you are willing to invest. best/cheapest/easiest may not exist in practical terms.

Ok, let's try with the better solution and then the easiest solution :grin:

Empirex: - I'm estimating I'll need about 10 sensors (temperature, humidity etc). That's too much for Arduino ONE, isn't it? Should I get a MEGA?

That depends. The Uno has 20 input/output pins. Depends on whether the sensors are analog or digital, and what else you need pins for.

and give orders (turn on fan etc.)

So you need outputs as well? You need to do a pin count, including what pins you need for communications.

Uhmm... I assumed they were all analog. Here's the estimated list I have: - 2 temp sensors - light sensors (to tell if a light is on or off, these for are just for fun) - 1 pH - 1 Humidity - 1 Water level (i'm thinking eTape)

And the output so far i can only think of turning the fan on or off, and lights on or off.

Empirex: Uhmm... I assumed they were all analog. Here's the estimated list I have: - 2 temp sensors - light sensors (to tell if a light is on or off, these for are just for fun) - 1 pH - 1 Humidity - 1 Water level (i'm thinking eTape)

And the output so far i can only think of turning the fan on or off, and lights on or off.

Ok I just discovered that I can buy a WiFi platform where you can plug your 3g USB and act like a regular WiFi Modem...So I guess the 2n questions is over!

What about the sensors (digital/analog no idea)/ which arduino to get?

Thanks..

Empirex: Hi!

I'm very happy to join the community, I've been looking forward to have some time to create my first Arduino project and here I am!

I am automating a medium greenhouse I own. I've seen some other threads here and learnt a lot, but I still have a couple questions:

  • I'm estimating I'll need about 10 sensors (temperature, humidity etc). That's too much for Arduino ONE, isn't it? Should I get a MEGA?

  • And here's the tough part. I want it to be constantly uploading all the data to a webserver to monitor and give orders (turn on fan etc.), but the greenhouse is too far away from Wifi/Ethernet, so I'm only left with a 3G USB modem (thankfully I do have electricity there). What's the best/cheapest/easiest way to pull off this?

Thank you!!

Hi, you may end up wanting a Mega anyway, but consider that some sensors can be connected in series using the I2C protocol. There are also (limited) options to use serial communication. Taken together, these could reduce the total number of analog pins required. Don't forget that then you'll have the task of developing the software in charge of reading/logging/sending the input from the various sensors. I'm saying this because I'm more inclined towards a distributed architecture, with a division of labor among small devices instead of a single central controller performing all the tasks. It is not necessarily easier to program, but allows for more flexibility. Among the deciding factors you should consider the area to be covered and whether sensors and actuator can be concentrated in a relatively limited space or scattered throughout. Another strong preference of mine is to leave all web-related stuff to a device that is best equipped to do things such as serving web pages and transferring files securely. Once again, consider that trying to get and store data from ten different sensors while accepting commands from the web and controlling actuators may lead to 'race conditions' where some of the tasks will be left behind (the Mega doesn't make much difference because it still has one processor). So I would leave all storage and communications tasks to a Raspberry Pi. The RPi could send its logs to an external server at timed intervals using the 3G phone, saving the cost of a permanent connection. It can also send and receive SMS for alerts and immediate commands to be dispatched to the Arduino(s).

Empirex: Uhmm... I assumed they were all analog. Here's the estimated list I have: - 2 temp sensors

Yes, but a temperature sensor might, for example, use I2C to digitally send the analog reading. Ditto for a lot of the other ones. A light sensors, though, if it was a LDR (resistor) would need to be hooked up to an analog pin. And two of the 6 analog pins are used for I2C.

What Spatula says makes sense too. Unless all the readings are going to be taken all in the one place (and even then) it might be better to have a few cheaper devices dedicated to one task each, rather than one larger one.

Empirex:

Empirex: Uhmm... I assumed they were all analog. Here's the estimated list I have: - 2 temp sensors - light sensors (to tell if a light is on or off, these for are just for fun) - 1 pH - 1 Humidity - 1 Water level (i'm thinking eTape)

And the output so far i can only think of turning the fan on or off, and lights on or off.

What about the sensors (digital/analog no idea)/ which arduino to get?

Thanks..

You can be pretty sure you will need a Mega. This is because of the memory requirement rather than i/o pins, although the latter could be a problem too. A Mega has eight times the usable memory but only costs a few dollars more and, seeing you haven't actually bought anything, I submit you would be silly to get a Uno. The Mega also has heaps more I/O pins!

No comment on the sensors other than that the DS18B20 for temp is an obvious, cheap, and popular choice. They work on a 3-wire bus which means you can have a great swag of them sharing a single I/O pin. I see you contemplate only two thermos, but it is still a good idea.

As the greenhouse has power do you need to use a 3G modem that I assume will incur monthly costs. Could you use a couple of powerline network nodes http://www.amazon.co.uk/Netgear-200Mbps-Powerline-Ethernet-Adapter/dp/B007JD6LBS/ref=pd_sim_sbs_computers_3/278-4290633-8656936

Riva: Could you use a couple of powerline network nodes http://www.amazon.co.uk/Netgear-200Mbps-Powerline-Ethernet-Adapter/dp/B007JD6LBS/ref=pd_sim_sbs_computers_3/278-4290633-8656936

Good move! However 2 conditions have to meet;- 1. The powerline networks won't work across power transformers, i.e. greenhouse and office have to be under same transformer. 2. Since most of Powerline-Ethernet-Adapter use Qualcomm Atheros chipset, if not all. It has maximum distance 300 m between nodes.

Thanks, both, for that background info.

Thank you everyone for the answers! I ordered a MEGA and a lot of sensors...

I'm wondering about decentrilizing the whole thing, what could happen if i only use one MEGA to handle all the sensors? The other only thing i'll make it to is send some GETs from time to time (maybe 1 per minute) to update my external server with the local info.

Empirex: what could happen if i only use one MEGA to handle all the sensors?

I thought that was your original intent - one greenhouse, with power available but no WiFi, and one Arduino.

The sensors are wired back to the Mega, it's capability for receiving them depends rather on the type of sensor and what you mean by " a lot of " . The connecting exercise also depends somewhat on the size of the greenhouse.

Your only serious problem is the connection and use of the USB 3G modem. I'm sure there is plenty of info around about that.

... what could happen if i only use one MEGA to handle all the sensors?

Hi, I'm curious about your choice of sensors, especially the one for the pH.

About your question, it's hard to give an answer in the abstract. Generally speaking, some sensors send their readings continuously (just an analog signal), while others must be polled for their readings and may take some time to return an answer (this might be the case for the pH sensor). The only issue I can see in centralizing sensor-reading and web-logging is that depending on the timing of the various operations you will have, from time to time, situations where two tasks, both blocking (cannot be suspended), would have to be done concurrently (and the Arduino's processor is not capable of multitasking).

[added] There is also a limit on how much power you can draw from individual pins and the Mega overall.

As I said, it depends on how you get the data from the sensors. The web-logging part is blocking and relatively time-consuming (it mostly depends on the time required to establish the connection, while data transfer should take a short time in comparison), and you should probably start designing your queue management model around that, taking into account the duration of the sampling operation for those sensors that require polling (if any), and prioritizing the different tasks. You may also want to define a strategy to deal with tasks taking longer than expected, just in case.

Hi,

Dont know if I Should open a new thread, but I have a similiar question, in the an allmost similiar case.
So I reckoned I could paste it here. And do not start a new threat. Hope this is the right manner…

The following tasks the Arduino should do:

  1. Put on a relais for 10 hours on a daily basis.

  2. Put on an actuator for 10 mins dependent from two sensor and two boundairy values. (Thus totally Independent from timing)

My question: Can this be organized within one code (thus one process)? Is this stable and punctual? Do I need a clock? What would the scheme look like?

michiel1984: Dont know if I Should open a new thread, but I have a similiar question, in the an allmost similiar case. So I reckoned I could paste it here. And do not start a new threat. Hope this is the right manner.. As the thread is quite old now & your posting a new question you should maybe have started a new thread.

The following tasks the Arduino should do:

1) Put on a relais for 10 hours on a daily basis. relais = Relays?

2) Put on an actuator for 10 mins dependent from two sensor and two boundairy values. (Thus totally Independent from timing) What two sensors are you referring to and what are the boundary values?

My question: Can this be organized within one code (thus one process)? Is this stable and punctual? Do I need a clock? What would the scheme look like? I would suggest using a RTC module (Real Time Clock), something like a DS3231 (they are more accurate than DS1307) so if you loose power the clock keeps ticking. Really need to know what the sensors are to design any software/hardware.

Why not use the sun for your clock? The day it is not right, you will have bigger problems.

What I saw in the older thread is a trend I have seen for over 20 years, to throw money in ever more expensive toys at a problem instead of time to find an efficient solution. Once a solution is found for one whatever-it-is then that solution is repeated until someone from somewhere else comes in with a far cheaper solution.

Thanks for awnsering, i did not recieve an email so I was not aware of your response.

relais is indeed relays

Here is a more precise overview of the initial setup and objective.

GoForSmoke:
Why not use the sun for your clock? The day it is not right, you will have bigger problems.

What I saw in the older thread is a trend I have seen for over 20 years, to throw money in ever more expensive toys at a problem instead of time to find an efficient solution. Once a solution is found for one whatever-it-is then that solution is repeated until someone from somewhere else comes in with a far cheaper solution.

Yes I would like to use an RTC to make it more accurate, and I would eventually like to ad a display. As the clock is low in price its okay.

Thanks for the commends guys!
I started to write some code for this setting. And decided to just post it. As I am new and have little coding experience, there are many faults in this code. Especially the RTC part keeps me with many questions. Nonetheles I wanted to make some coding before I have all the hardware. I choose a digitalRead for hour to check what time it was at the end of the loop and basically than the light have to go on.

Can someone steer me in the right direction! Thanks !

#include "Wire.h"
#define DS1307_ADDRESS 0x68 //including real time clock

// named constant for the pin the sensor is connected to
const int sensorPin = A0;
// Minimal moist level
const float baselineMoist = 20.0;
const float LightON = 12;
const float LightOFF= 22;


void setup(){
  Wire.begin();
  // open a serial connection to display values
  Serial.begin(9600);
  
  // pinmode set up for the irrigation and the lighting both begin LOW
  pinMode(2, OUTPUT); 
  pinMode(3, OUTPUT); 
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
}
// this part of code I copied from another project http://www.l8ter.com/?p=417 allthough I have little clue what it does :')
  printDate();
  delay(1000);
}

byte bcdToDec(byte val)  {
// Convert binary coded decimal to normal decimal numbers
  return ( (val/16*10) + (val%16) );
}

void printDate(){

  // Reset the register pointer
  Wire.beginTransmission(DS1307_ADDRESS);
  Wire.write(0);
  Wire.endTransmission();
  
  Wire.requestFrom(DS1307_ADDRESS, 7);
  
  int second = bcdToDec(Wire.read());
  int minute = bcdToDec(Wire.read());
  int hour = bcdToDec(Wire.read() & 0b111111); //24 hour time
  int weekDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
  int monthDay = bcdToDec(Wire.read());
  int month = bcdToDec(Wire.read());
  int year = bcdToDec(Wire.read());  
  
  //print the date EG   3/1/11 23:59:59
 
  //Serial.print(month);
  //Serial.print("/");
  //Serial.print(monthDay);
  //Serial.print("/");
  //Serial.print(year);
  //Serial.print(" ");
  //Serial.print(hour);
  //Serial.print(":");
  //Serial.print(minute);
  //Serial.print(":");
  //Serial.println(second);
  
  
  // !!!  Here the code for the moist sensor starts
  // read the value on AnalogIn pin 0 
  // and store it in a variable
  int sensorVal = analogRead(sensorPin);

  // send the 10-bit sensor value out the serial port
  // Serial.print("sensor Value: ");
  // Serial.print(sensorVal); 

  // convert the ADC reading to moist level still needs an equation, I did not choose a moist sensor to work with
  float moistvalue = (sensorVal);

  // Send the voltage level out the Serial port, possibly print for check up
  // Serial.print(", : ");
  // Serial.print(moistvalue);
  if(moistvalue > baselineMoist){
    digitalWrite(2, LOW);
  } 
  // if the moist level is above sensorVal xx actuator 1 turns on for five minutes or turns of when BaseMoist is reached.
  else if(moistvalue <= baselineMoist){
    digitalWrite(2, HIGH);
    for (float moistvalue => baslineMoist); // loop as long as the moist value is lower than baselineMoist
    digitalWrite(2, LOW);
  {
 
    } 
  }
  //starts to turn on light at 12:00 and turns of light at 22:00
if (hour => LightONN && hour <LightOFF ){
  digitalWrite(3,HIGH);
  else (hour < LightONN && hour > LightOFF ){
  digitalWrite(3,LOW);
  }
}
}_));