21/7/22

Como conectar Scilab con una nube - Thingspeak, thingboard, favoriot

 Instalar

atomsSystemUpdate();

atomsInstall("bytecode_iot_module");

//Poner Api

api = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Ikl2YW5EaWF6IiwicmVhZF93cml0ZSI6dHJ1ZSwiaWF0IjoxNjU3NjA0NjY0fQ.NJHuw74yakvCpRVnY6Ju85dH51UU8Q--xB_aC5VAlnU'

obj=favor_createData('PC1@ohin1uh', 'Sensor 2', ' Sensor2');

obj.data

obj.data.Sensor1= "1"

obj.data.Sensor2= "1"

result = favor_sendData(api,obj);

obje=favor_createData('IvanDiaz', 'Sensor 2', ' Sensor2');

obje.data

obje.data.Sensor1= "1"

obje.data.Sensor2= "1"

result = favor_sendData(api,obje)

//////////////////////////////////////

device_id = "THE_DEVICE_ID"

device_acc = "THE_DEVICE_ACCESS"

userpw = "username@email.com:yourpassword"

thingsboard1 = iot_init("thingsboard", "deviceid",device_id, "post_acc",device_acc, "auth",userpw)

NEGADO, SCILAB DEJA DE FUNCIONAR CUANDO LE QUIERO CONECTAR A LA NUBE

device_id = "6b9e1230-01a0-11ed-9726-b70ec1232897"

device_acc = "1e5SyLLt4aExiZwiJ2U3"

userpw = "kdiaz6902@uta.edu.ec:kidscomics"

thingsboard1 = iot_init("thingsboard", "deviceid",device_id, "post_acc",device_acc, "auth",userpw)

///////////////////////////////////////

https://thingspeak.com/channels/1768821/api_keys

channel_info= thingspeak_channelinfo(channelID,privacy,apiWriteKey,apiReadKey)

channel_info= thingspeak_channelinfo(1768821,Private,XTOK8904FTI6TKT5,9P7BW6BPPUGP5FWT)

privacy = 'Private'

apiWriteKey = 'XTOK8904FTI6TKT5'

apiReadKey = '9P7BW6BPPUGP5FWT'


///////////////////////////////////////

channelID = 1768821

userapi = '64N9AFZHHP6I782A'

channel_info= thingspeak_channelinfo(channelID,userapi)

channel_info= thingspeak_channelinfo(channelID,apiWriteKey,apiReadKey)

entryID=thingspeak_update(apiWriteKey,datastruct)

entry_update = thingspeak_update("writekey",new_entry)

Thingspeak

Obtener informacion del canal

--> channelID = 1768821
 channelID  = 

   1768821.

--> userapi = '64N9AFZHHP6I782A'
 userapi  = 

  "64N9AFZHHP6I782A"

--> channel_info= thingspeak_channelinfo(channelID,userapi)
 channel_info  = 

  id = 1768821
  name = "Temperatura LM35 By Ivan Diaz"
  description = ""
  latitude = "0.0"
  longitude = "0.0"
  created_at = "2022-06-14T23:56:30Z"
  elevation = ""
  last_entry_id = 16
  public_flag = %f
  url = ""
  ranking = 30
  metadata = ""
  license_id = 0
  github_url = "null"
  tags = []
  api_keys: [1x2 struct] with fields:
      ["api_key", "write_flag"]

a




--> apiWriteKey = 'XTOK8904FTI6TKT5'
 apiWriteKey  = 

  "XTOK8904FTI6TKT5"

-

--> new_entry = thingspeak_newentry("status","New update!","field1",25)
 new_entry  = 

  field1 = 25
  field2 = []
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = "New update!"


--> new_entry = thingspeak_newentry("status","New update!","field1",25)
 new_entry  = 

  field1 = 25
  field2 = []
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = "New update!"


--> disp(new_entry)

  field1 = 25
  field2 = []
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = "New update!"


--> writeapi='DKQQEEGHSOW901EU'
 writeapi  = 

  "DKQQEEGHSOW901EU"


--> writekey='DKQQEEGHSOW901EU'
 writekey  = 

  "DKQQEEGHSOW901EU"




--> new_entry = thingspeak_newentry("status","New update!","field1",20)
 new_entry  = 

  field1 = 20
  field2 = []
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = "New update!"



--> new_entry = thingspeak_newentry("field1",20)
 new_entry  = 

  field1 = 20
  field2 = []
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = []




--> channel_info= thingspeak_channelinfo(channelID,userapi)
 channel_info  = 

  id = 1768821
  name = "Temperatura LM35 By Ivan Diaz"
  description = ""
  latitude = "0.0"
  longitude = "0.0"
  created_at = "2022-06-14T23:56:30Z"
  elevation = ""
  last_entry_id = 16
  public_flag = %f
  url = ""
  ranking = 30
  metadata = ""
  license_id = 0
  github_url = "null"
  tags = []
  api_keys: [1x2 struct] with fields:
      ["api_key", "write_flag"]

Conectar con la nube


--> thingspeak='thingspeak'
 thingspeak  = 

  "thingspeak"

-->  obj = iot_init('thingspeak');
 obj  = 

  cloud = "thingspeak"
  url_base = "https://api.thingspeak.com"
  url_post = "https://api.thingspeak.com/update.json?api_key=DKQQEEGHSOW901EU"
  url_get: [1x1 string]
  deviceid = "1797022"
  post_acc = "DKQQEEGHSOW901EU"
  read_acc = "563YS5OWC0O2LOEK"
  auth = ""
  token = ""
  variableid = ""
  cacert = ""


--> cloud = "thingspeak"
 cloud  = 

  "thingspeak"


--> entryID=thingspeak_update(apiWriteKey,new_entry)
 entryID  = 

   17.

--> new_entry = thingspeak_newentry("status","New update!","field1",59)
 new_entry  = 

  field1 = 59
  field2 = []
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = "New update!"




--> new_entry = thingspeak_newentry("field1",57)
 new_entry  = 

  field1 = 57
  field2 = []
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = []


--> entryID=thingspeak_update(apiWriteKey,new_entry)
 entryID  = 

   18.

--> new_entry = thingspeak_newentry("field1",18)
 new_entry  = 

  field1 = 18
  field2 = []
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = []


--> entryID=thingspeak_update(apiWriteKey,new_entry)
 entryID  = 

   19.

--> entryID=thingspeak_update(apiWriteKey,new_entry)
 entryID  = 

   20.

--> new_entry = thingspeak_newentry("field1",18,"field1",'hola')
 new_entry  = 

  field1 = "hola"
  field2 = []
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = []


--> new_entry = thingspeak_newentry("field1",18,"field2",'hola')
 new_entry  = 

  field1 = 18
  field2 = "hola"
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = []


-->  entryID=thingspeak_update(apiWriteKey,new_entry)
 entryID  = 

   21.

--> new_entry = thingspeak_newentry("field1",-13,"field2",'hola')
 new_entry  = 

  field1 = -13
  field2 = "hola"
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = []


--> entryID=thingspeak_update(apiWriteKey,new_entry)
 entryID  = 

   22.

--> new_entry = thingspeak_newentry("status","ola que hace","field1",25)
 new_entry  = 

  field1 = 25
  field2 = []
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = "ola que hace"


--> new_entry = thingspeak_newentry("status","New update!","field1",25)
 new_entry  = 

  field1 = 25
  field2 = []
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = "New update!"




--> new_entry = thingspeak_newentry("status","New update!","field1",25)
 new_entry  = 

  field1 = 25
  field2 = []
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = "New update!"



--> new_entry = thingspeak_newentry("latitude","25!","field2",25)
 new_entry  = 

  field1 = []
  field2 = 25
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = "25!"
  longitude = []
  elevation = []
  status = []



--> new_entry = thingspeak_newentry("latitude","25","field2",25)
 new_entry  = 

  field1 = []
  field2 = 25
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = "25"
  longitude = []
  elevation = []
  status = []


--> new_entry = thingspeak_newentry("latitude",25,"field2",25)
 new_entry  = 

  field1 = []
  field2 = 25
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = 25
  longitude = []
  elevation = []
  status = []


--> new_entry = thingspeak_newentry("field2",25)
 new_entry  = 

  field1 = []
  field2 = 25
  field3 = []
  field4 = []
  field5 = []
  field6 = []
  field7 = []
  field8 = []
  latitude = []
  longitude = []
  elevation = []
  status = []


--> entryID=thingspeak_update(apiWriteKey,new_entry)
 entryID  = 

   23.

Enviar informacion

//Write your callback for  Suma  here
 a=get(handles.pantalla,'string');
 a=a+"+";
 set(handles.pantalla,'string',a);
endfunction

function resta_callback(handles)
//Write your callback for  resta  here
 a=get(handles.pantalla,'string');
 a=a+"-";
 set(handles.pantalla,'string',a);
endfunction

function Multiplicacion_callback(handles)
//Write your callback for  Multiplicacion  here
 a=get(handles.pantalla,'string');
 a=a+"*";
 set(handles.pantalla,'string',a);
endfunction

function division_callback(handles)
//Write your callback for  division  here
 a=get(handles.pantalla,'string');
 a=a+"/";
 set(handles.pantalla,'string',a);
endfunction

function igual_callback(handles)
//Write your callback for  igual  here

 a=get(handles.pantalla,'string');
 disp(a)
 a2=evstr(a);
 a3=string(a2);
 disp(a3)
 set(handles.pantalla,'string',a3);
 calcula=a3;
 
 
 v=get(handles.clientes,'string');
 v=v+"+1";
 set(handles.clientes,'string',v);
v2=evstr(v);
v3=string(v2);
set(handles.clientes,'string',v3)

 new_entry = thingspeak_newentry("field1",a3,"field2",T.values(127),"field3",D.values(127),"field4",v3)
entryID=thingspeak_update("PNQ1CQUM0VUWBI8J",new_entry)

Thingboard

--> obj = iot_init('thingsboard')
--> key='1e5SyLLt4aExiZwiJ2U3'
 key  = 

  "1e5SyLLt4aExiZwiJ2U3"

--> value=10
 value  = 

   10.
--> out = iot_send(obj,key,value)

Favoriot

--> obj=favor_createData('PC1@ohin1uh', 'Sensor 2', ' Sensor2');

--> obj.data
 ans  =

  Sensor 2 = "0"
   Sensor2 = "0"


--> 

--> obj.data.Sensor1= "1"
 obj  = 

  device_developer_id = "PC1@ohin1uh"
  data: struct with fields:
      Sensor 2 = "0"
       Sensor2 = "0"
      Sensor1 = "1"


--> obj.data.Sensor2= "1"
 obj  = 

  device_developer_id = "PC1@ohin1uh"
  data: struct with fields:
      Sensor 2 = "0"
       Sensor2 = "0"
      Sensor1 = "1"
      Sensor2 = "1"


--> out = iot_sen(obj,key,value)

Undefined variable: key

--> key='XTOK8904FTI6TKT5'
 key  = 

  "XTOK8904FTI6TKT5"

--> out = iot_sen(obj,key,value)

Undefined variable: value

--> value ='15'
 value  = 

  "15"

--> out = iot_sen(obj,key,value)

Undefined variable: iot_sen

--> out = iot_send(obj,key,value)
at line    25 of function iot_send 

Unknown field : cloud.



No hay comentarios.:

Publicar un comentario