We have moved at community.getvera.com

Author Topic: Arduino Sensor Plugin - Build your own wireless sensors!  (Read 264055 times)

Offline mitekdg

  • Sr. Newbie
  • *
  • Posts: 42
  • Karma: +0/-1
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #90 on: September 29, 2013, 08:58:37 am »
yes. no device showed up.
Now i'll try a new version.
thx

Offline mitekdg

  • Sr. Newbie
  • *
  • Posts: 42
  • Karma: +0/-1
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #91 on: September 29, 2013, 09:09:55 am »
work perfect! thx

Offline mitekdg

  • Sr. Newbie
  • *
  • Posts: 42
  • Karma: +0/-1
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #92 on: September 30, 2013, 12:54:05 am »
New release... see wiki for details..

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.
* Fixed "No Implementation" message when pressing Armed/Bypassed on security
  sensors.
* Automatically sets LAST_TRIP and BATTERY_DATE
* Cleaned up plugin code

hek, could u give some example to work w/variables. And another question is how can i send a battery lev from sensor.
thx

Offline hek

  • Moderator
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #93 on: September 30, 2013, 01:22:07 am »
Quote
* New example sketch showing time and variable functionality

You'll find the example for variables and time here:
http://code.mios.com/trac/mios_arduino-sensor/browser/trunk/Arduino/TimeAndVariableSensor

Sending batterydata should be done by (note that I have not tried this myself yet):

vera.sendVariable(CHILD_ID, V_BATTERY_LEVEL, 50);  // 50%



Offline hek

  • Moderator
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #94 on: September 30, 2013, 03:24:59 am »
Hi Hek,

Thank you so much for sharing this plugin!
I have a Vera since last Saturday, and I have immediately looked for a way to interface the Vera with my IR remote control (logitech harmony) to control the lights, and was disappointed not to find no solution at less than 100?.
I know pretty well Arduino, and the great IRremote library from Ken Shirriff's (http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html), so finding your plugin was a bless to put me at start on a cheap IR interface solution (approx 10?) :D
Thanks to your example, I had the plugin working on Sunday: for now it simply executes scenes with predefined names when I press buttons on the remote.
I am now trying to have the plugin generate events instead of directly running scenes, so that I do not have to use any particular names for the scenes... I am struggling with this for now: the documentation for luup is one of the worst I have ever seen :(

Anyway, thank you so much for this plugin! It is a great idea. I am sure I will be using your plugin in full very soon!

(for the IR plugin, once finished, I will post my plugin in a different thread. I do not want to pollute your thread, but just to say thank you :) )

Cheers,

Patrick

Nice idea!

Just bought this:
http://www.aliexpress.com/item/2PCS-Digital-38KHz-Infrared-IR-Sensor-Transmitter-Kit-for-Arduino-M3AO/1178542936.html

I'll incorporate this into the plugin so we can send/reveive AV equipment IR signals when the stuff arrives.
« Last Edit: September 30, 2013, 07:38:08 am by hek »

Offline hek

  • Moderator
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #95 on: September 30, 2013, 03:33:34 am »
The wiki has been updated with a purchase guide for getting started.
http://code.mios.com/trac/mios_arduino-sensor/wiki#Buyingguide

Offline mitekdg

  • Sr. Newbie
  • *
  • Posts: 42
  • Karma: +0/-1
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #96 on: September 30, 2013, 06:30:05 am »
and another feature request ))
1. Security token (aka pairing vera-gateway vs. "sensor")
2. Mesh network of nrf24 dvcs or relays for distance improving.

IR extender will be great solution!

Hek, u r genius! THX!

Offline hek

  • Moderator
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #97 on: September 30, 2013, 07:51:57 am »

1.
What do you mean by security token? Some sort of AES key exchange and encrypted traffic would be the best but it would require quite complex handshaking and probably larger messages.  But it would be nice, I agree... someone up for the challenge or having clever ideas, please let me know.

2.
I see a couple of problems using nrf24 network. Relay nodes must always be "on", ready to relay message. Which means no battery devices.
The node addresses (16bit) is also used to set topology would require me to redo the whole auto-id and message structure. It would be a quite a bit more complex for novice users to setup their sensor network. I really like the idea of a z-wave network better where nodes auto-configure their topology and routes. Don'r really know if I have the time to implement that type of behavior though.

Offline mitekdg

  • Sr. Newbie
  • *
  • Posts: 42
  • Karma: +0/-1
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #98 on: September 30, 2013, 08:25:34 am »
1. 2 purposes: pairing devices, so 1 device can interact with 1 gate, and the second one - secure (encrypting) messaging
2. Yes, the relay nodes must be always on-line, but it will allow to increase the range of network. Have u seen the maniacbug RF24Network meshnetwork  example, its very easy to configure. Auto-config is excellent solution, but very complex, i think manual config will be enough

p.s.: sorry for my english

Offline axill

  • Full Member
  • ***
  • Posts: 183
  • Karma: +3/-0
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #99 on: September 30, 2013, 02:01:29 pm »
i have some thoughts about mesh and encryption

- encryptions a nice thing to have but it costs hardware and it will slow down implementation.
I thing we should thing about two different things:
1) authentication
2) encryption itself

the first one can make our network more consistent because we can be sure that we react to the message of "a right" format from "a right" pair.
it can be archived by a few different ways:

1.1) simple check for the message body using our unique function. For example we can put one byte CRC to check that the rest of the message is matching CRC. If there is no match device should ignore the message assuming that message is of wrong format, wrong version, wrong pair etc.
1.2) through key-exchange algorithm - before two devices will communicate (or any new device will communicate with a gateway) a right format keys should be exchanged:
   1.2.1 using any simple arithmetic function - will require about zero of additional programming and memory code but will be also zero resistant to intruders
   1.2.2 using good encryption algorithm like DSA/RSA etc. It will be much more protected from the intruders but will require 1-4kb of programming code
after key exchange we should send a right key with each message. Probably key should have an expiration leading to the next key exchange session.

encryption can not only make a network more consistent but also will protect it from stealing and from hacking
2.1 software encryption using for example https://github.com/DavyLandman/AESLib
2.2 hardware encryption. Most atxmegas have hardware encryption but this will require to build a custom hardware

because 1.2.2 requires the same additional program code as 2.1 it probably a reason to use just  encryption without authentication (encryption will act also as authentication using private/public keys)

but the cost... I personally will prefer to build network faster less secured instead of slower and secured. I do not plan to put locks using arduino and i have nothing against someone listen to my sensors. But at least 1.1 or 1.2.1 is nice to have - this will reduce dramatically a probability of unexpected behavior.

---------
network
- i think RF24Network is not a good solution

i'm thinking of:
- keeping simplest design of end-user devices
- add relays. You will just need a few of them across the house
- relays can relay message both ways
- they should have powered from the outlets, not batteries.
- relay can be at the same time an end-user device but not necessary
- relay should acts as a gateway to end-user device if end-user device was configured to talk with relay instead of GW
- relay can talk to GW using another relay (not needed at first step but will allow to brake a restriction on a distance from a device to GW)
- ID generation by vera&GW should also include relay assignment. Etc. wile adding a new device we should take vera & GW close to a new device and initiate ID & relay assignment. It can be like this:
   - vera sendsa new ID to device
   - device announce itself to the network
   - first replying relay should be recorded by a device as relay
   - relay should record a device as neighbor
   - relay should announce a new device as it's neigbor to it's relay (including GW itself)

this way:
- relay will knew it's neighbor
- device will knew it's relay
- GW will knew all devices and their relays

the path can be constructed on the fly relaying one through one
« Last Edit: September 30, 2013, 02:07:00 pm by axill »

Offline hek

  • Moderator
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #100 on: September 30, 2013, 05:16:45 pm »
Interesting to read about how Zigbee has solved this.

http://www.digi.com/support/kbase/kbaseresultdetl?id=2214

Offline axill

  • Full Member
  • ***
  • Posts: 183
  • Karma: +3/-0
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #101 on: September 30, 2013, 05:49:28 pm »
hek what i'm doing wrongly?
I just tried to start dallas sensor with latest code (target as 1.2)

I was installed plugin early as version 1.1
Now I did an upgrade by uploading new files to Vera with Lia engine restart

Arduino plugin show version 1.2 now but GW version is empty
I can see error in the Lua log file:

01   10/01/13 1:48:40.937   luup_log:71: Arduino plugin: 255;0;2;34; <0x317b8680>
01   10/01/13 1:48:40.938   LuaInterface::CallFunction-2 lu_incoming failed [string "module("L_Arduino", package.seeall)..."]:141: attempt to call global 'nextAvailiableRadioId' (a nil value) <0x317b8680>

what is wrong?

Offline axill

  • Full Member
  • ***
  • Posts: 183
  • Karma: +3/-0
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #102 on: September 30, 2013, 06:05:47 pm »
I found that if a set an explicit RADIO_ID - it is workin
but AUTO is not

Offline axill

  • Full Member
  • ***
  • Posts: 183
  • Karma: +3/-0
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #103 on: September 30, 2013, 11:58:37 pm »
a small question
in DallasTemperature example is set that pin 2 is using by ds18b20 but at the same time according to connection guide http://code.mios.com/trac/mios_arduino-sensor/wiki/ConnectingRadioModule pin 2 also should be connected to IRQ pin. Do you use IRQ for devices or it is used only for GW?

Offline hek

  • Moderator
  • Hero Member
  • *****
  • Posts: 714
  • Karma: +60/-1
Re: Arduino Sensor Plugin - Build your own wireless sensors!
« Reply #104 on: October 01, 2013, 01:28:37 am »
@axill
No. I'm not currently using the irq-pin for radio. But I might use it later to make the the relay/receiving sketches sleep more.

Regarding the nextAvailiableRadioId. Are you really using the latest L_Arduino.lua in the trunk? The 1.2 version had a bug related to auto-id

(I'll probably better create a new 1.2.1 tag)
« Last Edit: October 01, 2013, 01:36:36 am by hek »