Skip to content

How to use VESNA CODE

oravec-juraj edited this page Apr 25, 2024 · 11 revisions

How to install and maintain the VESNA toolbox for MATLAB

Prerequisites

MATLAB R2023a or later.

Installation instructions

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.

Configuration

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 

Updating

To update the VESNA toolbox call:

tbxmanager update vesna

Uninstall

If you wish to uninstall VESNA toolbox call:

tbxmanager uninstall vesna

How to initialize a VESNA object

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 check the list of available VESNA variables

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

How to connect to the smart greenhouse VESNA device

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      

How to download the values of the required parameters from the cloud

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

How to upload the required values of some parameters to the cloud

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

How to terminate/reset all values of the actuators

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

How to get the date and time of the last update of the vesna object to/from the cloud

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

How to send an e-mail notification

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")

How to show the current version of the VESNA_CODE

MyVesnaVersion = MyVesna.version