Simple farm plot monitor? temperature, humidity and light?

I'm a complete newb when it comes to Arduinos and somehat familiar with programming on computers but nothing to the extent of some of you folks :)

I'll try and describe my needs the best I can and see if you folks can help

Sensors:

Thermoprobe for soil temperature Thermoprobe for air temperature Photocell for day light measuring (is it possible to have these monitor lumens? intensity etc?) Probe for soil moisture (using this technique http://gardenbot.org/howTo/soilMoisture/) Probe for air moisture (see link above for same perhaps?)

Read out: I would like if possible to have this read out data saved to an on board memory (does not need to be removable) If I could have this data read from the sensors say, 6 times a day that would be perfect. The data would need to be saved on the beforementioned memory, every x amount of days I would walk out to the device, plug it in via USB and "grab" the data off it, onto my mac. I imagine a simple .txt file would be sufficient, where I would then convert it on my Macbook into a useable form (such as making an excel list of data inputs)

Power: Powered via 6volt lantern battery (reduced down to appropriate electrical voltage) which is tied to a photocell for solar charging


A bit of background; I grow organic tobacco and sell it in the unprocessed form. Because I can't use fertilizer, chemicals etc it is very time intensive. A lot of issues such as lack of plant growth, wilt or certain diseases can be attributed to atmospheric conditions, being able to utilize this monitor would allow me to see what's truly happening in my field when I'm not at the field. It would also help me be able to track and possibly predict issues before they show their ugly face.

I know this is a big request, but any help is appreciated.

From the fields of Michigan I give you all a large thank you!

Jeremy (michibacy)

For temperature, the DS18B20 is a popular sensor and you can get waterproofed variants - handy for soil temperature. You can use the same for air, or, since you need humidity too, the DHT11 might work although you'll need to defend it from the weather.

A light dependent resistor (LDR) will do for light sensing - although it'll give you comparative intensity, not lumens.

Soil moisture sensing is easily done as per your gardenbot link.

You're not collecting much data, so unusually, you could fit several days worth in RAM. Any momentary power outage & it would be gone though. I'd be more inclined to use an arduino or shield that has an SD card so you can be sure it's saved. Also, it'll have capacity that it could collect for years without filling up.

I'd add a real time clock too, so you can put a timestamp on the data you've collected.

Terrific I'll start working on it!

I have the Micro as it right now, so I'll be starting me experimenting with that.

Which code would you suggest for measuring the Ohm/resistance from say Analog pin one? How about programming it to only take a reading every 120 minutes? Save the log to a readable file?

check out arduino yun

are you really growing tobacco in mich?

i didnt think i grew any further north than the va/nc line

At this point I'm not able to invest more money in a new board, if at all possible I would like to use what I have.

And yeah I am growing tobacco in Michigan, many people think it only can grow in those warmer climates but honestly, anywhere you can grow tomato, you can grow tobacco. The only issue one runs into is curing/drying it. (I start my plants early in march, harvest rather early to utilize the summer heat).

I plan on using this device either as a stationary unit, or after discussing the design with a fellow nerd at Radio Shack last night, tying it into my laptop when I'm either on the tractor out in the field to get real time readings (which if I'm not mistaken will be a bit simpler).

My biggest hurdle right now is getting the coding, making/attaching the sensors is the easy part.

I was thinking about the soil moisture probe, because DC current through two nails/metallic probes causes electrolysis, is there a code that would turn on/off PinX rapidly (simulating in essence AC) and take multiple readings (every time it turns on then off). I might be over thinking this, but would that not help elongate the life of the probe?

Michibacy: Which code would you suggest for measuring the Ohm/resistance from say Analog pin one? How about programming it to only take a reading every 120 minutes? Save the log to a readable file?

  1. AnalogRead and a voltage divider.
  2. See Blink without delay example and Robin2's Do multiple things at the same time thread.
  3. Look at the SD library in the reference.

Thanks Wildbill, I'll look into it.

I've done some digging and started to compile a code. As of right now I have it only measuring the moisture. I came up with a formula to measure the humidity of the soil every 30 inches (that's how far the plants will be planted apart) at 5 miles per hour, or in other words, covering 30 inches every 2.93 seconds. As it stands I don't have the probe installed, just running off the connector pins (in a dry environment) this reads out to the serial viewer.

Quite pleased so far :)

The status LED also blinks to notify me that it is processing, the TX LED blinks as well to let me know it's transmitting.

I will probably run an external LED for the beforementioned status lights to view them outside of the project box

/*

Example code for the moisture sensor

Editor : Da Vinci Plant Services

Date : 3.18.15

Version : 1.0

Connect the sensor analog out to the A0(Analog 0) pin on the Arduino board

Connect the sensor VCC pin to 5v pin on Arduino the board

Connect the sensor GND pin to GND pin on the Arduino board.

the sensor value description

0 ~300 dry soil

300~700 humid soil

700~950 in water

*/

void setup(){a

Serial.begin(57600);

}

void loop(){

Serial.print("Moisture Sensor Value:"); Serial.println(analogRead(0)); delay(2930);

digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(114); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(114); // wait for a second

}

Also, though it is simple to come up with if you're mathematically inclined (which I'm not), the formula I wrote to come up with the test rate frequency is below

A=17.6 Inches Per Second (1 mile per hour = 17.6 inches per second) C=Constant rate, MPH to Inches per second (desired planting speed) H=plant spacing in inches P=1 second (1000 milliseconds) Z=test rate frequency (per plant spacing)

Z= uP[/u] H

Considering the code I have above, is there a way to display the results that are appearing in my Serial Monitor onto a simple lcd screen so I do not have to have my laptop with me in the cab of the tractor?

I have decided to change the design/concept a bit, this device will monitor the soil moisture content immediately prior to planting (while in motion). Depending on the moisture content the driver will be able to adjust his or her pop up fertilizer (which is essentially liquid compost diluted heavily by water) depending on the moisture content.

Thanks!

Michibacy: Considering the code I have above, is there a way to display the results that are appearing in my Serial Monitor onto a simple lcd screen so I do not have to have my laptop with me in the cab of the tractor?

Yes. Take a look at the LiquidCrystal library in the reference. For your current display needs, the ubiquitous 16x2 character LCD would do the job, at least until you think up new features ;)

Consider interpreting the analog value to make it easier on the user. Show Dry, Medium, Damp or Yes/No so that you don't have to think about what the raw data means. Of course you could show that too.

Would I add this code to the existing code? or should I replace the Serial.Print with the lcd.print?

Add the LCD code - the serial stuff is useful for debugging. Once you're happy with it, you can remove it. Or leave it - the arduino doesn't know or care whether anything is listening to the serial port.

In some cases, serial output can slow things down, but in your case, it's not relevant.

Which pins do I connect to the LCD? I haven't gotten one in my hand yet so I'm just curious what I need to look forward to. Also, how do I add the code to interpret the analog value to a more user friendly format?

Michibacy:
Which pins do I connect to the LCD? Also, how do I add the code to interpret the analog value to a more user friendly format?

Pins are up to you - you just have to tell the library which ones you used when you declare the LCD object. ‘Classic’ LCDs use quite a few which might be a consideration if you’re considering adding extra hardware later. You can get more expensive ones using a serial interface that save you pins.

As to interpreting, just use some if statements to compare the value from analogRead against thresholds you define & print a suitable message. You can test it using Serial.

I don’t think my caffeine is working today…need some corrections done to a code if I could acquire your help. I am completely lost…

As it is right now I want the serial print to show me the value as well as the “too high” or too “low” designation…what am I doing wrong?

/*

Example code for the moisture sensor

Editor : Da Vinci Plant Services

Date : 3.18.15

Version : 1.0

Connect the sensor analog out to the A0(Analog 0) pin on the Arduino board

Connect the sensor VCC pin to 5v pin on Arduino the board

Connect the sensor GND pin to GND pin on the Arduino board.

the sensor value description

0 ~300 dry soil

300~700 humid soil

700~950 in water

*/

void setup(){

Serial.begin(57600);

}

Serial.print(“Moisture Sensor:”);
Serial.println(analogRead(0));
delay(529);

if Serial.println ()>=350);{
Serial.print(“Too Dry - INCREASE”);
}else if (Serial.println ()<= 351);{
Serial.print(“Too Moist - DECREASE”);
}

digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(114); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(114); // wait for a second

}

This is the result I’m getting in my serial read out:

Too Dry - INCREASE
Too Moist - DECREASEMoisture Sensor:312

Too Dry - INCREASE
Too Moist - DECREASEMoisture Sensor:452

Too Dry - INCREASE
Too Moist - DECREASEMoisture Sensor:210

Too Dry - INCREASE
Too Moist - DECREASEMoisture Sensor:442

Too Dry - INCREASE
Too Moist - DECREASEMoisture Sensor:219

Too Dry - INCREASE
Too Moist - DECREASEMoisture Sensor:430

Too Dry - INCREASE
Too Moist - DECREASEMoisture Sensor:291

Too Dry - INCREASE
Too Moist - DECREASEMoisture Sensor:363

If someone could help me get it to read either the too dry or either the too moist with the moisture sensor readout below it, it’d be most appreciated! Thanks!

Try this. Note the use of code tags rather than the quote tags you’ve been using:

Serial.print("Moisture Sensor: ");
int MoistureReading=analogRead(0);
Serial.print(MoistureReading);  
delay(529);
 
if(MoistureReading>350)
  {
  Serial.println(" Too Dry - INCREASE");
  }
 else if (MoistureReading< 300)
   {
   Serial.println(" Too Moist - DECREASE");
   }
 else  
   {
   Serial.println(" Just right - Do nothing");
   }

Thanks Bill, but I received Error Compiling:

Arduino: 1.6.1 (Windows 7), Board: "Arduino Micro"

Build options changed, rebuilding all

adrunio_blink_if_then_up_down2.ino:2:1: error: 'Serial' does not name a type

adrunio_blink_if_then_up_down2.ino:4:1: error: 'Serial' does not name a type

adrunio_blink_if_then_up_down2.ino:5:6: error: expected constructor, destructor, or type conversion before '(' token

adrunio_blink_if_then_up_down2.ino:7:1: error: expected unqualified-id before 'if'

adrunio_blink_if_then_up_down2.ino:11:2: error: expected unqualified-id before 'else'

adrunio_blink_if_then_up_down2.ino:15:2: error: expected unqualified-id before 'else'

Error compiling.

This report would have more information with "Show verbose output during compilation" enabled in File > Preferences.

Please post the code that gave those errors. Looking at your previous post though, there are some lines missing at the top of what should have been your loop function. Similar issue?

I used your suggested code.

Oops - that was just a fragment to paste into loop to replace your attempt at getting the printing going. Here’s the complete version of loop to replace yours:

void loop()
{
Serial.print("Moisture Sensor: ");
int MoistureReading=analogRead(0);
Serial.print(MoistureReading);  
delay(529);
 
if(MoistureReading>350)
  {
  Serial.println(" Too Dry - INCREASE");
  }
 else if (MoistureReading< 300)
   {
   Serial.println(" Too Moist - DECREASE");
   }
 else  
   {
   Serial.println(" Just right - Do nothing");
   }
 
 digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
 delay(114);              // wait for a second
 digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
 delay(114);              // wait for a second 
}

hahaha I just saw the same thing! Sorry about that, taking sales calls here at work as well as coding gets me confused a bit (I typed pricing into my code and told the guy a syntax code...oops)

Works great! Onto probe making and LCD install!