Changes between Version 2 and Version 3 of TipsAndTricks


Ignore:
Timestamp:
2014-01-22 22:24:42 (11 years ago)
Author:
axill
Comment:

case 2 added

Legend:

Unmodified
Added
Removed
Modified
  • TipsAndTricks

    v2 v3  
    11 
    22== Case # 1== 
     3 
     4'''Pull data from vera''' 
    35 
    46'''Task:''' ''you need an ability to tune a few parameters of you arduino/avr radio node without downloading a new sketch to it. For example you need to fine tune your motion sensor'' 
     
    911- choose from your root or child nodes. You can use all five parameters per each of your root and child device. It is up to you how to design this; 
    1012- program your sketch to fetch variable from vera using one of requestStatus() or getStatus(). The method getStatus() will wait for vera reply and will return text representing needed variable. The method requestStatus() will be a none blocking call but you will have to take care to get reply later by yourself using messageAvailable() and getMessage(); 
    11 - do i thirst run of your modified sketch to request parameters. Be prepared that you will receive an empty string because at this time we have just created empty variables at vera side. 
    12 - refresh your vera and go to particular child into Advanced Tab. You should be able to see your new variables named Variable1...Variable5. Variable1 corresponds to V_VAR1 inside your sketch etc. 
    13 - fill free to change empty field on vera side to the value your needed, Save changes. 
    14 - check with you Arduino, it should receive correct data at this point 
     13- do i thirst run of your modified sketch to request parameters. Be prepared that you will receive an empty string because at this time we have just created empty variables at vera side; 
     14- refresh your vera and go to particular child into Advanced Tab. You should be able to see your new variables named Variable1...Variable5. Variable1 corresponds to V_VAR1 inside your sketch etc.; 
     15- fill free to change empty field on vera side to the value your needed, Save changes; 
     16- check with you Arduino, it should receive correct data at this point; 
     17 
     18'''Comments''' 
     19 
     20You free to use whatever design you want. You can pull data at each start of you node or you can pull each 30 minutes like many z-wave devices do if they operate from battery.  
     21Other example can be if you need for your to nodes to communicate to each other and you need to tell a radio ID to one/both nodes to establish their communication. But for this one you probably want to use Push... 
     22 
     23---- 
     24 
     25== Case # 2== 
     26 
     27'''Push data from vera''' 
     28 
     29'''Task:''' ''You need to push data from vera on event or using schedule and it should be initiated instantly by vera, not by node. For example you want your clock to show external temperature received by vera from the Weather plugin or from other sensor. '' 
     30 
     31'''Solution:''' 
     32[[Image(forcase1.jpg, align=right, 300px)]] 
     33- choose from V_VAR1, V_VAR2, V_VAR3, V_VAR4, V_VAR5 to be used for data push; 
     34- design your sketch to listen for incoming messages with desired variable; 
     35- create a new scene on vera side. The scene should be run according to your goal. For example each 10 minutes; 
     36- use Lua tab while editing scene to provide data for the push. For example this Lua is taking current temperature from Weather (vera id = 61) plugin and pushing it to the node (vera id for root device = 372) using VAR_5: 
     37 
     38{{{ 
     39local temp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 61) 
     40temp = temp*10.0 
     41luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="4;255", variableId="VAR_5", value=temp}, 372) 
     42}}} 
     43 
     44'''Comments''' 
     45 
     46A good combination between Pull and Push can work for the best. 
    1547 
    1648----