temperature average day

Forum about Domotiga Open Source Home Automation for Linux.

Moderator: RDNZL

Pik
Starting Member
Starting Member
Posts: 33
Joined: Sun Apr 13, 2014 2:14 pm

temperature average day

Post by Pik »

Hello,

I wish to implement a valve in my installation for my garden greenhouse.
Today, I use an automatic "gardena" device to drive this watering. But, in my greenhouse, when no sunny day, it's not necessary to have wastering. In the opposite, when sunny days, even opening door, temperature is quite high and humidity level quite low => Necessary to have watering.

As I have an Oregon sensor in this greenhouse, the idea is to use DOMOTIGA to drive the valve when necessary.
The idea is to record the average temperature for day time + to record humidity level for day time.
By the end of the day (it could be a Cron automation or an event), If upper or under a certain level, wastering has to be done.
I know how to manage Cron automation, but to read the average temperature or Humidity (or to calculate it) for a period of time = I can't find a solution !
I beg the attention I only need to have those values for a time period - day time (for example, I don't want to have the night temperature to interfer with day situation).

1 - Do you know how to call back or to have the average temperature for day time (between sunrise & Sunset) ?
2 - Do you know how to call back or to have the average humidity level for day time (between sunrise & Sunset) ?

I usee RRD Tool for graph, and I can see maxi, min and average temperature for last 12 Hrs... so it should be possible to use those values in DOMOTIGA... isn't it ?

Does anybody has an idea ?

(You will makes my salads more happy as today they have a lack of water when to sunny and my tomatoes too much water when cloudy !)
Henk
Member
Member
Posts: 450
Joined: Sat May 06, 2006 10:54 pm
Location: Netherlands

Re: temperature average day

Post by Henk »

I'm right now developing irrigation controllers to be used for the garden, flowerbeds (bloembakken) and green houses. The controllers are based on the micro processor Arduino combined with all kind of sensors. If required those irrigation controllers can be integrated with Zwave and operational together with a Zwave domotica controller (like HC2/lite/Vera)
The price is very reasonable and it has a lot of flexibility based on available hardware and programming. It can be operational as a stand alone controller

In your case i would suggest the following components:

Arduino
Temperature / Humididty sensor
Clock module
Soil moisture sensor (as alternative for average temperature)
Relais module to control valve or pump / or fan
Power supply / Box to put the hardware in (usually more expensive as the microprocessor)
Light sensor (optional)
Display (optional)
Operational panel switches/pushbuttons (optional)
Rain sensor (optional)

Also you should considering watering at root level by tubing and not from the top. (sprinklers type) Consider also a safety control so in case of a failure the supply of water will stop.
You may even consider to expand the function of this greenhouse controller to the irrigation of your garden it will be a matter of adding some extra relais / valves and sensors.

In case you are interested or other members for this kind of irrigation controllers you might contact me I'm at hotmail (@hotmail.com..... with in front username homenica

Henk
Pik
Starting Member
Starting Member
Posts: 33
Joined: Sun Apr 13, 2014 2:14 pm

Re: temperature average day

Post by Pik »

Hi Henk,

Thanks for your feedback. But I don't wish to buy this kind of automatic equipment especially as my DOMOTIGA with sensors can provide something similar. I have sensors (temperature + humidity + light) and Switches + valve.
Further to security, yes, I have a timer prevented valve to stay open if for exemple signal is not received. This timer is very cheap and works nice (220v model just before valve power supply).
Hardware is ready, I just need to know how to calculate the average temperature for a time period.

Any other idea ?
OWK
Member
Member
Posts: 62
Joined: Sat Sep 24, 2011 11:03 am

Re: temperature average day

Post by OWK »

Idea: use global variables that reset each day after irrigating

Create a variable for:

-Sum of temperature
-Count of measurements

Add the result of each temperature measurement to the global var. Also increase the counter after each measurement.

Set your condition to the average temperature value to start irrigating

After irrigation reset both global variables and start all over

Hope this helps, regards

OWK
Domotiga
Cubietruck, Ubuntu server 1.0.2
RFXcom LAN, home brew ground plane antenna
KaKu
Pik
Starting Member
Starting Member
Posts: 33
Joined: Sun Apr 13, 2014 2:14 pm

Re: temperature average day

Post by Pik »

Hello OWK,

Yes, I like your idea and I tried this :

Temp_total : is Global var for sum of temperature
Temp_n : is count of measurement.

But, in script when I do Temp_n = Temp_n + 1 this give message "False" as comparing (Temp_n) to (Temp_n +1).
Same for Temp_total...
I should miss something... could you please enlighten me a little more?
Do you know how to increment a global var and how to make sum of device_value + previous global var ?

Best regards.
OWK
Member
Member
Posts: 62
Joined: Sat Sep 24, 2011 11:03 am

Re: temperature average day

Post by OWK »

I was brain storming on your request for help ;-)

Never the less, I use global variables in my system. There are two ways to set a global var:
-by action type 'Set GlobalVar'
-by action type 'Script'


Setting a gobal var using the script action can be done using: Main.SetGlobalVar("VarName",YourValue)

Examples:
-Set variable to the current date/time: Main.SetGlobalVar("varAtHomeDateTime",Now())
-Set variable to a device value: Main.SetGlobalVar("varHumidity",Dev_39_Value2)

So my advice is to play with Main.SetGlobalVar function a little bit. Use the script editor available from the action window, it gives you a direct access to values stored.

Regards
OWK
Domotiga
Cubietruck, Ubuntu server 1.0.2
RFXcom LAN, home brew ground plane antenna
KaKu
Pik
Starting Member
Starting Member
Posts: 33
Joined: Sun Apr 13, 2014 2:14 pm

Re: temperature average day

Post by Pik »

Hi OWK,

Your idea is nice : to increment a count and to sum temperature... later, to caclculate average.
Yes, I found this function "Main.SetGlobalVar" and I can use it, but I can't make a sum and an increment !

I tried : Main.SetGlobalVar(VarHumidity, Device_value + VarHumidity) but the (+) operator is not accepted.
I tried too to have a temp variable like : temp = temp + 1 but in this case, (=) operator is seen as a comparison to do !

Do you know if a specific function has to be used to make a sum between variables or Variable and a number ?

Thanks a lot anyway for your time to try to help me to solve this issue.

Best regards.
OWK
Member
Member
Posts: 62
Joined: Sat Sep 24, 2011 11:03 am

Re: temperature average day

Post by OWK »

It could be that the varables are strings and not numbers.
Try/experiment to convert your variable to numbers if used in calculations, maybe that helps. The way to do this is: val(variableName).

Regards
OWK
Domotiga
Cubietruck, Ubuntu server 1.0.2
RFXcom LAN, home brew ground plane antenna
KaKu
Pik
Starting Member
Starting Member
Posts: 33
Joined: Sun Apr 13, 2014 2:14 pm

Re: temperature average day

Post by Pik »

Hi,

OK, I'll try in coming days.

Thanks again !
Pik
Starting Member
Starting Member
Posts: 33
Joined: Sun Apr 13, 2014 2:14 pm

Re: temperature average day

Post by Pik »

Hello,

I tried to convert variable, but the "=" operator is seen as a comparison to do. So, I can' do an operation like :
a = a+ 1 or a = a + b
If I only write : a+1 in editor field and running it, I can see result.
if I write a = a + 1, I get "false".

So, I think in fact, it's not a format trouble.

Oh my poor salads...
OWK
Member
Member
Posts: 62
Joined: Sat Sep 24, 2011 11:03 am

Re: temperature average day

Post by OWK »

So you tried this ?

Main.SetGlobalVar(VarHumidity, val(VarHumidity) + val(Device_value))

Regards
OWK
Domotiga
Cubietruck, Ubuntu server 1.0.2
RFXcom LAN, home brew ground plane antenna
KaKu
Pik
Starting Member
Starting Member
Posts: 33
Joined: Sun Apr 13, 2014 2:14 pm

Re: temperature average day

Post by Pik »

Hello,

I created an action and I wrote this script :
Main.SetGlobalVar(Var_Temp_n, Var_Temp_n+1)

When I check the script (into Editor : Run) I get "True"
In action list, I launch the acion (right clic on action and "run action")
In GlobalVar Window, I see no change in my globalVar still at 0

Temp_n is my globalvar to count values. I have an other globalvar for temperature sum.

I tried also :
Main.SetGlobalVar(Var_Temp_n, 1)
My var Temp_n stay on 0

I tried :
Main.SetGlobalVar(Var_Temp_n, "2")
Still 0 in Temp_n

Is there a mistake in my script ?
OWK
Member
Member
Posts: 62
Joined: Sat Sep 24, 2011 11:03 am

Re: temperature average day

Post by OWK »

You did not follow my advise to use val().

Your script should be reading: Main.SetGlobalVar(Var_Temp_n, val(Var_Temp_n)+val(1))

If that is not solving the problem i'm lost. Maybe other forum members can help from here

Lets wait and see what happens

Regards
OWK
Domotiga
Cubietruck, Ubuntu server 1.0.2
RFXcom LAN, home brew ground plane antenna
KaKu
Pik
Starting Member
Starting Member
Posts: 33
Joined: Sun Apr 13, 2014 2:14 pm

Re: temperature average day

Post by Pik »

Hello,

Yes, I know, but using Val (Main.setGlobalVar(Var_Temp_n, val(Var_Temp_n) +val(1)) ), I get following message :
"Error:type mistmatch Wanted String, Got Integer instead"

If I write "Main.setGlobalVar(Var_Temp_n, val(1))", I get same message.

If I write "Main.setGlobalVar(Var_Temp_n, str(1))" I get message "True" but no change in variable (I see 0 in globalVar).

If I write "Main.setGlobalVar(Var_Temp_n, "1") " I get "True", but variable Temp_n keep 0 value.
Strange... I'm quite sure I miss something... but what ?


This evening, I will spend more time on this issue...

Best regards.
OWK
Member
Member
Posts: 62
Joined: Sat Sep 24, 2011 11:03 am

Re: temperature average day

Post by OWK »

Start with what is working already and build on that. So setting the variable the first time with: Main.setGlobalVar(Var_Temp_n, devicevalue) is your starting point.

Then concentrate on the second argument only (the one behind the comma) and change nothing to the rest.
Note: Maybe val(1) is not correct, try 1 in stead.

"Error:type mismatch Wanted String, Got Integer instead" suggests that varables are stored in strings and not numbers and you where offering number/integer. So the result of what you calculate will be a stored as a string.

Since calculations are only working with numbers, you should use a conversion to numbers before starting a calculation, i.e. Val(), for each string you use. This all should happen in the second argument.

Idea: convert the result of your caculation to string

Regards
OWK
Domotiga
Cubietruck, Ubuntu server 1.0.2
RFXcom LAN, home brew ground plane antenna
KaKu
Post Reply

Return to “DomotiGa Forum”