Friday, February 22, 2013

Automatic greenhouse control system










My brother is a farmer and he owns a couple of green houses. The greenhouses are computer controlled; depending on light intensity and temperature in each green house, the computer system lifts or closes the window panels to keep the temperature constant and safes the plants from too much heat or cold. The control system my brother uses is a very well established system. The only drawback is, that it costs a fortune. So my brother came up to me and asked me, if I can figure out a cheaper solution. Well, and there we go with my concept that is less than 100USD...



Overview about the conceptional system showing light and temperature sensors (left), the micro-controller board (middle) and the control output (left, LEDs for illustration) which will be connected to the greenhouse window lifting system

Micro-controller board used in this concept project; Arduino Leonardo


Ok, so how does it work? I am using temperature sensors (LM35) and light sensors (LPR) to detect the actual temperature and light intensity in the greenhouses. - In the current example I am controlling two greenhouses and therefore there are two light sensors and two temperature sensors-. The electronic signals are sent from the sensors to the micro-controller board (Adruino Leonardo). The board processes the signals and sends the data to the computer that is connected via USB micro plug.
GUI showing actual temperature and light values as well as temperature and light criteria used in the algorithm to control the greenhouse window panel and ensure constant temperature in the greenhouse


I have used Python to create a Graphic User Interface (GUI) that presents the sensor values and the history of the sensor values via Diagram.

Recorded temperature and light (light less than 3klx, thus not visible in the chart) history


I have implemented several algorithms that check temperature and light intensity in order to verify if a greenhouse window panel must be opened or closed. After processing the input signals, electronic impulses are sent from the computer back the the micro-controller which then sends opening or closing signals to the window panel control system. (Here simulated with LEDs) 

LEDs are used to simulate the window panel control.

  

Wednesday, February 6, 2013

F2PY on 64bit Windows (python2.7)

I am writing this post because after hours of frustration I want to share the solution that I found to get F2PY running on a 64 bit windows machine. Ok, here is how it worked out for me,...

If you have old python stuff on your computer, than entirely remove it and download and install components in the following order:

.) Python 2.7.3 Windows X86-64 Installer under http://www.python.org/getit/
.) numpy-unoptimized-1.6.2.win-amd64-py2.7.‌exe under http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

Then download and extract
.) mingw-w64 under http://sourceforge.net/projects/mingw-w64/
From the extracted directories copy mingw to your c:\mingw

After that, go to your environment variables (under System) and add
.) C:\Python27\Scripts
.) C:\mingw\bin 
to the PATH variable

Add also .py to the PATHEXT variable.


To use F2PY now write: 

f2py -c --fcompiler=gnu95 --compiler=mingw32 -m yourmodulename yourfortranfile

Important note:
I still got an error on my system saying:

"File "C:\Python26\lib\site-packages\numpy\distutils\fcompiler\gnu.py", line 331, in get_libraries raise NotImplementedError("Only MS compiler supported with gfortran on win64") NotImplementedError: Only MS compiler supported with gfortran on win64"

I solved the problem absolutely randomly: 
I changed C:\Python27\Lib\site-packages\numpy\distutils\fcompiler\gnu.py line 331 to:

pass #raise NotImplementedError("Only MS compiler supported with gfortran on win64")

Basically I un commented the NotImplementedError and it worked fine!! GEZUZ!!