Arduino experiments - Datalogger for the grow room

wietefras

Well-Known Member
Besides growing cannabis, one of my other hobbies is Arduino. This is a cheap and easy to use microcontroller board which can be used to automate all kinds of things.
https://www.arduino.cc/

I’m constantly thinking of new things I can do with the Arduino and perhaps my experiments can be a source of inspiration for others who have the same hobbies :)

I started out with an Arduino Mega 2560 R3 clone and real time clock module to create a data logger. This is what the sensors get connected too. The data from these sensors is then stored in a database which resides on a Raspberry pi microcomputer. I created a web interface which also runs on the Raspberry pi to produce charts with the sensor data.

Initially I had the Arduino built in to a little card board box:
20130728_GroLo_Papdoosje_DSC3056.jpg

Very high-tech obviously :) I have since moved the Arduino to a plastic housing, but the wiring is still similar. At some point I want to make a printed circuit board where I can put everything in a more permanent position.

In the grow tent I have a sensor box which contains:
- On top a lux sensor (BH1750FVI)
- On the bottom a temperature/RH sensor (DHT22/AM2302)
- 15cm below a separate temperature (DS18B20 waterproof)
- Another waterproof temperature sensor is used to measure soil or water temperature (hydro)
- Another temperature/RH sensor is located in the intake to measure temperature and humidity of the air that enters the tent.

20130623_Binnen_Sensor.jpg

The data from all these sensors gets combined into charts like this:
Climate.png

I keep coming up with new sensors that I can hook up to the Arduino. For instance:
- Plant temperature sensor
- Tensiometers (soil humidity)
- CO2 sensor
- pH, EC, DO
- IR Thermal imaging
- Power usage (current sensor)

I also started to use Arduino’s to control some aspects of the grow
- 0-10V fan controller
- Reservoir top off
- Nutrient mixing

I will add more posts describing the various things I tried and will try in the future.
 
Last edited:

wietefras

Well-Known Member
Plant Temperature camera = IR Temperature sensor

A Plant Temperature (PT) camera is used to measure the leaf temperature which, along with the ambient temperature and humidity, can then be used to determine the Vapour Pressure Deficit (VPD). When used in combination with the plant temperature (PT) this is a measure which shows how easy it is for the plants to transpire. How to use these measurements is explained a bit later.

The PT camera is basically simply an IR temperature sensor with an I2C interface. I broke out the center of the glass in a dummy security camera and installed the IR temp sensor through it. Was quite a good fit and with some extra padding around the sensor it fit rally snugly. I hooked up the sensor to an USB cable and this plugs into the Arduino.

You can see the sensor peeking out through the hole in the middle:
20140623_IR_Temp_DSC4857.jpg

The sensor mounted to the front bit of the dummy camera housing and the simple connection i set up to the USB cable:
20140623_IR_Temp_Aansluiting_DSC4853.jpg

The PT camera in action monitoring the ladies:
VPD Camera action.jpg

How to calculate the VPD?
The VPD is the difference between the saturation vapor pressure at the plant temperature and the measured ambient vapor pressure. I’m using this formula:
VPD = 0,6108*EXP((17,27*PT)/(PT+237,3)) - 0,6108*EXP((17,27*AT)/(AT+237,3)))*RH/100

The VPD calculation is based on the following parameters:
- Plant temperature (PT in degrees Celsius)
- Ambient temperature (AT in degrees Celsius)
- Relative Humidity (RH percentage)

In general for most plants the VPD should be slightly below 1kPa, but I also read that for cannabis it should be between 1.0 and 1.5kPa. When the VPD is too high the plants will be transpiring too much so you should either lower the temperature (dim the lights) or raise the humidity. When the VPD is too low, the plants could grow more if their transpiration was higher and if very low the plants might get wet becaue they can;t lose their moisture through transpiration.

VPD.gif

When a plant is in vegetative phase it can still adapt to it’s surroundings. So the VPD is not so much an issue then. You shouldn’t change the climate based on that. Also when the plants are smaller you will usually measure not just the plants but also the walls or floor behind the plants. When the grow room is nicely filled with plants which are flowering then the VPD becomes more interesting.

I noticed the VPD has some sort of cycle where it starts off high when the “day’ starts, then it drops during the “day” and before the lights go off it goes up again. The VPD is the orange line at the bottom of this image:
Climate.png

I’m still trying to figure out if this actually means the plants could use more light in the middle of the day or that this is just the result of something else. My idea was to dim the lights on a curve similar to how more sunlight reaches the plants at noon and less in the morning and evening. Overall the plants would get the same amount of light energy, but then perhaps they can use it more efficiently this way.

Dimlux sells a controller that protects the plants from overheating based on the same VPD principle. Although they only use it as a protection when the system is unable to keep the climate within the proper range.

The plants should always be slightly colder than the ambient temperature because the plants are cooling themselves by transpiring water. The Dimlux controller will dim or switch off the lights when the PT goes above the air temperature or when the VPD goes too high. When the plants are no longer transpiring something is seriously wrong. The plants will then have closed their stomata to protect themselves against drying out. That means no more photosynthesis is going on either. That’s damaging to the plants and a massive waste of energy in lighting. You can see the same occur with plants outside when they receive too much sun and heat.
 

wietefras

Well-Known Member
Soil moisture sensors - Tensiometers or Capacitive sensors

There are several ways to measure soil moisture levels. Cheapest and least reliable is a resistance based sensor. These measure the electrical resistance of the soil. If more water is present then it's easier for the electricity to flow. Unfortunately these tend to corrode over time. This can be reduced by using the sensor only in short bursts and using an alternating current, but still I found them unreliable.

Easier and better ways of doing this are by using a capacitive moisture content sensor or a tensiometer.

A capacitive sensor measures the capacitance difference due to the dielectric constant of water being different from that of air and soil. After calibration you get a percentage figure which gives you the amount of water between completely dry and waterlogged.

You can build these yourself from metal plates/foil like this:
http://www.instructables.com/id/Building-a-Capacitive-Liquid-Sensor/

Or get ready versions like these:
https://www.tindie.com/products/miceuz/i2c-soil-moisture-sensor/
http://www.vegetronix.com/Products/VH400/

Although the latter uses a slightly different technique, but it's similar.


A tensiometer measures the suction of the soil on a water filled ceramic sensor head. The sensor returns a pressure level. 80mbar is usually a good level to keep the moisture level, but obviously the soil isn't constantly at the same moisture level.

Blumat sells these things, but they cannot be connected to a data logger. So instead I decided to make my own.

A picture of some home made sensors together with a Blumat Digital sensor:
20130706_Binnen_Tensio_DSC2756.jpg

The sensor needs to measure a negative pressure and I wanted something that I could connect to a Blumat watering tube. The only sensor that fit my requirements was the Freescale MPXV5050VC6T1. It measures a pressure between -50KPa (-500mbar) and 0KPa and returns an analog signal between 0.1V and 4.6V. Exactly the right range for hooking up to an Arduino.

The construction consists of two pieces:
1) The housing
2) The pressure sensor module

The whole thing taken apart:
TensioParts_DSC3892.jpg

The housing is made from PVC piping glued together with a Lactacyd mini bottle cap which just happens to have the same thread as a Blumat sensor tube. I intend to some day make a 3D printed housing for these, but for now I'm growing in hydro so not sure if and when I will get to that :)

Picture of the housing in white PVC up close:
20131018_TensiokopWit_DSC4055.jpg

The module is basically a simple connection from the sensor to a stereo headphone jack. I attached that to a bit of proto board which I cut out to fit in the PVC pipe.

Picture of the sensor module perched on a cap:
20130922_GroLo_SensorAansluiting_DSC3920.jpg

A bit of Arduino code for converting the analog voltage into a pressure value:
Code:
#define VSS 5.0
        int sensorValue = analogRead(pin);
        float voltage = sensorValue * (VSS / 1023.0);
        //Transfer MPXV5050V vout to value
        // VOUT = VSS x (0.018 x P + 0.92)
        // Multiply by 10 for mBar/hPa
        Tensio = -( voltage/ VSS - 0.92) /0.018 * 10;
In my datalogger code I also added a smoothing algorithm. The sensor is read every second and these values are averaged over a minute. This minute average is then logged. Not that it mattes much, but I like the more graph clean lines it gives.

A graph of the tensiometer data from two sensors (2 plants) show how quickly the plants start taking up water after the lights are switched on:
Tensio_Nacht-Dag_overgang.png

The charts shows low transpiration during the night and within 15 minutes after lights on, the plant is taking up water at full capacity.
The drop around the 160 minute mark is where the plants were watered. This causes the tensiometer pressure values to drop.
 
Last edited:

wietefras

Well-Known Member
I was going to come in here and mention tensiometers, but you've got it, lol.

I'm subbed, interested to see where this goes!


How much $ do you think you have invested in the aduino set up pictured above?
Yeah, I added a bit on tensiometers now.

Not ure how much I spent, but usually the parts are reasonably cheap. An arduino is around $8 and less for the smaller ones which I usually use (a Pro Mini is only a few bucks). A temperature/humidty sensor is around $2 to $2.50. I paid around 10 euro for the pressure sensors in the tensiometers and right now they are around $13.

The Raspberry pi is the most expensive part in the system. I purhased a yun shield to see if this could do the same thing. That would make the whole system even smaller and cheaper.

I also have a 3D printer which I could use to print the housing for the datalogger and the tensiometer heads.
 

wietefras

Well-Known Member
Scales

I was interested in seeing the weight of a pot change over time. So I hooked up a kitchen scale to the Arduino.

20131106_StrainGauge_DSC4076.jpg

On the left an Arduino Uno which powers the scales and gets the weight data back through the green wire. The AD623AN (instrumentation amplifier) on the breadboard amplifies the weak signal from the "load cell" (right) to something the Arduino can read

This was a mod on a standard kitchen scale:
20131107_Weegschaal.jpg

Graph of a 2332g weight on the scale with temperature logging (blue is weight, green is temperature and red is a 100 minute average):
20131108_Weegschaal+Temp.png

It's obvious that these load cells are quite sensitive to temperature. 2 degrees temperature difference translates into a 2 gram difference in weight. So there needs to be some temperature calibration. Also these sensors tend to drift a bit over time.

Regular kitchen scales calibrate when you switch them on and there is no weight on them. In the grow room the plant would always be on top of the scales so I didn't quite figure out how to calibrate the sensor over time. Perhaps lift the pot now and then or maybe there is nothing needed.

My idea was to water the pot to saturation and then weigh to get an idea of how much weight the plant gains over time. On a day to day basis, the weight difference would tell how much water disappeared.

Since then I switched to hydro and I haven't done much with this, but I would still love to be able to track how fast the plant is adding on weight some day
 

wietefras

Well-Known Member
Hi @wietefras :)

nice job ! is your code available somewhere ?

how much have you paid for the printer and what size ?

Thanks !
Thanks :)

The code isn't available, but for these things it's usually just a matter of using a bit of example code. For pretty much all sensors you can find example code from Adafruit, Sparkfun or something like that.

The basic datalogger code you can also find examples, but everybody likes to do those things their own way. For now my code is still much a work in progress although the basic data logger has been running for quite a while now and I rarely change anything there.

The 3D Printer I bought is the Ultimaker 2: https://ultimaker.com/en/products/ultimaker-2.

I designed a fan duct and I needed to split that in two to get it to print:
20150619 FanVerloopCompleet.jpg

Also made some supports that clip onto the tent poles for fixing a scrogg net:
20150729 3D ScrogsteunOpBuis DSC7040.jpg 20150729 3D ScrogsteunMetHout DSC7042.jpg

A funnel for transferring the ground up weed from the grinder into the holder for the Plenty vaporizer (the white bit visible in between the grinder and holder):
20150910 PlentyFunnel.jpg

A sturdy ratched rope holder (downloaded from Thingiverse)
3DPrint_Ratchet_Lichthanger_DSC7646.jpg
 

wietefras

Well-Known Member
CO2 Sensor

Unfortunately these sensors tend to be quite expensive. The ones based on the NDIR principle (Nondispersive infrared sensor) usually start around $100 or so. Instead I went for a cheaper catalytic sensor.

A sensor like the MG-811 can be bought for around $20, but you need some extra circuitry for the heating which needs 6V and for amplifying the signal to something the Arduino can read. Didn't feel like spending a lot of time saving myself $30 so I bought a ready made module from sandbox: http://sandboxelectronics.com/?p=147

This thing just hooks up to an Arduino and with their example code you are up and running in minutes.

Well sort of, because first you need to calibrate. A good site with extra info on this can be found here: http://www.veetech.org.uk/Prototype_CO2_Monitor.htm

Basically you need to check ambient CO2 levels and measure a saturated CO2 level (your breath) to get a two point calibration.

Funny thing with the sensor was that the CO2 level kept dropping while I had it running. Apparently the sensor uses some CO2 itself. So it does need some airflow. i installed a tiny fan to give it a supply of fresh air.

I also added a display so I could see what it was measuring and write the data on the SD card:
20141228_CO2_SandBox_DSC5457.jpg

In the end it should be a sensor that gets connected to the data logger so I wouldn't need a screen or SD card, but this was just a prototype for testing out if it works at all.

These things are less accurate than the NDIR sensors, but all I need to know is if the CO2 levels are elevated in the grow room. If it's 800ppm or really 750 or 850 doesn't matter.


Thermal imaging
The plant temperature camera measures an average temperature over a large chunk of the canopy. I wanted to see a more detailed and more accurate thermal image of the whole canopy so I tried a IR thermal imaging sensor

The Lepton FLIR sensor is a relatively low cost sensor which can produce a 80x60 temperature map:
Lepton_FLIR_Shutter.jpg

I found it a rather finicky device to get to work and the example code is rather poorly worked out. Biggest issue I had with this is that you only get some meaningless numbers between 0 and 16484 which are centered around the temperature of the sensor itself. So getting actual temperature data would mean calibrating the device by a know temperature in the view of the sensor. It also didn't play nice together with the TFT touchscreen that I wanted to use for displaying the thermal images.

I guess it's all doable, but I got rather fed up with the thing and programming it all is a lot of work. For a few bucks extra you can buy a FLIR One that you can simply plug into your smartphone.

It does work though. Here is my ugly mug :)
FLIR.jpg

I created this with raw data from the sensor and then using Excel with conditional formatting


Water quality sensors


Of course an important thing to know in hydro is the quality of the water.

Atlas Scientific sells these with very nice modules for measuring EC, pH, ORP or DO (dissolved oxygen), but they are all a bit pricey.

pH sensor modules with probe can be found for around $25 to $40 on eBay or AliExpress.

Another good source for these modules is https://www.sparkyswidgets.com/ The probes are easy to find on eBay or AliExpress.


Power usage

Growing cannabis indoors uses a lot of power and if you want to keep track of it you can could log that on the Arduino too.

There are sensors that you actually need to insert into the circuit:
Free-shipping-1PCS-LOT-Hall-Current-Sensor-Module-ACS712-20A-model-for-arduino.jpg
Or clasp them onto a powerline:
yhdc01_small.png

An example of an energy monitor: http://openenergymonitor.org/emon/buildingblocks/report-yhdc-sct-013-000-current-transformer

Trouble with this is that you also should know the exact voltage to correct for distorted wave forms caused by inductive loads. You should calculate the power factor or Cos Phi factor, but that;s not so easy.

Monitoring the cure

One thing i would like to automate more is the drying and curing. For now I created a board that allows me to hook up a dozen humidity sensors. I put a sensor in every pot and keep track of humidity levels. Better would be if the system would open automatically when the humidity is too high.
 

SnaFuu

Well-Known Member
Good job:clap:

Love all this... Though i'm only just starting out. Don't even have an arduino yet... But there's so much potential here i'm in the process of soaking it all up to eventually (soon) aim my legitimate and illegitimate businesses this direction.

The future is now:bigjoint:

Any plans to get the board on a wireless network so you can access cameras or view datalogs remotely?
 

wietefras

Well-Known Member
Thanks.

Yeah the next thing is controlling things with the Arduino. Monitoring the grow is a great way to learn what effects the plants and how, but the real benefits come when the Arduino takes menial jobs out of your hands. I'll post those some of those too.

I took apart my nutrient mixing system because I needed the EC and pH meters for something else and the pump as well. I still regret doing that :-( It's just so much easier to tell the device to mix to a certain EC and pH instead of doing this yourself. I'm not patient enough and also a bit clumsy I guess. Often I will add to much pH- or end up with an EC of 3.0 or something and then I have to start again.

The Raspberry pi is running a web server, so I can reach that from anywhere if I would like to do so. I can simply call up the charts or a page with values on my phone.

I also had a webcam connected to it, but I stopped running that. I still felt the need to just see the ladies live and a webcam sees only a bit of the room. I have been meaning to put the webcam back into the tent to make time lapse video's though. I saw some of those and you can really see the cola's fattening. Would perhaps help determine the best harvesting time for when the buds are fattest.

I bought a Pi-NoIR webcam that has, as the name indicates, the IR filter removed. Adding a blue filter allows taking NDVI images which will show if the vegetation is showing high photosynthesis or not. Or perhaps if the vegetation doing worse in some area's. Not sure exactly if his will be beneficial for an indoor grow, but I wan't to try it out :)
https://publiclab.org/wiki/ndvi
PetVISNDVIcomp.jpg
 

a senile fungus

Well-Known Member
I noticed the VPD has some sort of cycle where it starts off high when the “day’ starts, then it drops during the “day” and before the lights go off it goes up again. The VPD is the orange line at the bottom of this image:
View attachment 3570531

I’m still trying to figure out if this actually means the plants could use more light in the middle of the day or that this is just the result of something else. My idea was to dim the lights on a curve similar to how more sunlight reaches the plants at noon and less in the morning and evening. Overall the plants would get the same amount of light energy, but then perhaps they can use it more efficiently this way.

Dimlux sells a controller that protects the plants from overheating based on the same VPD principle. Although they only use it as a protection when the system is unable to keep the climate within the proper range.

The plants should always be slightly colder than the ambient temperature because the plants are cooling themselves by transpiring water. The Dimlux controller will dim or switch off the lights when the PT goes above the air temperature or when the VPD goes too high. When the plants are no longer transpiring something is seriously wrong. The plants will then have closed their stomata to protect themselves against drying out. That means no more photosynthesis is going on either. That’s damaging to the plants and a massive waste of energy in lighting. You can see the same occur with plants outside when they receive too much sun and heat.

Have you ever heard of mid-day depression?

http://www.nature.com/articles/srep04389

Worth a read
 

wietefras

Well-Known Member
Thanks people :)

Have you ever heard of mid-day depression?

http://www.nature.com/articles/srep04389

Worth a read
Yeah I read that one. Have you seen their midday temperatures though? It goes up to 40C (104F), their VPD runs up to 4kPa and the light intensity goes up to 1750umol/s/m2 and in some cases almost 2000umol/s/m2! That's like putting a blowtorch on them and then act all surprised they don't like it :)

I really don't get the point of that report and it seems to be misleading people into thinking that midday depression is actually a thing. It's not. This particular situation is an exception. Or at least I assume it isn't 40C all over the planet (yet). Of course plants can't take that kind of abuse and their photosynthesis collapses.

My plants don't like a VPD of over 1.5 either. Indeed I get canoe leaves and photosynthesis suffers. Yet the lowest VPD they measured was 1.5kPa and it quickly goes up from there.

The collapse in the photosynthesis processes they charted isn't caused by a diurnal cycle, but by overloading the leaves.

I have seen the same happen to my plants but only when the HPS bulb was too close to them. Cannabis plants are C3 and they close their stomata when they overheat/dry out. When the stomata are closed they can no longer transpire and indeed photosynthesis halts. That's why we prevent that.

As shown in my charts above, my plants in a properly controlled climate actually show more transpiration in the middle of the day. More transpiration means more open stomata and more activity in the plant.

I guess I should install that NDVI camera and measure photosynthesis to see how much more.
 

Purpsmagurps

Well-Known Member
Woah! This is RAD. I'm setting up mini raspberry pis eventually so I can check on all my tents. but this is a little more than what I planned to do lol.
 

TommyDuhCat

Well-Known Member
Very cool. I use Arduino (and a few other cheaper microcontrollers) on my race bikes for a gps lap timer, traction control, and data logger. Working on a few expansions with a buddy to handle some other tasks. Arduino makes a fine unit.

Luckily for me, my buddy writes most of the code. Im a novice with coding and debugging. He has written a few thousand lines for our units.
 

bggrass

Well-Known Member
Stuff like this really excites me. I've been thinking on a digital potentiometer, with the raspPi that is quite feasible/fun. Don't have the budget to play with it at the moment, but maybe further down the road. Let me know if you need some code for a function you have in mind, maybe I can write/modify it for you. I've seen them short codes/functions online that come with some gadgets. Doesn't seem hard and I'll learn something new.
 
Top