How to use VESNA CODE
MATLAB R2023a or later.
We strongly recommend installing VESNA using a tbxManager by typing:
tbxmanager install vesna
Otherwise, manually download the latest release of the VESNA toolbox, unpack the package in the target directory, and set and save the corresponding path in MATLAB.
To enable connection with the remote cloud service, and to enable all the capabilities of VESNA toolbox, you need to setup the JSON-files:
vesna_credentials.json
vesna_data_ids.json
vesna_email.json
To update the VESNA toolbox call:
tbxmanager update vesna
If you wish to uninstall VESNA toolbox call:
tbxmanager uninstall vesna
Initialization of a VESNA object using the class constructor by calling:
MyVesna = vesna
returns the of the vesna
method display
MyVesna =
Smart greenhouse VESNA (last update: Never)
URL []
ID []
Status []
Flag []
Connection established []
How to show the list of available VESNA variables filtered into the 2 groups:
-
actuators
- read/write (editable) VESNA variables -
measurements
- read-only (non-editable) VESNA variables
MyVesna.variables
How to get the list of available VESNA variables as a variable/cell-array:
list_of_variables = MyVesna.variables
Connection to smart greenhouse VESNA device using the method connect
by calling:
URL = LINK_TO_ARDUINO_IOT_CLOUD
login = PUBLIC_HASH_OF_USER_LOGIN
password = SECRET_HASH_OF_USER_PASSWORD
MyVesna.connect(URL,login,password)
returns the information:
Connected
ans =
Smart greenhouse VESNA (last update: Never)
URL https://api2.arduino.cc/iot/v1/clients/token
ID Ij7686MXMIXCS4JyGJTe5nyQNQM6w7R9
Status connected
Flag 1
Connection established 2023-10-25T18:07:49
To download the value of the required parameter from the cloud use the method download
by calling:
% How to download the current (last-known) value of the temperature
data = MyVesna.download("temperature");
T = data.temperature
% How to download the current (last-known) value of the temperature and humidity
data = MyVesna.download("CO2", "humidity");
gCO2 = data.CO2.value
h = data.humidity.value
% How to download the current (last-known) value of all available variables
data = MyVesna.download();
data
% How to download the sequence of the measured values of the temperature in the current day (up to 1000 samples)
sampleRate = 1; % each sample
data = MyVesna.download(["temperature"]);
T = data.temperature.value
% How to download the sequence of the measured values of the temperature in the current day (up to 1000 samples)
sampleRate = 1; % each sample
data = MyVesna.download(["temperature",sampleRate,"2023-11-07 10:00:00", "2023-11-07 11:00:00"]);
T_values = data.temperature.value
T_time = data.temperature.time
data = MyVesna.download(["light_intensity",sampleRate,"2023-11-07 09:00:00", "2023-11-07 11:00:00"]);
L_value = data.light_intensity.value
L_time = data.light_intensity.time
returns the information:
T =
28.7037
gCO2 =
774.5313
h =
37.8830
data =
struct with fields:
temperature: 28.7037
humidity: 37.8830
light: 895
gasses: 774.5313
heater: 0
humidiser: 100
lighting: 100
vents: 100
T =
Columns 1 through 3
24.8371 24.8371 24.8371
...
Columns 423 through 426
27.7798 27.7651 27.7544
T =
27.6111 27.7638 27.7558 27.7424
To upload the required values for some parameters to the cloud use the method upload
by calling:
% How to upload the required values for the fans
MyVesna.upload("fans",74);
% How to upload the required values for the fans and lighting
MyVesna.upload("fans",74,"lighting",32);
% Check all variables by loading their current values
data = MyVesna.download();
data
returns the information:
data =
struct with fields:
temperature: 28.7037
humidity: 37.8830
light: 895
gasses: 774.5313
heater: 0
humidiser: 100
lighting: 32
vents: 74
To terminate/reset (clear) all values of the actuators on the cloud (set them to their default (reset) values) use the method terminator
by calling:
% How to use the terminator and show the output message on the screen:
MyVesna.terminator
% How to use the terminator and return an output flag variable/double:
VesnaFlag = MyVesna.terminator
Get the date and time of the last update of the vesna
object to/from the cloud by calling:
MyVesna.communication.lastUpdate
returns the information:
ans =
datetime
2023-10-25T18:10:22
To send an e-mail notification:
%% How to send an e-mail notification
MyEmailSubject = "Notification from Smart Greenhouse VESNA";
MyEmailBody = ['Temperature is ',num2str(MyVesna.data.temperature),' degrees.'];
MyEmailBody = convertCharsToStrings(MyEmailBody);
MyVesna.email(MyEmailSubject,MyEmailBody,"juraj.oravec@stuba.sk")
MyVesnaVersion = MyVesna.version