Directory of RSS feeds
Statistics

RSS feeds in the directory: 374

Added today: 0

Added yesterday: 0

Hi-Tech / Hardware

Connect soil moisture sensors to MajorDoMo

Samopal.pro 26.01.2019 at 07:01

Recently I designed a party of resistive soil moisture sensors. In this article I will tell how to connect these sensors to the system smart scrap MajorDoMo and make information on the soil moisture of potted plants easy to use.

Before you proceed to configure MajorDoMo I'm a little bit elaborate on your requirements:

the Server should do the conversion testimony of servers in a calibrated moisture value of soil, and also in the simplified concept of "dry", "humid", "emergency water". The connection of similar sensors to the system should be as less labor-intensive. All sensors (humidity and battery status) to be displayed on one screen. You must set up the notification system with specific recommendations and system-wide problems of soil humidity control. If needed report on the frequency of irrigation, date of last watering and the forecast of the date of the next irrigation

I must say that the last function is only possible with the accumulation of data over quite a long period and at the time of writing not implemented.

the sensors Connected to MajorDoMo

After you have enabled controllers humidity new nodes begin to appear on the pages of MajorDoMo Mysensors. In the firmware of the controller defines the presentation of two sensors — a humidity value as the value of the ADC and the battery voltage read through the function ReadVcc()

For convenience, change the name of the node to clear my

the Most close type sensor soil moisture available from this class SHumSensors. But in my case it will display as the primary humidity parameter that is transmitted from the controller, that is the ADC value. To convert these values to percentage of humidity I decided on the server side so each time the calibration is not to go into the firmware of the controller. So I created a new class that inherits SHumSensors with two new properties: "relative soil moisture" and "Evaluation of soil moisture"

relative humidity of the soil specified CA key property with the desired retention period (in my case 1000 days) in the history of the parameters (ie, in a MySQL database).

Property "Evaluation of moisture" I have not the key and the story of his store is not necessary that you specify when you create a

After that, I edited the existing method valueUpdated my class that is invoked on every change of the property value inherited from the parent class.

In the PHP code I write the formula for recalculation of the ADC readings in relative humidity, obtained during calibration of the sensor and the estimated humidity value, convenient for quick understanding

$adc = $this->getProperty('value');

$new_value = 0.000001*$adc*$adc*$adc*-1;

$new_value += $adc*$adc*0.001649;

$new_value += $adc*-0.686978;

$new_value += 121.559157;

$new_value = round($new_value,1);

$this->setProperty('RelativeHumSoil',$new_value);

if( $new_value == " || $new_value setProperty('RatingHumSoil','No data');

else if( $new_value < 40 )

$this->setProperty('RatingHumSoil','Need watering');

else if( $new_value < 50 )

$this->setProperty('RatingHumSoil','Soon watering');

else if( $new_value < 75 )

$this->setProperty('RatingHumSoil','normal');

else $this->setProperty('RatingHumSoil','Very wet');

You can then create objects of the new class for ease of identification in the name of the room adding Mysensors nodes and prescribing in the Name property the name of the plant

For the battery voltage each module I did not create a new class, and take the finished SVoltageSensors. For convenience, add it the ability TextStatus and method valueUpdated added PHP code of his formative

$val = $this->getProperty('value');

$min = $this->getProperty('minValue');

if( $val setProperty('TextStatus','battery Low');

else

$this->setProperty('TextStatus','Battery normal');

Now, fill in the minValue property, TextStatus registers line status of the battery. Actually you can use a built-in mechanism for monitoring Mysensors battery — send a percentage of battery drain sendBatteryLevel(). For this you need to sew the inside of the controller battery type and range of its voltage. At this stage of the project I decided to do the calculation of discharge level on the server side.

so, after each of the controller I built a couple of objects from the sensor the relative humidity sensor of the battery, I connected the sensors with the corresponding Noda Mysensors

Form of control of soil moisture

To display the readings of all parameters of soil moisture and the condition of the batteries create a separate scene with a single element of type HTML.

the Scene with a bunch of individual widgets or icons would look very effectively, but the complexity in its creation, and subsequent additions of settings seemed too high.

In the HTML code of the element scene write an HTML table with the output of all controller parameters humidity

[70] %SavSoil70.Name%

Humidity: %SavSoil70.RelativeHumSoil% %(%SavSoil70.RatingHumSoil%)

Battery: %MysensorsSensor_voltage02.value% (%MysensorsSensor_voltage02.TextStatus%)

Latest survey: %MysensorsSensor_voltage02.updatedText%

[71]

[72] %SavSoil72.Name%

Humidity: %SavSoil72.RelativeHumSoil% %(%SavSoil72.RatingHumSoil%)

Temperature: %MysensorsSensor_temp02.value%

Battery: %MysensorsSensor_voltage03.value% (%MysensorsSensor_voltage03.TextStatus%)

Latest survey: %MysensorsSensor_voltage03.updatedText%

[73] %SavSoil73.Name%

Humidity: %SavSoil73.RelativeHumSoil% %(%SavSoil73.RatingHumSoil%)

Battery: %MysensorsSensor_voltage04.value% (%MysensorsSensor_voltage04.TextStatus%)

Latest survey: %MysensorsSensor_voltage04.updatedText%

[74] %SavSoil74.Name%

Humidity: %SavSoil74.RelativeHumSoil% %(%SavSoil74.RatingHumSoil%)

Battery: %MysensorsSensor_voltage05.value% (%MysensorsSensor_voltage05.TextStatus%)

Latest survey: %MysensorsSensor_voltage05.updatedText%

[75] %SavSoil75.Name%

Humidity: %SavSoil75.RelativeHumSoil% %(%SavSoil75.RatingHumSoil%)

Battery: %MysensorsSensor_voltage06.value% (%MysensorsSensor_voltage06.TextStatus%)

Latest survey: %MysensorsSensor_voltage06.updatedText%

[76] %SavSoil76.Name%

Humidity: %SavSoil76.RelativeHumSoil% %(%SavSoil76.RatingHumSoil%)

Battery: %MysensorsSensor_voltage07.value% (%MysensorsSensor_voltage07.TextStatus%)

Latest survey: %MysensorsSensor_voltage07.updatedText%

[77] %SavSoil77.Name%

Humidity: %SavSoil77.RelativeHumSoil% %(%SavSoil77.RatingHumSoil%)

Battery: %MysensorsSensor_voltage08.value% (%MysensorsSensor_voltage08.TextStatus%)

Latest survey: %MysensorsSensor_voltage08.updatedText%

[78] %SavSoil78.Name%

Humidity: %SavSoil78.RelativeHumSoil% %(%SavSoil78.RatingHumSoil%)

Battery: %MysensorsSensor_voltage09.value% (%MysensorsSensor_voltage09.TextStatus%)

Latest survey: %MysensorsSensor_voltage09.updatedText%

[79] %SavSoil79.Name%

Humidity: %SavSoil79.RelativeHumSoil% %(%SavSoil79.RatingHumSoil%)

Battery: %MysensorsSensor_voltage10.value% (%MysensorsSensor_voltage10.TextStatus%)

Latest survey: %MysensorsSensor_voltage10.updatedText%

[80] %SavSoil80.Name%

Humidity: %SavSoil80.RelativeHumSoil% %(%SavSoil80.RatingHumSoil%)

Battery: %MysensorsSensor_voltage11.value% (%MysensorsSensor_voltage11.TextStatus%)

Latest survey: %MysensorsSensor_voltage11.updatedText%

[81] %SavSoil81.Name%

Humidity: %SavSoil81.RelativeHumSoil% %(%SavSoil81.RatingHumSoil%)

Battery: %MysensorsSensor_voltage12.value% (%MysensorsSensor_voltage12.TextStatus%)

Latest survey: %MysensorsSensor_voltage12.updatedText%

the result is this form

To monitor changes in moisture, you can use the MajorDoMo "Graphics"

Here the graphs clearly seen watering the three plants.

setting up alerts

alert Types in the MajorDoMo of a great variety of TEXTS, various messengers, social networks, and a built-in assistant Alice with voice output. I prefer to receive notification by e-mail in the morning.

To generate the report email I developed the script with the PHP code that runs every morning:

the Script parses the current state of the sensor and forms the first important alert — a list of plants that need watering, a list of controllers requiring battery replacement and not contacted.

Eti zhe problemi peredayutsya cherez pomoschnika Alisu. V kontse pisma dobavlyaetsya polnaya svodka parametrov kontrollerov vlazhnosti na maner formi otobrazheniya

require_once 'lib/PHPMailer/PHPMailerAutoload.php';

$mail = new PHPMailer;

$mail->setLanguage('ru', 'lib/PHPMailer/language/');

$mail->isSMTP();

//Enable SMTP debugging

// 0 = off (for production use)

// 1 = client messages

// 2 = client and server messages

$mail->SMTPDebug = 0;

$mail->Debugoutput = 'html';

$mail->Host = 'smtp.yandex.com';

//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission

$mail->Port = 587;

//Set the encryption system to use - ssl (deprecated) or tls

$mail->SMTPSecure = 'tls';

$mail->SMTPAuth = true;

$mail->CharSet = "UTF-8";

$mail->Username = 'Polzovatel@yandex.ru';

$mail->Password ='Parol';

$mail->setFrom('Polzovatel@yandex.ru', 'SmartHome');

$mail->addAddress('Pochtoviy adres 1', '');

$mail->addAddress('Pochtoviy adres 2', '');

$subj='Ezhednevniy otchet po vlazhnosti pochvi rasteniy';

$mail->Subject = $subj;

global $wat,$bat,$err,$body,$body1,$body2,$body3;

$wat = 0;

$bat = 0;

$err = 0;

$body = '';

$body1 = '';

$body2 = '';

$body3 = '';

ReportSoil1("[70]",'SavSoil70','MysensorsSensor_voltage02');

ReportSoil1("[72]",'SavSoil72','MysensorsSensor_voltage03');

ReportSoil1("[73]",'SavSoil73','MysensorsSensor_voltage04');

ReportSoil1("[74]",'SavSoil74','MysensorsSensor_voltage05');

ReportSoil1("[75]",'SavSoil75','MysensorsSensor_voltage06');

ReportSoil1("[76]",'SavSoil76','MysensorsSensor_voltage07');

ReportSoil1("[77]",'SavSoil77','MysensorsSensor_voltage08');

ReportSoil1("[78]",'SavSoil78','MysensorsSensor_voltage09');

ReportSoil1("[79]",'SavSoil79','MysensorsSensor_voltage10');

ReportSoil1("[80]",'SavSoil80','MysensorsSensor_voltage11');

ReportSoil1("[81]",'SavSoil81','MysensorsSensor_voltage12');

$body_all = 'Trebuetsya poliv: '.$wat.' '.$body1."\n\n\n";

$body_all = $body_all.'Batareya: '.$bat.' '.$body2."\n\n\n";

$body_all = $body_all.'Net svyazi: '.$err.' '.$body3."\n\n\n";

$body_all = $body_all."Polniy otchet:\n".$body ;

if( $wat > 0 )say('Trebuetsya poliv: '.$wat.' '.$body1);

if( $bat > 0 )say('Batareya: '.$bat.' '.$body2);

if( $err > 0 )say('Net svyazi: '.$err.' '.$body3);

$mail->Body = $body_all;

if (!$mail->send()) {

say( "Oshibka pochti: " . $mail->ErrorInfo);

} else {

say( "Otchet po vlazhnosti pochti otpravlen!");

}

/**

* Formirovanie otcheta po odnomu sensoru

*/

function ReportSoil1($num,$soil,$vcc ){

global $body, $body1, $body2, $body3, $wat, $bat, $err;

// Proverka neobhodimosti poliva

if( gg($soil.'.RatingHumSoil') == 'Nuzhen poliv' ){

if( $wat != 0 ) $body1 = $body1.', ';

$body1 = $body1.gg($soil.'.Name');

$wat++;

}

// Proverka zaryada batarei

if( gg($vcc.'.TextStatus') == 'Nizkiy zaryad batarei' ){

if( $bat != 0 ) $body2 = $body2.', ';

$body2 = $body2.gg($soil.'.Name');

$bat++;

}

// Proverka chto sensor zhivoy

if( time() - gg($vcc.'.updated') > 18000 ){

if( $err != 0 ) $body3 = $body3.', ';

$body3 = $body3.gg($soil.'.Name');

$err++;

}

// Zapolnenie osnovnogo otcheta

$body = $body."\n".$num.' '.gg($soil.'.Name').': ';

$body = $body.gg($soil.'.RelativeHumSoil');

$body = $body.'% ('.gg($soil.'.RatingHumSoil').' )';

$body = $body.', bat:'.gg($vcc.'.value');

$body = $body.' ('.gg($vcc.'.TextStatus').' )';

$body = $body.', '.gg($vcc.'.updatedText');

}

V rezultate raboti stsenariya mne kazhdoe utro prihodit primerno takoe pismo:

Trebuetsya poliv: 1 Molochay

Batareya: 0

Net svyazi: 2 Dratsena, Plyusch

Polniy otchet:

[70] Palma bolshaya: 52.2% (V norme ), bat:3.61 (Batareya v norme ), 5 min. nazad

[72] Dratsena: 53.6% (V norme ), bat:3.73 (Batareya v norme ), 06.11.2018 04:07

[73] Monstera: 57.3% (V norme ), bat:3.87 (Batareya v norme ), 1 min. nazad

[74] Hlorofitum (kuhnya): 42.6% (Skoro poliv ), bat:2.91 (Batareya v norme ), 1 min. nazad

[75] Molochay: 37.6% (Nuzhen poliv ), bat:2.92 (Batareya v norme ), 4 min. nazad

[76] Fikus Bendzhamina: 62.5% (V norme ), bat:2.98 (Batareya v norme ), 1 min. nazad

[77] Tolstyanka: 61.8% (V norme ), bat:3.04 (Batareya v norme ), 3 min. nazad

[78] Plyusch: 40.1% (Skoro poliv ), bat:2.93 (Batareya v norme ), 22.12.2018 21:47

[79] Dratsena krasn.: 47.1% (Skoro poliv ), bat:3.09 (Batareya v norme ), 31 sek. nazad

[80] Shefflera: 88.1% (Ochen vlazhno ), bat:2.90 (Batareya v norme ), 1 min. nazad

[81] Tsissus (vinograd): 118.8% (Ochen vlazhno ), bat:3.05 (Batareya v norme ), 1 min. nazad

Nebolshoy itog

V proshliy raz ya pisal monitoring vlazhnosti sensorov na PHP i poluchil gorazdo bolee skromnie rezultati, potrativ namnogo bolshe vremeni. Monitoring vlazhnosti v sisteme MajorDoMo mne nravitsya svoimi vozmozhnostyami i gibkostyu raboti.

Na moment napisaniya stati sistema rabotaet uzhe pol goda. V datchikah stoyat samie deshevie schelochnie batareyki iz magazina Galamart.

A ya gotovlyus k vesne zapustit etu sistemu v teplitse i otkritom grunte na svoem ogorode s GSM-shlyuzom Mysensors .

The post Podklyuchenie datchikov vlazhnosti pochvi k MajorDoMo appeared first on samopal.pro.