Greenhouse project

Hi there,

I’m planning a monitoring/automation solution for a greenhouse (used to grow vegetables).

The goal is to monitor ambient air (temp/r hum%/lux), soil moisture at different places/depth, rainwater level in a cistern and irrigation/heating control (and connect this to my home automation solution). More stuff might be added later.

From what I’ve seen, it seems that a Raspberry Pi + GrovePi+ would be a nice fit for the project.

Nice to see that a grove sensors exists for soil moisture. I just hope that it’s not constantly powered on – only when reading it’s value? (to avoid fast corrosion). Can somebody confirm that it’s safe to use for a permanent use?
I will probably also need a way to protect it’s PCB, as I intend to bury one of the sensors ~30cm deep. Maybe some waterproof glue?

Regarding water level estimation, I initially had in mind the grove ultrasonic sensor, but there is a risk for the tank to overflow. I guess that the sensor won’t appreciate taking a bath… so I think I will go with 10 simple water level sensors switches connected to a IO-Pi-Plus from AB electronics (https://www.abelectronics.co.uk/p/54/IO-Pi-Plus), mounted on top of the GrovePi+: does anybody see a potential incompatibility between the GrovePi+ & IO-Pi-Plus? (I couldn’t find any while reading the respective docs).

Thanks!
Kind regards,
Cedric

Hi Cedric,
GrovePi does sound like great solution for your Greenhouse automation problem.

I am not really sure about the life of the moisture sensor. There is a costlier option available though which should last longer: http://www.seeedstudio.com/depot/Soil-Moisture-Temperature-Sensor-p-1356.html?cPath=25_27, though you might have to do a bit of soldering to get it connected the the GrovePi.

The ultrasonic sensor is the best sensor available out there to measure the water level. Usually tanks have an overflow system and it might be better to keep it above that if possible and you can keep the ultrasonic sensor a bit higher than the max water level. If you want to use then IO-Pi-Plus, then that would work too or you can try using this too http://www.seeedstudio.com/depot/water-level-switch-p-565.html?cPath=25_27.

Do keep us updated about your project and do share more detials and pictures of it when it’s done. We’ll be more than happy to share it with community and feature on our site.

-Karan

Hi Karan

Thanks a lot for your feedback. Will keep the post updated as I move forward!

The SHT-10 based soil sensor looks nice and robust indeed. Do you know if somebody already produced a wiring diagram for use with GrovePi?

I will also try the basic soil moisture sensors as they are inexpensive – and see how they perform. I believe that I need to turn them ON only when reading to limit corrosion (once every 5 or 10 minutes). Can I use a GrovePi Digital out pin to provide them with on-demand 3.3V? or should I go through a dedicated relay? – not sure how much current I can draw from a digital out pin?

Regarding the water level switch, that’s exactly the kind of component that I have in mind. However, I was thinking on connecting them to a IO-Pi-Plus instead of GrovePi, as I need ~10 switches – and I don’t see how to easily connect all of them to a GrovePi!

Cheers,
Cedric

The SHT sensor uses I2C, so you can choose any of the connectors here: http://www.seeedstudio.com/depot/s/grove%20cable.html?search_in_description=0 and connect the wires in this way SHT sensor: Red = VCC (3-5VDC), Black or Green = Ground, Yellow = Clock, Blue = Data. Grove Connector:Red=VCC,Black=GND,White=Data,Yellow=Clk.

Yeah, it might be worth testing the basic moisture sensor. You can use digital out to control power to it, but since the sensor is an anlog sensor, you’ll have to change the wiring of the cable a bit to do that. The easiest way to do that would be to remove the white cable from the side which connects to the GrovePi and replace that with the red VCC cable from the sensor, so that the wiring of the grove connector which connects to the GrovePi becomes: NC,Black,Red,Yellow. This way when you connect it to any anlog port, you can control the voltage on it and also read from it.

-Karan

Hi there!

Finally been able to install my greenhouse & RPI/GrovePi+ stuff.

So far, it works perfectly.

I just have an issue with the digital light sensor (that one: http://www.seeedstudio.com/wiki/Grove_-_Digital_Light_Sensor): it gives complete random results during day :frowning:

Readings are stable at dusk & night, but as soon as enough daylight is present, readings are completely wrong/unstable:

# python grove_i2c_digital_light_sensor.py
Power ON

There is light:
ambient = 5874
IR = 28237
_ambient = 5874
_IR = 28237
Light = 0 lux.
Power OFF

There is light:
ambient = 29937
IR = 16461
_ambient = 29937
_IR = 16461
Light = 206.5422 lux.
Power OFF

There is light:
ambient = 63472
IR = 7501
_ambient = 63472
_IR = 7501
Light = 1810.05141938 lux.
Power OFF

There is light:
ambient = 20976
IR = 61004
_ambient = 20976
_IR = 61004
Light = 0 lux.
Power OFF

There is light:
ambient = 54511
IR = 51788
_ambient = 54511
_IR = 51788
Light = 49.59838 lux.
Power OFF

There is light:
ambient = 12527
IR = 40012
_ambient = 12527
_IR = 40012
Light = 0 lux.
Power OFF

There is light:
ambient = 41710
IR = 29772
_ambient = 41710
_IR = 29772
Light = 118.951 lux.
Power OFF

There is light:
ambient = 5358
IR = 19788
_ambient = 5358
_IR = 19788
Light = 0 lux.
Power OFF

There is light:
ambient = 39661
IR = 10828
_ambient = 39661
_IR = 10828
Light = 867.309702507 lux.
Power OFF

There is light:
ambient = 62956
IR = 64843
_ambient = 62956
_IR = 64843
Light = 44.19948 lux.
Power OFF

[...]

(each reading is separated by 1 sec)

Already seen something similar?
Maybe a new revision of the chip that requires some changes?

Thanks,
Cedric

Hey cedric,
Can you run i2cdetect -y 1 and post what you get here. Do you get any good reading with some light. What do the reading look like in the dark. Has this sensor worked for you before.

-Karan

Hi Karan,

The sensor is new. Never got a correct/stable reading at day with it!

During night, I get stable readings at 1-1.1 lux (ambient=34-35, IR=2) – this is not 0 as the Grove RGB LED’ backlight nearby provides some light.

Collected the following log this morning. Sun rises at 07:12:

[04/03/2016 06:20:06] Ambient 34/34, ir 2/2, lux 1.000000
[04/03/2016 06:21:23] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:22:41] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:23:58] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:25:15] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:26:33] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:27:50] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:29:08] Ambient 35/35, ir 2/2, lux 1.100000
[04/03/2016 06:30:25] Ambient 36/36, ir 2/2, lux 1.100000
[04/03/2016 06:31:42] Ambient 36/36, ir 2/2, lux 1.100000
[04/03/2016 06:33:00] Ambient 36/36, ir 3/3, lux 1.100000
[04/03/2016 06:34:17] Ambient 37/37, ir 3/3, lux 1.100000
[04/03/2016 06:35:38] Ambient 37/37, ir 3/3, lux 1.100000
[04/03/2016 06:36:55] Ambient 39/39, ir 3/3, lux 1.200000
[04/03/2016 06:38:13] Ambient 40/40, ir 3/3, lux 1.200000
[04/03/2016 06:39:30] Ambient 42/42, ir 4/4, lux 1.200000
[04/03/2016 06:40:47] Ambient 44/44, ir 4/4, lux 1.300000
[04/03/2016 06:42:05] Ambient 47/47, ir 5/5, lux 1.400000
[04/03/2016 06:43:22] Ambient 51/51, ir 6/6, lux 1.500000
[04/03/2016 06:44:40] Ambient 57/57, ir 7/7, lux 1.600000
[04/03/2016 06:45:57] Ambient 65/65, ir 9/9, lux 1.800000
[04/03/2016 06:47:14] Ambient 75/75, ir 12/12, lux 2.000000
[04/03/2016 06:48:32] Ambient 89/89, ir 16/16, lux 2.300000
[04/03/2016 06:49:49] Ambient 108/108, ir 22/22, lux 2.700000
[04/03/2016 06:51:07] Ambient 133/133, ir 30/30, lux 3.200000
[04/03/2016 06:52:24] Ambient 164/164, ir 40/40, lux 3.800000
[04/03/2016 06:53:41] Ambient 202/202, ir 51/51, lux 4.600000
[04/03/2016 06:54:59] Ambient 254/254, ir 67/67, lux 5.700000
[04/03/2016 06:56:16] Ambient 16129/16129, ir 86/86, lux 507.400000
[04/03/2016 06:57:33] Ambient 35585/35585, ir 107/107, lux 1120.300000
[04/03/2016 06:58:51] Ambient 58881/58881, ir 132/132, lux 1854.100000
[04/03/2016 07:00:08] Ambient 23298/23298, ir 165/165, lux 732.500000
[04/03/2016 07:01:26] Ambient 2307/2307, ir 230/230, lux 67.200000
[04/03/2016 07:02:43] Ambient 61699/61699, ir 18433/18433, lux 1269.300000
[04/03/2016 07:04:00] Ambient 51972/51972, ir 38145/38145, lux 129.400000
[04/03/2016 07:05:18] Ambient 26373/26373, ir 45057/45057, lux 0.000000
[04/03/2016 07:06:35] Ambient 64005/64005, ir 50945/50945, lux 87.900000
[04/03/2016 07:07:53] Ambient 34822/34822, ir 56577/56577, lux 0.000000
[04/03/2016 07:09:10] Ambient 58886/58886, ir 57601/57601, lux 49.300000
[04/03/2016 07:10:27] Ambient 14087/14087, ir 57857/57857, lux 0.000000
[04/03/2016 07:11:45] Ambient 52999/52999, ir 1794/1794, lux 1642.000000
[04/03/2016 07:13:02] Ambient 53512/53512, ir 26370/26370, lux 507.400000
[04/03/2016 07:14:22] Ambient 41738/41738, ir 17667/17667, lux 572.000000
[04/03/2016 07:15:40] Ambient 21260/21260, ir 61699/61699, lux 0.000000
[04/03/2016 07:16:57] Ambient 53772/53772, ir 52483/52483, lux 45.300000
[04/03/2016 07:18:14] Ambient 64525/64525, ir 5124/5124, lux 1922.200000

As you can see, as soon as enough light comes in (even before official sunrise time), readings are random.

As for i2cdetect:

# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          03 04 -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- 29 -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3e -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- 62 -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
#

I took a very quick look at code provided by Seeed: https://github.com/Seeed-Studio/Grove_Digital_Light_Sensor/blob/master/Digital_Light_TSL2561.cpp
It’s a bit different than the one in your repository: https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grove_i2c_digital_light_sensor/grove_i2c_digital_light_sensor.py
One thing that did struck me is that they are using an integration time of 13ms, while the python version is using 402ms. I didn’t read the sensor specs to really understand what that means, but maybe some register is overflowing when using 402ms?

The Seeed version is using low gain mode only, while the python version tries both low & high. However, bad readings happen also in low gain mode.

The .cpp lib doesn’t seem complex. Might rewrite it in python if I can spare some time and see if it solves the issue.

Follow up: I made a quick port of the Seeed provided .cpp file for RPI/Python, and now get stable (and good?) readings.
So it really seems that the 402ms integration time was the culprit here.

Will monitor in the coming days how it behaves (-- and if I need to support high gain mode).

Will share the resulting python lib here when I get confident with the results.

Hey cedricm, thanks for letting us know more about this. Can you please share your python script? We’d love to take a look!

1 Like

Hi John,

Sure, here it is: https://raw.githubusercontent.com/cmaion/TSL2561/master/TSL2561.py

It has been up and running for a couple of days, works great and results seems reliable/stable.

I extended the logic to dynamically select 13.7, 101 or 402ms integration time, and high/low gain, depending on current light conditions:

  • when raw readings are starting to get low, precision is dropping, so I switch to higher integration times (and then select high gain when dark): 13.7ms => 101ms => 402ms => 402m with 16x gain
  • when raw readings are starting to get high, saturation/overflow is an issue, so I do the opposite: 402ms with 16x gain => 402ms => 101ms => 13.7ms

This enables full range lux estimation, both during night and under bright sun light.

I may adjust a thing or two in the library, depending on my experience (esp the threshold values), but so far it’s working great.
One thing that may not be really useful in my case is the 13.7ms integration time, as I don’t believe it yields more precision than at 101ms (it’s just faster but also less precise under lower light levels). It’s here for now until I can verify this (ie., this spring/summer!)

As it is right now, the library is starting with 402ms and will work with that from ~150 lux to ~5500 lux. Will engage high gain (16x) below [until it reaches again ~700lux], and switch to 101ms if over.

The library in your repository didn’t work for me unless when dark. The 402ms integration time should have given me good results most of the time, except maybe during a bright day – so something else might be wrong.

My library is also much closer to the sample C code provided in the datasheet, making it easier to compare.

Hope this helps!

1 Like

Hey cedricm, thanks for the script? I was having the same issue with a GrovePi and the digital light sensor, the analog one worked fine, but the digital sensor was all over the place. I just installed your script and things are looking good.

By the way, how is the gardening project going? I am interested to hear what sensors you have hooked up. I am working on a home monitoring system. I have multiple Pi’s talking over an MQTT broker (hosted on a Pi) and sensor times-series saving for up to 6 months in a time-series database (hosted on a Pi), and a dashboard with real-time graphs of the data coming in. The code is here: https://github.com/wilblack/lilybot
You might find something useful there.

I’ll post some screen shots of the lux time-series as i get some data coming in the next couple of days.

Cheers,
Wil.

Hi Will,

Glad it helped!
On the grove side I don’t have much stuff: 3 soil moisture sensors, rgb i2c, hum/temp pro, light sensor i2c, buzzer, pir.
The RPI is also driving directly a 4 relay board (water pump, heating…), a 5mp fisheye USB webcam and is also connected to push buttons and 7 water level switches.
The RPI is autonomous, but is also integrated with my home automation solution (lots of z-wave & oregon scientific devices, IP cams and misc stuff). So I’m getting history/graphs/alerts for free from my ha solution :slight_smile:

Will take a look at your repo.

Cheers,
Cedric

1 Like

Hey Cedric,
It would be great if you could share some pictures, write-up or a post that you have for your greenhouse project. It would be great to showcase your project to the community.

-Karan

1 Like

Hey Cedric, we would love to work more with you on the greenhouse project and see if we could get a tutorial up!

Hi Karan, John,

OK will think about it and see if I can provide a blog post with pictures.

Cheers,

Cedric

@walkpto: I have answered the other forum post. Lets continue the conversation there. Since this post is on a different topic, can you please delete the post above and move the conversation to the other forum post.

Thanks,
Karan

This topic was automatically closed after 24 hours. New replies are no longer allowed.