Last modified 6 years ago Last modified on 2014-01-24 06:51:30

Case # 1

Pull data by node 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 to node

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.


Case # 3

Powering things from battery

Task: Tips to achieve long battery life. This consolidates information from a great post from @a-lurker and others around the web trying to the longest battery life possible. http://forum.micasaverde.com/index.php/topic,20078.0.html

Solution:

  1. Disable or remove the on-board regulator. This draws excessive current;
  2. Remove the power LED. On some boards this is done by disabling the Regulator;
  3. Power directly off the battery or use a Switching Regulator such as:

https://www.sparkfun.com/products/10967

http://www.pololu.com/product/798

  1. SLEEP whenever possible.
  • Wake up using the WDT
sleep.sleepDelay(SLEEP_TIME * 1000); //sleep for: sleepTime
  • Or use an interrupt if using a button or sensor.

See http://code.mios.com/trac/mios_arduino-sensor/browser/VeraArduino/Arduino/libraries/Vera/examples/RelayWithButtonActuator/RelayWithButtonActuator.ino

  1. Disable the BOD (Brow out detection). Sleep library does this or can be done in software:

<Enter Sleep Mode>

// turn off brown-out enable in software
MCUCR = bit (BODS) | bit (BODSE);
MCUCR = bit (BODS);

<Sleep the CPU within 3 clock cycles of above code>

  1. Turn of A/D Convertors : (Again Hek already does this in Sleep Library)
// disable ADC
ADCSRA = 0;
  1. Set unused input or output pins to LOW;
  2. Lower your clock frequency. This has to be done by burning your fuses. Be careful and check the clock frequency of the radio you're using;
  3. To send the Battery level to the Gateway:

To measure the battery internally (when connected directly to a battery):

// Read the Battery
long readVcc() {
    long result;
    // Read 1.1V reference against AVcc
    ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
    delay(2); // Wait for Vref to settle
    ADCSRA |= _BV(ADSC); // Convert
    while (bit_is_set(ADCSRA,ADSC));
    result = ADCL;
    result |= ADCH<<8;
    result = 1126400L / result; // Back-calculate AVcc in mV
    return result;
}
// Send the Battery Percentage to the Gateway
#define VBatMax 3.1             // The voltage of New Batteries
#define VBatDropout  1.8    // The battery dropout voltage
gw.sendBatteryLevel((readVcc()-(Dropout*1000)) /(((VBatMax-Dropout) *10)));

To measure the battery voltage when using a Switching Regulator: See a-lurker's post: http://forum.micasaverde.com/index.php/topic,20078.0.html

Comments:

For reference here are some good sights:

http://maniacbug.wordpress.com/2011/10/19/sensor-node/

http://www.gammon.com.au/forum/?id=11497

http://hwstartup.wordpress.com/2013/03/11/how-to-run-an-arduino-on-a-9v-battery-for-weeks-or-months/

http://hwstartup.wordpress.com/2013/04/15/how-to-run-an-arduino-clone-on-aa-batteries-for-over-a-year-part-2/

http://www.thalin.se/2013/04/arduino-pro-mini-low-power-modification.html

http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/


... more cases to came soon

Attachments