Version 3 (modified by axill, 11 years ago) (diff)

case 2 added

Case # 1

Pull data from vera

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

Solution:

  • choose from V_VAR1, V_VAR2, V_VAR3, V_VAR4, V_VAR5 to use for your fine tune parameters;
  • 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;
  • 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();
  • 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;
  • 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.;
  • fill free to change empty field on vera side to the value your needed, Save changes;
  • check with you Arduino, it should receive correct data at this point;

Comments

You 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. Other 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...


Case # 2

Push data from vera

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.

Solution:

  • choose from V_VAR1, V_VAR2, V_VAR3, V_VAR4, V_VAR5 to be used for data push;
  • design your sketch to listen for incoming messages with desired variable;
  • create a new scene on vera side. The scene should be run according to your goal. For example each 10 minutes;
  • 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:
local temp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 61)
temp = temp*10.0
luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand", {radioId="4;255", variableId="VAR_5", value=temp}, 372)

Comments

A good combination between Pull and Push can work for the best.


... more cases to came soon

Attachments