To measure to soil moisture, the Sensor delivers an electrical voltage representing the moisture. This value is calibrated for water and air and a value for the dryness is calculated.
Dryness d | Description |
---|---|
0 <= d <= 9 | saturated |
9 < d <= 19 | adequately wet |
19 < d <= 59 | irrigation advice |
59 < d <= 99 | irrigation |
99 < d <= 100 | dangerously dry |
The mailbox is based on this Adafruit project.
A 5V pump is used for irrigation.
The three devices are connected and controlled by a business workflow.
var httpConnector = org.camunda.connect.Connectors.http();
var system = java.lang.System;
var resp = httpConnector.createRequest()
.get()
.url("http://192.168.0.40/soilmoisture")
.execute();
var result = JSON.parse(resp.getResponse());
resp.close();
system.err.print("dryness: ");
system.err.println(parseInt(result.value, 10));
system.err.print("description: ");
system.err.println(result.description);
execution.setVariable('dryness', parseInt(result.value, 10));
execution.setVariable('description', result.description);
var payload = { status : true };
var httpConnector = org.camunda.connect.Connectors.http();
var resp = httpConnector.createRequest()
.put()
.url("http://192.168.0.95/flag")
.contentType("application/json")
.payload(JSON.stringify(payload ))
.execute();
var result = resp.getResponse();
resp.close();
var payload = { status : false };
var httpConnector = org.camunda.connect.Connectors.http();
var resp = httpConnector.createRequest()
.put()
.url("http://192.168.0.95/flag")
.contentType("application/json")
.payload(JSON.stringify(payload ))
.execute();
var result = resp.getResponse();
resp.close();
var payload = { duration : 1500 };
var httpConnector = org.camunda.connect.Connectors.http();
var resp = httpConnector.createRequest()
.put()
.url("http://192.168.0.40/pump")
.contentType("application/json")
.payload(JSON.stringify(payload ))
.execute();
var result = resp.getResponse();
resp.close();