Version 82 (modified by hek, 11 years ago) (diff)

--

Arduino Nano

Arduino Sensor Plugin

The Arduino sensor plugin allows you to build your own cheap wireless sensors [for less than $10]. The sensors is using Nordic Semiconductors transceiver nRF24L01 for wireless data transmissions. The Arduino Vera plugin automatically creates the sensor devices it finds on the radio network. Creating your own sensors should be pretty simple using the supplied Arduino library and example sensor sketches.

Arduino is an open source hardware prototype board that have lots of both digital and analog IO pins. There are an enormous amount of different cheap sensors that is compatible with the Arduino hardware.

Link Arduino page: http://arduino.cc
Relevant forum thread: http://forum.micasaverde.com/index.php/topic,16170.msg123378.html

Architecture

Author

Henrik Ekblad - henrik.ekblad at gmail.com (hek on forum)

Installing the Vera plugin

The latest version of the Vera plugin can be found here:

http://code.mios.com/trac/mios_arduino-sensor/browser/trunk/Vera

  1. Download all files and upload them in Vera under APPS->Develop Apps->Luup files.
  2. To create the new device to to APPS->Develop Apps->Luup and enter "D_Arduino1.xml" in "Upnp Device Filename" and press "Create Device"
  3. After the usual reload/refresh ritual the Arduino root device should pop up.
  4. If you have your Arduino board plugged into Vera you should now configure which serial device to use. See image to the right.

Using the Arduino library

All the components developed and compiled here are Open Source. The Vera plugin was inspired by the excellent rfxtrx plugin. I've also written a Arduino library handling all encoding and communication between Arduino sensors and ArduinoGateway. The Vera plugin part automatically creates newly found sensors in Vera.

It should be pretty simple to use the library (some more documentation in vera.h). But here follows the basic usage in your Arduino sketch:

#include <SPI.h>  
#include <RF24.h>
#include <Vera.h>  
#include <EEPROM.h>


// Set RADIO_ID to something unique in your sensor network (1-254)
// or set to AUTO if you want vera to assign a RADIO_ID for you.
#define RADIO_ID AUTO

// Create RF24 library instance using pin 9,10 which is what I've described how to hook up the radio module in this wiki.
RF24 radio(9,10); 

// Create a Vera library instance
Vera sensors(RADIO_ID, &radio); 

void setup()  
{
  // Initialize and start up vera library (this also initializes the radio stuff)
  vera.begin();

  // Register sensor(s) to Vera (they will be created as child devices when found). The arguments as follows.
  // childId      Each Arduino can have up to 128 child sensors. 0-127. 
  //              Here we register childId 0.
  // deviceType   Which (vera) device type to use for this sensor. See Vera.h for all options available. 
  //              In this example we use a motion sensor
  vera.sendSensorPresentation(0, S_MOTION); 
}

void loop()      
{     
   // Send a variable change to vera. In this case for childId 0 set the Tripped value to "1".  
   vera.sendVariable(0, V_TRIPPED, "1");
   delay(10000); // Delay 10 seconds
}

Arduino Sketches

A sketch is a small program that you download to the Arduino boards. To get started download Arduino SDK here: http://arduino.cc/en/Main/Software

Also make sure to install all Arduino libraries I've created and collected here before trying to build the sensor sketches below. http://code.mios.com/trac/mios_arduino-sensor/browser/trunk/Arduino/libraries

Follow the description below on how to assemble hardware and configure each type of sensor. I've also tried to link all the hardware necessary to build each sensor [from aliexpress.com].

Arduino Gateway

Acts as a link between Vera and your wireless sensors. This sketch should be downloaded to an Arduino Nano which then is connected to your Vera using a usb cable. It is important to use a Nano board for the ArduinoGateway as it contains a serial usb chipset recognized directly by Vera.

Dallas Temperature Sensor

This is an example sensor sketch that sends in Dallas temperature information and presents it as a temperature devices in Vera.

Distance Sensor

Bed occupancy sensor? Or use it in the garage to show when the car has reached the right location. Why not measure your own length every day using your Vera?

Humidity Sensor (DHT22)

Sketch that sends DHT11/22 data to Vera which displays them as a humidity and temperature device.

Light Sensor

Sensor sketch that reports light level and displays it in Vera using a light sensor device.

Motion Sensor

Motion sensor sketch that triggers a motion sensor security device in Vera.

Pressure/Temperature/Weather forecast sensor (BMP085)

Example sketch showing how to use a BMP085 pressure sensor to create a simple weather station with forecast calculation. Everything is sent and displayed as a barometer and temperature device in Vera.

Soil Moisture Sensor

Soil moisture sensor that triggers a security sensor device in Vera.

Relay Actuator

Relay sketch that can be controlled from Vera using a regular binary light switch device in Vera.

Power Consumption

My initial power measurements on a Arduino Mini Pro with radio module and motion detector shows a power consumption of 0.48 mAh in sleep mode. When motion is detected consumption raises to 1,5 mAh for a couple of seconds when radio powers up and transmits data to vera.

Converted to real life figures, this would make three 2000mAh alkaline AA batteries connected in series (giving 4.5V) last for almost 6 months (2000/0.48 hours) directly connected to VCV (not raw as it passes a regulator). Note that this is just a theoretical calculation. I have not made any long time measurements or tests myself yet. Read more about the subject on the following links:

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

When feeding the Arduino Pro Mini with 5V through VCC (unregulated). It is possible to reduce the consumption a few additional uA by cutting of the power regulator which also disables the power led. Note that you cannot feed the arduino through the raw pin after this operation. Note: This tip does not apply to newer pro minis (or funduino in my case) with a different layout.

Buying guide

There are many Arduino models out there. Here is a good overview of the different models: https://www.sparkfun.com/arduino_guide

A good start kit for building 9 sensors and 1 gateway for your Vera could consist of:

1x Arduino Nano (and USB-cable) for the gateway
http://www.aliexpress.com/item/Free-Ship-Wholesale-IC-Parts-Integrated-Circuits-Atmel-ATmega328-Board-with-Mini-USB-Cable-Full-Compatible/704043993.html

10x Arduino Pro Mini for the sensors (2 lots = 10 pcs)
http://www.aliexpress.com/item/16Pcs-Lot-Pro-Mini-Module-Atmega328-5V-16M-For-Arduino-Compatible-Nano/710613095.html

10x NRF24L01+ wireless data transmission module 2.4Ghz
http://www.aliexpress.com/item/Free-shipping-NRF24L01-wireless-data-transmission-module-2-4G-the-NRF24L01-5PCS-LOT-upgrade-version-New/603756080.html

80x Dupont cable Female->Female
http://www.aliexpress.com/item/40pcs-in-Row-Dupont-Cable-20cm-2-54mm-1pin-1p-1p-Female-to-Female-jumper-wire/1265984941.html

80x Dupont cable Female->Male
http://www.aliexpress.com/item/Free-Shipping-80pcs-1P-40x2-New-20cm-2-54mm-1pin-1p-1p-female-to-male-jumper/905874108.html

1x Serial to USB adapter to download code to Arduino pro mini
http://www.aliexpress.com/item/Free-Shipping-FT232RL-USB-To-Serial-Adapter-Module-USB-TO-232-For-Arduino-Download-Cable/827218126.html

Some pull up resistors 4k7 (used for dallas and humidity sensors)
http://www.aliexpress.com/item/300pcs-Resistors-4-7K-4K7-Ohm-1-4W-5-Carbon-Film-Free-Shipping/579559008.html

Power regulators for connecting radio module to Arduino Pro Min (which lacks 3.3v output)
http://www.aliexpress.com/item/XC6206P332MR-XC6206P252MR-SOT-23-SMD-triode-transistor-Good-quality-ROHS-leave-message-model-you-need/473456552.html

Changelog

CHANGES 1.2

  • Added possibility to request time from vera
  • Support for 5 custom variables (can be stored in any sensor device). Note that chixxis variable container is still not supported. But the functionality is similar.
  • Sensors reports their library version to Vera.
  • New example sketch showing time and variable functionality
  • SendCommand action added in vera plugin which makes it possible to send data to sensors from scenes (advanced-section) or via luup-calls.
  • Auto-id added. A sensor can now request id from vera at first start. The id gets stored in the sensors EEPROM. All example sketches now uses auto-id functionality. You can still use static ids if that is preferred.
  • Automatically sets LAST_TRIP and BATTERY_DATE
  • Fixed "No Implementation" message when pressing Armed/Bypassed on security sensors.
  • Cleaned up plugin code

CHANGES 1.0

  • Initial release

Attachments