The Vera Community forums have moved!

Advanced => Plugins & Plugin Development => Programming => Arduino Sensor Plugin => Topic started by: hek on August 20, 2013, 04:55:55 am

Title: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on August 20, 2013, 04:55:55 am
Use the following link to  learn how to build your own sensors for less than $10.

http://www.mysensors.org


-----------------------------------



I'm working on a new plugin for home built Arduino sensors that transmits data to Vera using the nRF24L01 radio chip. Initially I will only send data one-way (to Vera) but there is really nothing stopping two-way communication (or even building mesh networks of sensors like z-wave).

I would like to design it to keep the changes to a minimum in the ReceiverSketch (running on the Arduino attached to Vera) and Vera plugin if possible.

For this to work it would be nice if the sensors could present them self to the ArduinoSensorPlugin with all information needed to create them automatically in Vera (like Device/implementation descriptor files etc).

The sensors could the only has two types of messages:
Presentation Data: Always sent when they are powered up. Contains all info needed to create the device in Vera including a unique Id to identify and transmit data to sensor (pipe-id).
Sensor Data: Sent when sensor data is changed.

The VeraReceiver sketch will only relay messages coming on the radio bus to the usb-serial interface which is read by the ArduinoSensorPlugin in Vera.

So.. the question is.. Is it best to keep the different sensor in child devices of the ArduinoSensorPlugin... or is it better to real devices? As stated above.. I would lite to keep changes to a minimum in the VeraReceiverPlugin and move all logic (specific implementation details) to the "child" plugins. This way someone can create a new Arduino sketch for a new sensor and upload the corresponding device files for it in vera.

Please help me brainstorm here.   ;)
Title: Re: Arduino Sensor Plugin
Post by: watou on August 20, 2013, 05:24:14 am
My initial thought would be to keep all Vera-specific service/device/JSON implementation within your distributed plugin, because your radio-accessed nodes are really very far removed from those implementation details.  Instead, develop a spec for communicating metadata and data between your devices and to the plugin, and have the plugin you distribute translate that spec into Vera-specific glue code as the sensors are discovered and managed.  I see the value in what you are proposing -- to have everything load up dynamically without ever needing plugin changes, but I think the reality is that this architecture calls for its own internal interface spec, while the plugin's sole job is to expose those devices in the Vera-specific way.

The analogy with Z-Wave is apt -- the Z-Wave nodes have their own protocol, but Vera translates it all into the single, unified Lua-UPnP interface.

watou
Title: Re: Arduino Sensor Plugin
Post by: hek on August 21, 2013, 07:14:54 am
Hmm..
Yes, I would normally agree with you. But in practice the sensors would only hint the plugin which devicetype(s) to create (and relay data by setting variables or some some other way).

Is it even possible to have separate implementation files for child devices?
Is it possible to create non-child devices (totally disconnected from the ArduinoPlugin)?


So. The sensor could for example send data like this:

<radioid>;<subid>;var1=data1;var2=data2;...\n

where
radioid = pipe adress for the radio in the sensor.
subid = the sensor could have a few sub-sensors. These are being specified by this id
var1 = variable data to be transferred from sensor.

The sensors also would need to send some discover-me message when started (of perhaps when issued from Vera plugin).

These messages could contain something like this (one for each device the sensor want to report data on):
<radioid>;<subid>;device_file=D_XXXX1.xml;var1=data1;...\n

This would make it easy for the Vera plugin to create the device if sensor not already exist on vera. And start relaying data to the device when these messages arrives.
Title: Re: Arduino Sensor Plugin
Post by: watou on August 21, 2013, 07:40:43 am
I'm thinking the approach I used in the Nest and Ecobee thermostat plugins might fit your purposes well, where every polling cycle the plugin interrogates its web service for all the devices it knows, and the plugin will add or remove child devices based on that discovery (which then triggers a Luup restart).  That way, no manual discovery step is needed, as long as the Arduino device that the plugin is dialoguing with is maintaining a current set of known sensors.

So you would have an "Arduino" device object -- the manager object -- and all sensor device objects would be created or destroyed as they appear or disappear from the set of sensors that the Arduino is aware of.  The one "I_Arduino.xml" (or whatever you call it) implementation file would contain all the glue code and service implementations to translate how the Arduino reports its devices and what they know/can do, into the Lua-UPnP format required by Vera.

As I learned writing the Nest plugin, the Vera only has a single hierarchy of parent/child devices (not multiple levels), with the thought behind it being a manager/slaves model.  So any nesting of sensors within sensors or the like really doesn't have an analogy in Vera.  Complex interrelations between managed objects, like you might have in JMX or CIM, don't exist in Vera.

I know this misses the mark on having a completely self-describing and fully dynamic way of bringing new sensors online, but I think there would be so many other obstacles to pulling this off that you might be better off writing your spec (transmitted in JSON or some other easy format), and then having the plugin just focus on the glue logic.

watou
Title: Re: Arduino Sensor Plugin
Post by: hek on August 21, 2013, 05:31:29 pm
I'm thinking the approach I used in the Nest and Ecobee thermostat plugins might fit your purposes well, where every polling cycle the plugin interrogates its web service for all the devices it knows, and the plugin will add or remove child devices based on that discovery (which then triggers a Luup restart).  That way, no manual discovery step is needed, as long as the Arduino device that the plugin is dialoguing with is maintaining a current set of known sensors.
Most of my sensors will be sleeping most of the time  to save battery (and I will turn off the radio).  So I cannot contact them (poll).
Isn't it better to let Vera keep the list of known devices (which will be the child devices). If a new sensor pops up it will present itself (fist message sent when started) which will create a new child device (and Luup restart).
Don't really see the point of storing a list of devices in the receiving/inteface Arduino aswell (this will keep receiver sketch as simple as possible).

So you would have an "Arduino" device object -- the manager object -- and all sensor device objects would be created or destroyed as they appear or disappear from the set of sensors that the Arduino is aware of.  The one "I_Arduino.xml" (or whatever you call it) implementation file would contain all the glue code and service implementations to translate how the Arduino reports its devices and what they know/can do, into the Lua-UPnP format required by Vera.

Ok.. will do some tests to see how "thick" the glue must be :)

As I learned writing the Nest plugin, the Vera only has a single hierarchy of parent/child devices (not multiple levels), with the thought behind it being a manager/slaves model.  So any nesting of sensors within sensors or the like really doesn't have an analogy in Vera.  Complex interrelations between managed objects, like you might have in JMX or CIM, don't exist in Vera.
I know this misses the mark on having a completely self-describing and fully dynamic way of bringing new sensors online, but I think there would be so many other obstacles to pulling this off that you might be better off writing your spec (transmitted in JSON or some other easy format), and then having the plugin just focus on the glue logic.

Ok, so a flat structure below receiver plugin then... Will use the altid to keep track of sub-child devices.

Thanks for your help and feedback.

Anyone else is also free to join in the discsussion.


------------

Code says more that 1000 words. This is an example sketch for a Temperature Sensor

Code: [Select]
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include <Wire.h>  // Comes with Arduino IDE
#include <DallasTemperature.h>
#include <OneWire.h>
#include <stdio.h>


/* Update radio id to something unique in your sensor network */
#define RADIO_ID 0xABCDABCD00LL
#define ONE_WIRE_BUS 2

/* This must correspond to the VeraReceivers radio id */
#define RECEIVER_ID 0xABCDABCD71LL

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
RF24 radio(9,10);
const uint64_t pipe = RECEIVER_ID;
const int max_payload_size = 512;

char payload[max_payload_size+1]; // +1 to allow room for a terminating NULL char
char floatBuffer[20];


void setup() 
{
 
  Serial.begin(9600);  // Used to type in characters

  sensors.begin();

  // Start up the sensor library
  radio.begin();
  radio.enableDynamicPayloads();
  radio.setRetries(15,15);
  radio.openWritingPipe(pipe);
  radio.printDetails(); 
  sendPresentationData(RADIO_ID, 1, "urn:schemas-micasaverde-com:device:TemperatureSensor:1", "D_TemperatureSensor1.xml");
}




void loop() 

  sensors.requestTemperatures(); // Fetch temperature from Dallas
  float temperature = sensors.getTempCByIndex(0);
  sendData(RADIO_ID, 1, "CurrentTemperature", dtostrf(temperature,2,1,floatBuffer));
  delay(10000);
}


/*
  This following functions should probably be moved to a library shared among sensors
*/
void sendData(uint64_t rId, int childId, char *variable, char *value) {
  uint32_t rIdHi = rId >> 32;
  uint32_t rIdLo = rId; 
  sprintf(payload, "%lu%lu;%d;%s=%s\n\0",rIdHi, rIdLo, childId, variable, value);
  Serial.print(payload);
  bool ok = radio.write( payload, strlen(payload));
  if (ok)
    Serial.print("send ok\n\r");
  else
    Serial.print("send failed\n\r");
}

void sendPresentationData(uint64_t rId, int childId, char *deviceType, char *deviceFile) {
  uint32_t rIdHi = rId >> 32;
  uint32_t rIdLo = rId; 
  sprintf(payload, "%lu%lu;%d;device_type=%s;device_file=%s\n\0",rIdHi, rIdLo, childId, deviceType, deviceFile);
  Serial.print(payload);
  bool ok = radio.write( payload, strlen(payload));
  if (ok)
    Serial.print("send ok\n\r");
  else
    Serial.print("send failed\n\r");
}


And this is the basic VeraReceiver sketch

Code: [Select]
/*
  Copyright (C) 2013 Henrik Ekblad <henrik.ekblad@gmail.com>
   
  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  version 2 as published by the Free Software Foundation.
   
  DESCRIPTION
  The VeraReciever is quite dumb. Only sends out the data received from sensors
  on the serial bus (which will be picket upp by Vera and processed).
  So the logic is placed in Vera plugn and the sensors.

  MESSAGE FORMAT
  The mesages sent by sensors has the following format. The data is a regualar ascii string (no binary data).
  End message with newline character "\n".
 
  RadioId;Subid;Var1=Data1;Var2=Data2;...\n

  Id = Unique if of sensor (uint64_t) - Same as pipe if sensor is awake and listening for commands
  Subid = If several senosrs ir reporting information from this device. This id is unque per sensor.
  Var1 = Data1, Var2 = Data2, ... Sensor data. Can be different for each type of sensor. Must be in sync with Vera plugin. 

  Maximum message length of is currently 512 bytes.
*/


#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
#include <Wire.h>  // Comes with Arduino IDE


#define RECEIVER_ID 0xABCDABCD71LL
#define BAUD_RATE 38400

RF24 radio(9,10);
const uint64_t pipe = RECEIVER_ID;
const int max_payload_size = 512;
char payload[max_payload_size+1]; // +1 to allow room for a terminating NULL char


void setup() 
{

  Serial.begin(BAUD_RATE);  // Baudrate to vera
 
  radio.begin();
  radio.enableDynamicPayloads();
  radio.setRetries(15,15);
  radio.openReadingPipe(1,pipe);
  radio.startListening(); 
  Serial.print("0;0;OK=Arduino receiver startup complete!\n");
}



void loop() 

    if ( radio.available() )
    {
      // Dump the payloads until we've gotten everything
      uint8_t len;
      bool done = false;
      while (!done)
      {
        // Fetch the payload, and see if this was the last one.
len = radio.getDynamicPayloadSize();
        if (len<max_payload_size) {
      done = radio.read( payload, len );
    // Put a zero at the end to terminate string
  payload[len] = 0;
    // Spew it
          Serial.print(payload);
        } else {
          Serial.print("0;0;ERROR=Receive error. Too large payload\n");
          done=true;
        }
      }
    }
}

Title: Re: [CODE] Arduino Sensor Plugin
Post by: hek on September 01, 2013, 04:10:28 pm
Released first version now.

Heavy beta warning!
Title: Re: [CODE] Arduino Sensor Plugin
Post by: hek on September 02, 2013, 10:44:03 am
http://code.mios.com/trac/mios_arduino-sensor/
Title: Re: [CODE] Arduino Sensor Plugin
Post by: hifs on September 02, 2013, 01:51:58 pm
For the physical connection between the Vera and the Arduino, you're just using the USB cable that communicates a serial stream, correct? Does it matter which Arduino model you're using? Does it work with the Arduino UNO? I seem to recall that some Arduino models had an FTDI chip while others did not. I was curious what would work with the Vera 3.
Title: Re: [CODE] Arduino Sensor Plugin
Post by: hek on September 02, 2013, 02:05:17 pm
Hi hifs,

You're right. As stated on the wiki you should only use Arduino Nano for the physically connected Arduino. Uno uses ACM (or something) chipset...   
Title: Re: [CODE] Arduino Sensor Plugin
Post by: ChrisK on September 03, 2013, 04:12:35 pm
I have been working on a similar idea for a while now.  I decided to go with Teensy, an Arduino compatible device and XBees.  I have a Raspberry Pi as a Ethernet to XBee gateway.  This allows my Vera Lite to do simple communicate with my Teensys via TCP/IP and let the Raspberry handle the hard stuff. 

My first device is an LED strip to light up my stairway.  The Teensy which is at the bottom of the stairs, has a motion detector and ambient light sensor and controls the LED brightness via PWM and a mosfet to handle the power for the LEDS.   At the top of the stairs I have a Z-Wave motion detector. 

The Raspberry and Vera work together to handle lighting based on motion and time of day.

In the works is a soil moisture and temperature sensor for my garden.

Anyway, my point is I am letting the Raspberry handle of a lot of the work using PERL as my programming language, which is just easier for me, as apposed to LUA on the Vera Lite. 

-Chris
Title: Re: [CODE] Arduino Sensor Plugin
Post by: hek on September 03, 2013, 04:24:27 pm
@ChrisK
Cool.

My idea was to create the cheapest possible wireless sensors and minimize the Vera plugin development. You could possibly reuse the arduino library I developed on your Teensy sensor if you use the same transceiver. 
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 07, 2013, 08:54:43 am
hi, is it possible to send data to sensor from vera OR to request data from vera to sensor?
Cool project )
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 07, 2013, 09:36:06 am
That bit is not quite ready yet... but sure it is possible. I will create a relay sketch when the stuff hardware arrives. It will accept commands from vera side (on/off) and ack that the command has reached the relay. 
 
Note that the sensors that receives data probably cannot be battery driven as they will consume too much power when radio is always on.
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: watou on September 07, 2013, 09:49:15 am
Note that the sensors that receives data probably cannot be battery driven as they will consume too much power when radio is always on.

Could the Nano attached to the Vera use a store-and-forward approach for packets destined for currently sleeping sensor nodes?
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 07, 2013, 10:01:05 am
@watou
Yes that would probably preferable. I don't think the Vera can have this logic in the plugin part. I'm a bit worried about having too large buffers with unsent data hanging around in the "attached nano"  (hereafter called ArduinoGateway) though.

Maybe the ArduinoGateway could timeout messages after 2-3 minutes back to vera plugin.

And when a sleeping node wakes up it could probably poll the ArduinoGateway for new commands.
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: watou on September 07, 2013, 10:11:00 am
@watou
Yes that would probably preferable. I don't think the Vera can have this logic in the plugin part. I'm a bit worried about having too large buffers with unsent data hanging around in the "attached nano"  (hereafter called ArduinoGateway) though.

Maybe the ArduinoGateway could timeout messages after 2-3 minutes back to vera plugin.

And when a sleeping node wakes up it could probably poll the ArduinoGateway for new commands.

You could use a fixed buffer of outstanding commands in the ArduinoGateway, and when it's full the next command pushed on the queue would discard the oldest one pushed and NAK the sender of that command.  Otherwise it would ACK the sender once it's been delivered to the sensor node.  Since there would be no backing storage of this command queue, command senders should not expect to receive ACKs or NAKs in case of reboots, power outages, etc.

Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 07, 2013, 10:19:18 am
Yup. will probably implement it like that. I already have a "queue" for incoming messages partly received (if they consist of more than one 32 byte fragment).
 
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 07, 2013, 11:08:49 am

Note that the sensors that receives data probably cannot be battery driven as they will consume too much power when radio is always on.

sound interesting.
Why don't u use sleep mode in arduino with INT signal from NRF24 to wake-up for sensor?
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 07, 2013, 11:16:45 am
@mitekdg
So true.  Much better.

Is it possible to get interrupts on more than one digital pin? Maybe an attached sensor also needs to trigger?
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 07, 2013, 11:28:01 am
Now i'm working on my project "arduino ethernet-NRF24 gateway".

http://maniacbug.wordpress.com/2011/10/19/sensor-node/ - here the info about power cons. and "battery driven feat."  (INT and sleep mode)
http://maniacbug.wordpress.com/2012/03/30/rf24network/ - about NRF24 network

Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 07, 2013, 12:26:03 pm
Yes those are great pages. Especially the battery feature is cool and should probably be incorporated ;)
RF24 network will have to wait a while...

One thing I find annoying with arduino is that there are no unique id that can be used as radio-id. Now you have to update the sketch for each new sensor.
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 07, 2013, 12:39:15 pm
your project is really interesting and i'm looking to change my project and exclude ethernet, and "replace" it by usb
Waiting for "switch sketch" ))
thx!
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 07, 2013, 01:00:30 pm
Just added a soil moist sensor example

http://code.mios.com/trac/mios_arduino-sensor/wiki/SoilMoistSensor
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 08, 2013, 12:11:40 pm
just test your solution:
1. did u analyze cpu load of vera in VeraGate use?
2. don't why but i have a very poor nrf24 connection ("Error: No ack received") on every data send

thx
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 08, 2013, 01:11:13 pm
Just updated soil sensor to use interrupt instead. Which means faster response and more sleeptime...

@mitekdg
1. No. How do I do that? And why? The ArduinoGateway is mostly waiting for radiotraffic doing nothing... Or did you find some problem?

2. I have really good reception 25+ meters indoors.  Maybe you have something disturbing the radio channels? You can perhaps do a radio.setChannel() to set a explicit channel with little disturbance in your ArduinoGateway and sensor sketch (in setup).

Also ... In the example sketeches for RF24 library (in the libraries folder) there is a scanner program that checks all channels available for how good reception there is. Maybe you could try this to see which channel to choose?
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 08, 2013, 03:50:22 pm
New! Motion sensor added.

http://code.mios.com/trac/mios_arduino-sensor/wiki/MotionSensor
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 09, 2013, 12:11:14 pm
@hek
1. hmm.. don't know why but i feel ... some slow-down. So i set-up system monitor + dataminer. Will check! )
2. Took another arduino + nrf24. Experiment two.

Did u make some test of power consumer?  its interesting how long will it works. I'm going to use 18650 acc
what about two-way solution?
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 09, 2013, 01:48:31 pm
Please do try to debug. Mine is superfast. When I started using interrupts on sensor its feels much faster than z-wave devices.

I have not tested power consumption yet. Will do that but I am still waiting for my new nano boards to arrive.

My first sensors will be mains feed.
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 15, 2013, 02:08:00 pm
test done.
1. cpu usege - ok
2. poor nrf connection. Problem was in power supply.

what about two-way connection?
did u try to use a RF24Network? 
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 15, 2013, 02:35:51 pm
I received an relay a couple of days ago but have had little time programming. Will do some nighthacking when the kids are in bed tonight.

Sorry have not tested the RF24network stuff...
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: buzzdavidson on September 16, 2013, 04:44:49 am
Was just poking around the forums and ran into your post - it's an interesting idea.

You might be interested in checking out the PanStamp project (https://code.google.com/p/panstamp/).  I have a handful of these and am in the process of integrating them with my Vera.  They have done a really good job of minimizing power usage - if nothing else, you may be able to glean some information from their implementation.

You might also be interested in the RF24Network library (http://maniacbug.github.io/RF24Network/); it implements a mesh network using NRF24L01 radios. (Edit: I just noticed that maniacbug himself already responded to this thread.  Hi Mike!)

I'll be interested in playing with your implementation - ZWave devices are ridiculously expensive.  I'll be happy to do a quick code walk-through and provide some suggestions (which you can feel free to ignore <g>).  Reading through this thread, I would suggest that you not transmit the full URN from each sensor node - it's unnecessarily verbose.  You'll be eating a lot of battery sending the same data over and over.  You already have a gateway node talking to Vera, just assemble it there.  The PanStamp project has done a good job of encapsulating device capabilities and information in a minimal footprint, it may be worth a look.

Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on September 16, 2013, 07:01:56 am
Really interesting topic.
I ?we been looking for an affordable solution to control my 2 motorized garage doors.
Seems like one of these would have enough I/O to serve my purpose and more.
All that is needed is basically 1 or 2 binary inputs to show the door position and 1 binary output to control the door.

Regards,
Tomas
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 16, 2013, 07:55:12 am
@buzzdavidson
Thanks, I'll be glad for any feedback! Please do check the code! Especially if I can make the sensors less power hungry.
Currently doing some refactoring to cope with information going from vera to actuators (like relays). 

@korttoma
Absolutely. This would really work as a affordable solution for your garage doors.
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 17, 2013, 01:32:36 pm
Ok! First basic support for actuators (relays etc) added. Also cleaned up the plugin code a bit.

http://code.mios.com/trac/mios_arduino-sensor/wiki/RelayActuator

This release have no resend functionality if message never reaches relay module. But the relay itself sends an update back to vera if it was changed. So its quite obvious that relay hasn't changed. 

When the the relay module starts up from off it requests the current state of the relays from Vera.

 
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 18, 2013, 02:45:30 pm
Stabilized relay code and added example sketch for light sensor.

http://code.mios.com/trac/mios_arduino-sensor/wiki/LightSensor
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 18, 2013, 02:48:32 pm
Is anyone using (or plan to use) the things I produce here?

There aren't much activity in this thread...

Would really like some more beta testers.
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Quinten on September 18, 2013, 02:57:18 pm
You know what, I'd love to get this started...  I've been hum-ing and ah-ing over the RFxtrx and some Oregon sensors, but this offers a much nicer solution.  The problem is that I have 10s of 'projects' on the go and none of them get finished ;)

Battery life for a (completely) wireless sensor should be a year minimum imho...  do you think that is achievable?
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: twistedsanity on September 18, 2013, 05:20:53 pm
Well I'm planning to give it a go, I've ordered some NRF24L01+ but still waiting for them to arrive (already have plenty of spare arduinos).
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on September 19, 2013, 08:32:28 am
Hi Hek - Firstly - AWESOME job!!!!

I asked about someone ( much smarter than me ) doing this a while back - here: http://forum.micasaverde.com/index.php/topic,11736.0.html

Ill be all over this!! Please keep feeding us!

Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on September 19, 2013, 08:39:58 am
Hi Hek - ive not read entire thread yet  ( a bit too excited just yet - but with respect to running very low power - have you seen the work done by the Jeenode developer - http://jeelabs.org/intro/

He has apparently done some amazing work on getting the arduino's to run extremely low power. Ive seen others use his library/code in their projects - so perhaps this would fit the bill.


Anyway - thanks again... now off to do some more reading..... ;-)
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: pat38 on September 19, 2013, 03:50:21 pm
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

Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 19, 2013, 04:00:50 pm
@pat38
Great to hear!

@greglions
Need to do some current measurements when my nanos arrive. They've been in the post void between China and Sweden for a month now! I don't really no how many uAmp they consume. Maybe it would be good to have this figure on the wiki per senors... Any help is appreciated.
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 20, 2013, 03:19:23 pm
Rewrote most of the code today. Gave up on the idea of splitting up/putting together large messages. Moved more of the definitions to the vera plugin and only very short messages needs to be sent from/to sensors now. Max payload is now 29 bytes.
Stability is much better now and device creation simplified.

Also implemented a very basic "weather station" forecast using using the pressure sensor BMP085.
http://code.mios.com/trac/mios_arduino-sensor/wiki/PressureSensor
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 22, 2013, 11:26:26 am
Added humidity sensor.
Improved stability when sending in values after powerdown/sleep.

http://code.mios.com/trac/mios_arduino-sensor/wiki/HumiditySensor

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 23, 2013, 02:20:01 am
Hi, Hek!
THX for relay suport )

4 questions:
1. Why did relay react to vera requests so looong? Just for test i push button and it requres 2-3 times to push on|off to work.
2. In PressureSensor.ino there is a string:
#define ALTITUDE 9.0  // Your altitude (in meters). This can later be configured in Vera.
How did it works? I mean data transfer from vera to arduino.
3. Could u make a support of variableContainer pluggin? Simply i need to store some arduino data in it.
4. Could u make a support of EEPROM. I mean a possibility to GET and SET variables/data on arduino.

thx for your work!!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 23, 2013, 02:45:31 am
1. Probably bad reception. You can configure it to resend (requires you to re-compile the Arduino Gateway) at the top of Vera.h
2. Forget about that. Should be removed.
3. Sure.
4. Had some ideas about that too.. Using EEPROM we could probably let vera dynamically issue a radio-id for new sensors... which would ease the configuration a bit.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: FireBird on September 23, 2013, 01:43:21 pm
Just wanted to say thanks for the great plugin and the how to documents you have created for this project. I'm thinking about buying the hardware soon, I would like to trend some temperatures in different parts of my house and this seems like a good solution for that.

Can the temperatures be converted to Fahrenheit easily?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 23, 2013, 01:50:55 pm
@Firebird
Yes it can be converted in Arduino sensor pretty easy. There is no support for vera side conversion just yet.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: FireBird on September 23, 2013, 02:10:45 pm
Can I use the Mini USB Nano V3.0 ATmega328P as the Gateway and for the Sensor boards? I would like to buy everything from the United States not China (don't want to wait weeks for shipping).

The price difference is only $3 or so, plus I won't need to buy the FT232RL USB to Serial adapter. I'm new to Arduino so thanks for the help. How are you powering the sensors? I'm sure it's batteries but could you give some more detail, what type of battery etc.

Thanks again.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 23, 2013, 02:39:58 pm
Can I use the Mini USB Nano V3.0 ATmega328P as the Gateway and for the Sensor boards? I would like to buy everything from the United States not China (don't want to wait weeks for shipping).

Yes that is what I've used for my gateway. For the sensors you can use any Arduino board.

How are you powering the sensors? I'm sure it's batteries but could you give some more detail, what type of battery etc.

Currently powering them using a step down module.
http://www.aliexpress.com/item/10pcslot-LM2596s-DC-DC-step-down-power-supply-module-3A-adjustable-step-down-module-LM2596-voltage/912126670.html

I have not done any battery and/or power consumption tests yet (it will come...). And I recon it depend a lot on how you configure the sleeptime (how often it should report) of the boards.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on September 23, 2013, 04:02:35 pm
@hek,

Been following this thread for awhile and it's something I would like to try out. I have been working with a WiFly module and Arduino, it took me forever to get it working, but that's another story.

Went to code.mios.com to get the files for your Arduino project but it appears that I can only download one file at a time. I don't have an account there. Unless I'm doing something wrong in trying to get all the files needed, could you possibly ZIP them up into one project file ? Sure would help .

Great work by the way and please keep it up. It was just what I have been looking for !
Thanks again...
 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 23, 2013, 04:16:17 pm
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?

Today's addition is a Distance sensor for vera. Distance in centimeters. Us-people. Please switch to use the metric system ;)

http://code.mios.com/trac/mios_arduino-sensor/wiki/DistanceSensor

@jackpot
At the bottom of the following page you can download zip-archive...
http://code.mios.com/trac/mios_arduino-sensor/browser/trunk
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on September 23, 2013, 04:19:51 pm
Thankyou !

I just got it. ;D
I must be getting old, didn't see it before.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 24, 2013, 08:40:05 am
Added support for Variable Container

Code: [Select]
  // Create container

  setup() {
     ...
     vera.sendSensorPresentation(0, S_VCONTAINER);
  }

  loop() {
         vera.sendVariable(0, V_VAR1, "4711");
         vera.sendVariable(0, V_VAR2, "4712");
         vera.sendVariable(0, V_VAR3, "4713");
         vera.sendVariable(0, V_VAR4, "4714");
         vera.sendVariable(0, V_VAR5, "4715");
      ....
   }
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 24, 2013, 09:45:02 am
When testing the variable container a little more there seem to be some problems...  It makes the communication "crash" in the main device. I don't know if it does not like to be a child device or if it outputs stuff to the serial post that makes the main device behave like this... The only difference I can see is that it got its own implementation file.

Arduino Gateway Plugin[272] : Failed to open IO Port

09/24/13 15:37:42.224   luup_log:272: Arduino plugin: Port already in use <0x2ea03680>

Any help regarding this would be appreciated!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 25, 2013, 04:35:23 am
1. Probably bad reception. You can configure it to resend (requires you to re-compile the Arduino Gateway) at the top of Vera.h
Fixed!! yes u were right) "bad reception". thx
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 25, 2013, 07:01:26 am
another feature requests:
- battery level. http://maniacbug.wordpress.com/2012/03/30/rf24network/ - it's very important to now if a battery driven dvcs in poor state
- NRF24 device status on Arduino gateway. Battery level could be a part of status of "NRF24sensor", last time connection, error(s), Known devices and addresses. What's more?

Hek, thx!!

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 25, 2013, 07:35:29 am
You can actually send battery status from your sensor already using V_BATTERY_LEVEL and V_BATTERY_DATE. The trick is to build a sensor where you can read out the battery status.

The arduino gateway is stateless right now. I would like a really good reason why it shouldn't :)
Last update could be stored directly in a variable directly in the vera device. Any particular reason for this?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on September 25, 2013, 03:59:28 pm
hek thank a lot for your good work!
will follow the project as I'm also looking for the similar solution.
I've tried to build tcp/ip based gateway but your way is much smarter.

I have an idea to share about assigning ID to radio device.
It looks like how zwave devices are paired.
- let us put a button to any arduino device
- as soon as a button pressed a special message (a request) is issued to arduino gateway
- gateway should send back a special message with ID
- the only arduino device who had button recently pressed should react to the message with ID and ID should be stored in EEPROM for the use

to keep arduino gateway stateless we should ask vera to provide an ID, it can be even copy of the id of the parent device created in vera for our arduino device

alternativelly we have no button - each new device who see at startup that EEPROM is empty (0xff) at addrees of ID should request it from arduino gateway but we should manage to have only one NEW device powering up at a time
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on September 25, 2013, 04:50:26 pm
I would like also to make a future request.
Is it possible for devices to recieve a clock/date data from vera?

It would be nice to build simple home clocks without any need for their mannual management - clock will be always in sync with vera while vera is in sync with the rest of the world
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 25, 2013, 06:02:54 pm
@axhill
What happens to the eeprom when re-writing/downloading a sketch? Will it be wiped?

If not wiped - We have a probelm if a new sketch containing a different set of sensors is written to the arduino. It will send its old id back to vera and it mill missmatch the devices in vera.

If it gets wiped -  We will create new vera device each time we update our sensor code because the sensor will request a new id.

Hmm...

The time variable was a good idea and i will implement it. It will work like the relay sketch does (when requesting state in startup).
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 26, 2013, 01:22:18 am
2 hek: u r using Pro-Mini 5v now, but NRF24 module requires 3.3V power supply, how did u solve it?

EEPROM would not be wiped when u re-write a sketch.
To solve that problem, before upgrade the sensor, - delete an old one from vera.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 26, 2013, 01:41:35 am
I realized that a couple of days ago (when my pro minis arrived) also. I will buy some low drop power regulators.  Probably these:
http://www.aliexpress.com/item/FREE-shipping-10-PCS-LE33-TO-92-VERY-LOW-DROP-VOLTAGE-REGULATORS-WITH-INHIBIT/481626589.html

I have some large step down power supplies that I can use while waiting;
http://www.aliexpress.com/item/10pcslot-LM2596s-DC-DC-step-down-power-supply-module-3A-adjustable-step-down-module-LM2596-voltage/912126670.html

Will update the wiki...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on September 26, 2013, 04:52:15 am
take a look at this LDO http://www.aliexpress.com/item/XC6206P332MR-XC6206P252MR-SOT-23-SMD-triode-transistor-Good-quality-ROHS-leave-message-model-you-need/473456552.html
looks like it can feet requirements and it is chiper
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 26, 2013, 05:16:15 am
Yes, and MCP1700T or LD1117 also looks good.
But some of the are really tiny and hard to solder by hand I guess.. ?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on September 26, 2013, 05:22:07 am
MCP1700 is nice but LD1117 better to check for datasheet
I have AMS1117 - drop voltage is at minimum 1V while MCP1700 and the one I mentioned early are about 0.25V

yes - it will be hard to use them on breadboard but soldering is simple even without hotair
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 26, 2013, 05:32:00 am
Ok, I'll also buy some 662K. 

100 pcs for $6 is unbeatable. It does not matter if soldering fails for a few of them...

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: nullx8 on September 26, 2013, 05:36:39 am
short question:
How many sensor elements can be served with one Arduino board ?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 26, 2013, 05:44:26 am
It depends...
You have 13 digital inputs and 5 analog on a arduino pro mini.  The radio uses 5 of the digital ports. So left is 8 digital inputs.

In the code i've set the limit to 128 child sensors per radio...


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: nullx8 on September 26, 2013, 05:49:44 am
so 8 digital and 5 analog left .. thats a word !

i'm serching for a affordable solution for serval motion and distance Sensors to get things more "automated".
my drawback was the expected cost of easy 400 bucks in z-wave hardware.

does that work with a VeraLite and a USB-Hub as well ? (i dont want to loose the logging and storage for datamine)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 26, 2013, 05:50:33 am
I have my arduino hooked up to a usb hub. So yes.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Ludde on September 26, 2013, 07:22:06 am
Hi!

hek: Impressive work! Have done some testing with your code and it works fine! I have a few ideas that may be of interest;

* It is easy to connect a serial LCD to an arduino and in combination with a cheap PSU one could make small "info-frames/stations" around the house showing various Vera data. Or with Larger LCDs or dot-matrix displays one could make ?wall-clocks? showing whatever Vera data you like. Maybe a development of axill's clocks? Sending text strings to a "sensor"?

* A really low battery solution for one or two I/Os would be great to watch the mailbox (the physical one). I know it has been discussed but not sure if a good solution came up?

* As for the ID of the sensor, I believe Dallas has some one-wire chips with just a unique ID on (DS2401). Maybe something that can be used? Or if all sensors have a DS18x20, one could steal the ID from those. http://www.aliexpress.com/item/Ds2401-ds2401-to-92/892319599.html (http://www.aliexpress.com/item/Ds2401-ds2401-to-92/892319599.html)

Anywho, will continue to play with this system whenever there is some time leftover.
Keep up the good work! 8)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 26, 2013, 07:39:06 am
Thanks Ludde.

The Arduino vera plugin could very well relay messages to a sensor. It should be enough if I implement a sendMessage action where you can specify the (altId) of the sensor and a string message.
But bare in mind that there is a limitation of 29 bytes payload in each message to the sensors. So we will not be able to stream any video to a sensor :)

The sensor would then use the waitForMessage and do the needful when a message arrive. BTW right now waitForMessage is busywaiting.. I should probably do something about that aswell (or at least give an alternative).

The mailbox sensor should be pretty simple.  Just register the sensor as a door or motion sensor and connect a magnet sensor between +5 and on of the digital in:s of the arduino. Using interrupts this sensor would sleep most of the time (see soil moisture sensor for an example).

@All
I am open to contributors. Improving documentation or code. Just give me a nudge.

 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: nullx8 on September 26, 2013, 07:42:49 am
I have my arduino hooked up to a usb hub. So yes.

thats great, i have a USB Hub in my "Router Room" already. but its connected to a Computer Power Supply for the 5 volts
serving the MiLight Bridge, and my in-wall Tablet (on the other side of the wall) and the Phone (3G Backup)
(the 12 volts serve all routers,switches, pbx, vera, hdd's and so on)

just need to figure out how to  have the vera use serial part of the usb hub with power coming from the Computer Power Supply
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Ludde on September 26, 2013, 08:18:36 am
Thanks for tip, see that the soil sensor uses interrupts, will be fine!

Ooops, forget about the DS2401 ID idea, the ID is 0-255... DS2401 will be too large (48-bit).

As for the message length, anyway one could send two messages, like A and B from Vera? Have the same node ID but different message IDs?

Is there a limit on how many serial devices that can be configured in Vera?

nullx8: Cut the red wire? Keep the D+, D- and Ground? Maybe?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: chilump on September 26, 2013, 10:22:44 am
First I really appreciate you taking the time to post this guide for the community!

I was wondering if folks would be willing to post pictures of their devices they purchased using the links in the guide so  Newbee like my self could have a visual to go along with the instructions?

Thanks everyone!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 27, 2013, 09:59:16 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

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on September 27, 2013, 11:35:15 am
hek it is unbelievable! thanks for release
will follow beta testing as soon as possible
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jduchon on September 27, 2013, 05:42:26 pm
Hello Henrik!

Congrats for this achievement.
I would like to use the distance sensor to inform me about the level of my tank (water not beer but I'll offer you one) Do you think it can work?

I plan to power it with 1.5 V batteries. Do you think I need 3 or 4? The tank is 10 m away from the Vera with only 1 wall in between.
I will report my testing results.
Thank you.

Jerome
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jduchon on September 27, 2013, 07:07:46 pm
I just found the resolution of the ultrasonic sensor (0.3 cm), so it should work.
I have a large but flat tank with only 90 cm between empty and full levels.
I'm curious and impatient to set this up!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 28, 2013, 02:56:50 am
The distance sensor is surprisingly accurate. Should work very well for your project!

Don't know how it will survive long time exposure to moisture in the tank though...
3 batteries will give 4.5 volt which would give enough power and can be connected to the unregulated Vcc input of the pro mini.

 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 28, 2013, 12:52:38 pm
hek, thx 4 update!
bug report: RelayActuator - stop working. ver #28 - work fine
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jduchon on September 28, 2013, 01:34:31 pm
Yes, moisture will be the big problem. Thank you for the advice for the batteries and voltage.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 28, 2013, 01:56:18 pm
@mitekdg
What parts did you update? Both plugin, library and relay sketch (using new library)?
Did you also update the ArduinoGateway sketch using new library?

Next step to debug is:

Have a look at Vera logs. Is data coming in from sensor?
> grep Arduino /var/log/cmh/LuaUPnP.log

Also have a look at the serial output from relay sketch Tools->Serial Monitor

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 28, 2013, 02:22:54 pm
1. gateway - updated
2. lib - updated
3. relay sketch - updated
non working

1. gateway - updated
2. lib - old ver28
3. relay sketch - old ver28
working

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 28, 2013, 02:57:06 pm
And vera plugin version?

Please check vera logs if we can find any problems there...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 28, 2013, 03:01:48 pm
updated vera plugin.
ver 1.2

how to get this data from vera?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 28, 2013, 03:31:16 pm
You need to ssh into vera and run the command above.

Maybe it's better to look at serial log on relay first. Hook it up to your computer and select Tools->Serial Monitor in the Arduino IDE.

Then turn on/off relay in vera/browser and look at the output.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 28, 2013, 04:06:27 pm
I might have found something... w8 a bit...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on September 28, 2013, 06:01:22 pm
Found a problem in vera plugin. It manifested itself when a sensor requested an id.
An updated "L_Arduino.lua"  has been checked in.

@mitekdg
Was your problem that no device showed up at all?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 29, 2013, 08:58:37 am
yes. no device showed up.
Now i'll try a new version.
thx
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on September 29, 2013, 09:09:55 am
work perfect! thx
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg 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
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek 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%


Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek 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.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek 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
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg 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!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek 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.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg 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
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill 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
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek 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
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill 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?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill 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
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill 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?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek 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)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on October 01, 2013, 01:39:18 am
2hek, what do you think about relay nodes?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 01, 2013, 02:47:52 am
@mitekdg
Maybe. Must think some more... Would be good with stateless relay nodes.

Or with this. Problem solved ;)
http://www.aliexpress.com/item/NRF24L01-PA-LNA-Wireless-Module-with-Antenna-1000-Meters-Long-Distance-FZ0410-Free-Shipping-Dropshipping/782032049.html

Gahh.. National holiday in china. Nothing will ship out for the next 7 days.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 01, 2013, 03:01:01 am
hek which one in your source directory is the latest one? I was sure that 1.2 is the latest
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: parkerc on October 01, 2013, 03:08:12 am
Wow. I've just finished working my way through 106 107 posts (@axill just beat me) and I'm really keen to try this. (I've not used Arduino before, but I'll give it a go)

I already have rtxrfx433 running a number if devices, but I certainly like the depth and breadth of devices that @hek and the team have come up with (A door bell relay to work with a wired bell/button is a must !)

A couple of less technical questions

    - Is everything bare/naked circuitry or can you get cases etc. for these?
    - How are people mounting / positioning them?

As I have a house proud wife to keep happy, makeing the house look like a scene from a transformers movie is not going to go down well. ;)

And one technical one.

    - An IP approach was discussed rather than USB, is that still possible (ser2net) ?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 01, 2013, 03:19:14 am
hek which one in your source directory is the latest one? I was sure that 1.2 is the latest

No that is just a tag (so we have some reference). trunk is always latest.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Ludde on October 01, 2013, 03:37:19 am
Just a thought about the relays, what would happened if a relay was just sending the exact content it receives? Every sensor has its own address so a message would only be processed by the correct sensor anyway!? Works lite the vera gateway, transparent?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 01, 2013, 05:15:44 am
just succeed with motion sensor
it is amazing how simple is to setup it!
hek excellent work!

relaying i think is a next important step

it is also would be nice to make an abstraction layer between Vera and RF24 etc. to make it possible easily replace transport from RF24 to anything else.

for example:
- encryption we re discussing can be set on a more lower level keeping Vera high level without knowing about encryption
- it is an idea to build a module for wireless device programming. It can be NRF24LE1 (with MCU) or NRF24L01 + atmega8 as a module connected to an arduino. Module will have a firmware to pass data through radio + program main MCU. This will require to replace RF24 by something else.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 02, 2013, 01:44:43 am
I have been following this thread from the start. I was planning to do something very similar awhile back with the arduinos and the xbee modules, but the cost of the xbee modules and the limited time I had made me put this project on the back burner. Now that winter is starting to creep up, I plan to use this project to do what I did not have time for. I appreciate the time and effort that went into this. Hopefully we can get more people to help with this project and make it even better. My intentions are to add some temperature sensors around the house to have a house average for use in heating and cooling. With the other sensors available, I may take on those to. Some questions.

1. I have always come across aliexpress, but never considered purchasing anything from there. Is it safe and reliable?
2. Has anyone tackled powering the arduino sensors via battery? I noticed a few posts on this and the blog posted by mitekdg. But has anyone implemented this and have real usage on how long it will last on battery. What is needed to get the battery readings passed to the gateway and read by Vera?
3. What type of enclosures are people using?
4. Would the Nano be the better choice as it supplied both 3v and 5v while the mini depending on the module you get supplied one or the other.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jfp on October 02, 2013, 03:41:14 am
Another arduino interesting product is RFduino which embedded bluetooth 4.0 LE
http://www.rfduino.com/


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 02, 2013, 04:51:17 am
jfp sure it is interesting but I do not see benefits comparing to hek choice. Yes footprint is nice, but not that different and at least two times more costly
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 02, 2013, 10:22:14 am
garrettwp browse here http://www.thingiverse.com/search/page:1?q=arduino&sa=
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 02, 2013, 02:03:45 pm
Wow, really nice axill! Would love a box. The Nano is just dangeling from the wall mounted vera3 now.

It would actually be rather simple to implement "include" button for the gateway. When one of the digital pins get HIGH we could let through presentation messages to vera for a minute or two...

I've thought some more about relay nodes. And this will be the most probably solution if no one objects too hard.
If implemented like this, no routes or tables needs to be stored in EEPROM of nodes (hard to debug and maintain) and everything can be monitored from Vera. Unfortunately only one level relay will be supported but I think that will be enough for most setups. If distance is a problem one could always use the large-antenna-version of nrf24.

Rely nodes register themselves like normal nodes. They will also be able to have other sensors attached and report data from those. A relay "sensor" will be created and presented like this:
Code: [Select]
vera.sendSensorPresentation(0, S_RELAY);

The relay nodes also will need to call
Code: [Select]
pumpRelayMessages()
frequently to forward messages traveling thought the relay.

Vera plugin will create the new relay device. The device holds a variable (RelayFor) containing all nodes that this relay is handling. The RelayFor will automatically be build up when new relayed nodes gets detected (or can manually be set in vera GUI). The RelayFor is used when vera needs to communicate with a node (otherwise we would not know which relay that handles a specific node).
 
When a node want its data to be relayed they will need to call a new constructor:
Code: [Select]
Vera(AUTO, <relayNode>, &radio)

Unfortunately I will probably need to change the message-protocol to include relayNode data.
 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on October 02, 2013, 02:10:17 pm
I bought these off of ebay about a week ago (SI24R01 2.4GHz RF Wireless Transceiver Module) and have had excellent results with them. Was a US supplier. I got 10 each for $11.38 + $1.50 shipping. They have very good range in my home at least. About 50 feet apart going through 3 walls. Haven't tried going farther apart yet .

Product features as listed on ebay ..................

"    SI24R1 is fully compatible with NRF24L01+ (SPI operation sequence, register definition, working state diagram), can communicate with each other, support NRF24L01+ all the function of communication.
    Output power of SI24R1 is 2~3 dBm by default mode, if you want 7dBm output, can change register address 0x06 (RF_SETUP) registers its lowest write 1 (NRF24L01+ did not use the bit, the default is zero), namely 0x06 register Low four bits to 1111.  "

So I'm not sure if it's running at 2~3 db or at 7db with @hek's awesome app .

Thought I would post this as an alternative to the standard NRF24L01+.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 02, 2013, 02:20:31 pm
jackpot name of the module is meaningless. Only chip name is important. If it is the same nrf24l01+ it will be absolutely no difference.
the only difference can be if module has PA+LNA meaning it has additional circuit to enforce input and output radio

hek
why not keep nodes knowing nothing about to whom they should talk? It can be gateway or relay - should be no difference.

I still think we should build a few layers for relaying otherwise this restriction will be hard to change.

Your idea to have relay devices in vera is excellent - it means that we can have all network data accessed and managed from vera.
Why not to make it multilayer? The only difference from one layer with multi is that each relay will have one additional byte - address of sub-relay.

To make things more transparent vera can have a possibility to push changed list of neighbors to relays. This way we can manually pair any node to any relay.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 02, 2013, 03:30:49 pm
Your idea to have relay devices in vera is excellent - it means that we can have all network data accessed and managed from vera.
Why not to make it multilayer? The only difference from one layer with multi is that each relay will have one additional byte - address of sub-relay.
Not quite that simple. One direction is simple. From a sensor back through multiple relay nodes to vera there is only one route (tree toplology). 
But If we want to control an actuator far away in the sensor (passing through multiple relays) network we have two options:
1. Send route with message  (please pass through relay nodes 1,5,27,42 etc to reach your target).
2. Each relay node keeps track of where to pass messages for ALL sub nodes (not just its direct children). Otherwise we would not know where to send a message if the are more than one relay child or not a direct route.

Option 1 would require space in the message structure (one byte for each hop). But would probably be simpler to implement.

Option 2 would require storing of router tables in the relay nodes (with backup on vera side). Probably need to keep these dynamiclly sized tables in EEPROM storage and also need to be refreshed at each startup. This requires some kind of refresh messages to be sent from vera containing routing info for the specific relay node. Probably multiple of them as data storage is limited. I am a bit worried that this could be risky and  error prone if/when routing messages never reaches relay nodes deep in the network or parts of them do.  We could expect people having problems with corrupt routing that is hard to debug.

Also vera side has no concept of more than parent->child relation. Sub children does not exist. This means that I have to simulate a tree structure for routing info.


Hmm..  the more you think about it the more complex it gets...

Don't know if anyone understands what I'm trying to describe but that is why I choose to go for option 1 with 1 hop as a compromise.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 02, 2013, 05:00:36 pm
what if route will be send prior the message?

let me propose a minor modification to your one layer network which can make it multilayer & not complicated

let us see an example - we need to send message to node 5

-- we are strictly in a logic of your proposal
scenario 1.
relay has an id 5
so as gw sends message addressed to node 5 it will send it to our relay and relay understanding that message is addressed to itself will execute it as regular node

scenario 2
relay has id 1 and there is a neighbor with id 5
relay will see that message is addressed not to itself this why it will pass it without modification to node 5

thats it, it is how one layer can work

-- we are modifying logic to have multilayer network
scenario 3
relay 1 is not withing a range of node 5
node 5 is withing a range of relay 3
relay 3 is withing a range of node 2
relay 2 is withing range of relay1

path to reach 5 should be gw->1->2->3->5

we need to add just two things - will note them as A and B
A
a modification to scenario 2 in bold:
relay has id 1 and there is a neighbor with id 5
relay 1 will check a recent path received from gw and if this path is for node 5 will pass message unmodified to the next relay in the path
relay will see that message is addressed not to itself this why it will pass it without modification to node 5

B
let us use a timing machine and let us go back in time just prior gw is ready to send message for node 5 though relay 1 (scenario 2)
just before this gw should send a message of type "the path" to relay 1
it can be a message like {5, 1, 2, 3}
- receiving message of that type  relay should store it in single dimension array and pass it unmodified to the next relay in the path except the last relay
path can be stored in regular RAM, not necessary to store it in the EEPROM

done

with A and B your can have single layer network behave 100% as you described but if someone will design a few layers network it will start working.

using such technique we do not need space inside the message and we do not need to debug network as your mentioned for a proposal there relays have to be statefull.

the path can be up to 30 relays - max payload is 32, first byte can be used to indicate "it is the path" and second byte will be used to mentioned the node for which the path is valid.

it is a probability that message with the path will not be delivered while message for node 5 will be. in that case node 5 will be not reached.
but actually the same can happen with one layer network too
in all 3 scenario, one layer or multilayer this problem can be addressed by physical network design
multilayer will allow your physical design be more flexible.


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 03, 2013, 06:36:09 am
experimenting with my port of Vera.cpp to plain C using jaseg port of RF24
i have a chance to make it working )

I've tried to rebuild my "simple" clock using arduino IDE but it generated hex of size 16k!
it is migger than size of atmega8 prog mem. Do not want to re-solder)
In plain AVR my code is 6k
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 03, 2013, 07:50:25 am
So I am putting together a list of what to buy and found a seller on ebay (in Hong Kong) that sells pretty much everything I need. I really wish I could get the stuff in the states, but the prices are 3x more than what I can get on ebay. Some questions:

1. Since these sensors will be battery powered, would it be best to buy the 3v3 volt versions of the Arduino Pro mini's? Or should I pick up the 5v? How would the nano fair with battery usage as I can use the 3v3 rail, but that would use the voltage regulator? Most of the sensors I am looking at would be better suited to the 3v3 version of the Arduino.

2. Would a Buck Boost Converter or a boost converter be better to use with a 2 or 3 AAA battery pack depending on the Arduino module I buy? What would be best to power the sensors using 2 or 3 AAA batteries (preferably NiMH eneloops).

3. I know it is more expensive, but the Sensirion SHT11 is a nice sensor and pretty accurate. Anyone tried these? How well does the DHT22 compare to the SHT11? Are they pretty reliable? I hear reports that the people are having issues running the DHT22 on the 3v3 Arduinos.

I had a look at the RF24Network library, and it seems that using this library would be much easier than to implement your own mesh type network. Did you have a look or consider using that library?

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 03, 2013, 08:52:20 am
hek looking at time example can understand that you are sending GMT time from vera
why not sending local time?
now it is required to hardcode timezone on device side

is it hard to add parameters to devices managed from vera?
like we can manage configuration settings for zwave devices on Device Options tab

for example with my simple clock i have a parameter to set display intencity
or my water count device will send current count to vera but it will be nice to edit current count too
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 03, 2013, 09:18:43 am
@axill
I could perhaps fix time using the newly found "luup.timezone". Will check this tonight

Regarding custom variables... We should try to use the standard variables/devices as far as possible. There are also 5 misc (var1-5) that can be used. But i'm happy to add new device types/variables if they make sense.

@garret
Sorry.. maybe someone else could answer your questions regarding electronic component decisions. I'm only a layman in this area.. (but i'm eager to learn!). So if updates are necessary on the wiki regarding buying guide, please let me know.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 03, 2013, 09:23:02 am
Quote
Regarding custom variables... We should try to use the standard variables/devices as far as possible. There are also 5 misc (var1-5) that can be used. But i'm happy to add new device types/variables if they make sense.

hek I do not need custom if there is standard )) Which 5 variables do you mean?
Let me explain once more.
For example my node has a parameter to fine tune it and I do not want to hardcode it.
Is it a way exists on how I can configure that parameter from vera? etc. node will receive updates on the parameter from vera
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 03, 2013, 12:07:51 pm
There is no automatic variable watch so you cannot just update the variable in the advanced-tab of the device. But you can send a vaariable change through action call (from the advanced scene tab by selecting arduino gateway device) or doing the following luup call.

luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand",
                 {sensorId="42", variableId="VAR_1", value="hello"},
                 <deviceId>)

<deviceId> = your arduino gateway device id

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 03, 2013, 12:36:00 pm
hek should i use Vera::waitForVeraMessage() on node side to get that value?

it seams no wait function is needed too or probably I can call radio->available and if it is true I can call for waitForVeraMessage which actually will not wait but will read a message

I'm I right?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 03, 2013, 12:54:52 pm
because variable type is 1 byte I suggest to create 16 or even 32 variables. 5 is not sufficient
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 03, 2013, 01:07:26 pm
Yes that would probably work. But note that could be hanging there as your node will also receive all messages sent to the gateway.. This is how the RF24 chips work... if I open an writing pipe to the gateway  it will also automatically listen to gateway pipe (where all nodes send their changes). 

I've implemented  another option in the next version that not busywaits...

if (vera->messageAvailable()) {
   message_s message = vera->getMessage()
}
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 03, 2013, 01:15:03 pm
because variable type is 1 byte I suggest to create 16 or even 32 variables. 5 is not sufficient

This was implemented to minic the VariableContainer. You can always create more devices from the node.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 03, 2013, 01:16:16 pm
do you mean that it is needed to use radio->available on a specific pipe?
which one? pipe = 1?

p.s. It is amazing how simple all things are) it seams i will finally launch my simple clock - simple means no buttons to configure.
just in half a second after power up it gets time from vera and will sync automatically time to time
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 03, 2013, 01:18:23 pm
This was implemented to minic the VariableContainer. You can always create more devices from the node.
do you mean that it is 5 variables for each child node? etc. if i need 10 i can use two children?
but any way can you please add up to 16) in 256 variants it is a plenty of space
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 03, 2013, 01:25:14 pm
do you mean that it is needed to use radio->available on a specific pipe?
which one? pipe = 1?


No that is unfortunately not enough. I must inspect radio id of message to know if it aderessed to the node.

I will probably relese somthing to the trunk later tonigt. Problem is that my wife is in Hollands and I will have to take care of the kids now  :D
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 03, 2013, 01:27:59 pm
kids are much more important!) i have the same situation today)

it will be nice to have simple tool to see your changes.
i have an intention to keep using my AVR version, etc. I will update it on your releases
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 03, 2013, 01:40:26 pm
luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand",
                 {sensorId="2", variableId="VAR_1", value="500"},
                 71)

is my understanding right that sensorID = radioID?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 03, 2013, 02:01:59 pm
is my understanding right that sensorID = radioID?

Yes. Should probably rename that parameter.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 04, 2013, 06:06:01 am
done! my simplest and stateless clock was installed
i think it is the first stateless but always correct clock for the house
no battery inside, power is supplied only while light is on (it is in a bathroom)

http://www.youtube.com/watch?v=-3a9ePBjax8

temperature and light sensosrs are represented in vera in real time
http://forum.easyelectronics.ru/download/file.php?id=16742&t=1

hek what i see that it will be nice to have LastUpdated field filed automatically for sensors update
now it is unknown is the measurement is up to date?

in example with my clock two sensors will be updated only while light in bathroom is on
the rest of the time sensors will be shown but it will be hard no know is it current measurement or the last one a few hours ago
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 04, 2013, 06:21:22 am
done! my simplest and stateless clock was installed
i think it is the first stateless but always correct clock for the house
no battery inside, power is supplied only while light is on (it is in a bathroom)

http://www.youtube.com/watch?v=-3a9ePBjax8
Really nice!



hek what i see that it will be nice to have LastUpdated field filed automatically for sensors update
now it is unknown is the measurement is up to date?

Good idea.. I'll add it to the list.
[/quote]

Solved the timezone problem yesterday evening but I have not checked in any code... Was in the middle of some refactoring so some example sketches won't compile right now. It's my sisters wedding this weekend.. hope to get some coding-quality-time on sunday.  ;D
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on October 04, 2013, 07:53:50 am
@axill realy nice!

Only thing you could have done to make it nicer is to hide the antenna inside the clock enclosure.

Br,
Tomas
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 04, 2013, 08:09:25 am
@axill realy nice!

Only thing you could have done to make it nicer is to hide the antenna inside the clock enclosure.
Tomas thanks
pa+lna+antenna module was selected just "to be sure"
but it seams I can downgrade it to simple nrf24 module without antenna
probably will do it later, not now (want to proceed with other things)
because of compact design the module was soldered to pcb and replacement need disablement and re-solder

my contribution to the project )) http://www.thingiverse.com/thing:160569
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 04, 2013, 10:45:51 am
So doing some more research and deciding on what type of arduino boards to buy (3v3 or 5 modules), I wanted to look at powering them via battery. I found that a buck boost converter would probably be ideal as it will allow for a batter back to either boost or step down the voltage depending on the output of the battery back while maintaining the voltage output. I found this from another site regarding powering a raspberry pi:

http://www.pololu.com/catalog/product/2118

It allows to adjust the output voltage from 2.5 to 8v with an input voltage of 2.7 to 11.8v. You adjust the voltage using the pot on the board. It is very tiny and the cost is not too shabby. Yes, it will drive up the coast of the sensors a bit, but I guess that is the price to pay for operating on battery power. They also offer 3.3v and 5v models. There are other companies and ebay sellers who offer similar options, but this is by far the smallest I have seen. They are located in the US.

I am still doing my research for operating on battery. But I want to place my order for the parts to make up the sensors. I'll post more info as I find it.

@hek,

Any consideration to using the RF24Network library to use the mesh networking abilities?

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 04, 2013, 02:09:03 pm
So doing some more research and deciding on what type of arduino boards to buy (3v3 or 5 modules), I wanted to look at powering them via battery. I found that a buck boost converter would probably be ideal as it will allow for a batter back to either boost or step down the voltage depending on the output of the battery back while maintaining the voltage output. I found this from another site regarding powering a raspberry pi:

http://www.pololu.com/catalog/product/2118
Looks nice. I haven't seen anything like it on aliexpress.

@hek,
Any consideration to using the RF24Network library to use the mesh networking abilities?

Yes, I've considered it. It got some nice features. But you have to give nodes specific numbers based on topology. This is somewhat confusing if you ask me (and probably other non techie users). It also effectively stops the auto-id feature. RF24 have a quite big header eating up message length. We will also lose my planned feature to reconfigure some stuff from vera side.

But the way RF24 works each nodes number also contains its route. Pretty smart. Still humming and thinking of the smartest way to go about all this routing. A bit messy to test also.

The RF24 chip can listen to 6 pipes simultaneously which is why RF24network nodes look like they do.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 04, 2013, 02:20:04 pm
I also worry on loosing simplified way as it goes now (like auto ID etc.). I already mentioned that in my opinion RF24Network is not well fitting.

 hek please take a look (when possible :)) to my proposal early in the thread (you will no miss my longest post :))
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 04, 2013, 08:55:12 pm
hek
i debugging my device with 11 children
is it an expected behavior that on each program start the only one single device (child) is created in vera?
i had to reset my application 11 times before i get all children ready

definitely none-blocking waitMessage is needed.

if I present S_VCONTAINER no device is created for this child. Is it designed so?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 05, 2013, 02:59:37 am
@axill
Yes. Its a bit messy to cerate devices in vera.  This way the gateway does not need to keep any information. This might change in the future. 11 child devices... some kind of record!

You should not use S_VCONTAINER (removed on vera side but fortgot it in vera.h). You can set variables to any child device instead.

In the next version a "parent" will be created for each node (even non-relaying ones) that can hold this type of "global" info (like battery level, library version used, relay info and maybe signal strength to other nodes).
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 05, 2013, 03:42:10 am
I'm doing currently the counter - it counts hot&cold water flow + measure temperature of both tubes + it sense alert from water leakage protection system and also allow to force valve close on vacation. In total 4 inputs (motion sensors), 5 outputs (will use relays), 2 temperature sensors, battery  info, and at last most important - two counts, i use 32 bits unsigned

I need to reflect counts visually in vera. If i will put them inside other sensors it will be tricky to check them. Why not to create vcontainer? I expect a few other application with a need to reflect visually some data.
I've tryed to change myself a device file to vcontainer and after that arduino gw stop responding :)
Had to remove the child
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 05, 2013, 05:17:51 am
Hek one suggestion on Vera.cpp
You use constant as address to store radio id.
It can create conflict with application storage
It is a nice mechanism in AVR toolchain which should work on arduino too

After #include <avr/eeprom.h> you can add EEMEM atribute to any variable:
uint8_t vera_radio_id EEMEM;

After that instead of your constant you can use &vera_radio_id instead.
In case of one single eeprom variable in the sketch it will be evaluated to 0
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 05, 2013, 03:49:14 pm
doing my application i'm thinking that waitForVeraMessage need to be replaced for none blocking interface
otherwise more or less serious application will be hard to design

i suggest to use the idea of the interface of RF24Network - the update function.

this function like waitForVeraMessage can run though all available messages skipping ones addressed to someone else (addressed to GW?)
this function should return NONE - no message available
SOME - there is a message to take care by this node
getMessage can be used to act on SOME result and it can be whatever (variable came, relay status change request or time received)

temporary i decided to use S_Distance to visually reflect my water counts. I will have to create two of them.
is it hard to create an universal device like vcontainer to show some (3-10) variables?
it should be much simpler than VCONTAINER, no need to have field editor.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 05, 2013, 04:17:45 pm
Another forum member and I were discussing this plugin via pm. Is there any possibility to have this plugin work over IP for the gateway?

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 05, 2013, 04:19:53 pm
i can be probably wrong but plugin designed to work on IP will be actually another plugin etc. very different
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 05, 2013, 04:53:13 pm
I do not think it would require a whole lot of changes, we can do something similar to what the DSC Plugin uses for the 2DS and the 3DS. We create an ip interface similar to the serial interface over IP for the vera gateway. It would connect over ip and the serial output would be pretty much the same. What do you think hek?

Have a look at the initializeIO function here:

http://code.mios.com/trac/mios_dscalarmpanel/browser/trunk/I_DSCAlarmPanel1.xml

Also see here for the info on luup.io:

http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#Module:_io

I should be placing my order for parts very soon. Need to finalize some things and I'll add an ethernet module to the purchase.

Depending on the ethernet shield you use, I was looking at the ENC28j60 ethernet shield here:

http://www.ebay.com/itm/170929813328

Library with tcp server:

https://github.com/ntruchsess/arduino_uip

There are other libraries out there as well.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 05, 2013, 06:50:18 pm
garrettwp I think it is already a time to join forces))
as you away on ho to setup ip interface - take it to deliver.

hek
just succeed to replace receiving time using blocking waitForVeraMessage by none blocking checkForVeraMessage.
it is plain C but not that far to understand the idea for C++:

Code: [Select]
uint8_t VeraAVR_checkForVeraMessage() {
uint8_t done = 0;
nrf24_startListening();
VeraAVR_delay_ms(100);
while (nrf24_available()) {
VeraAVR_getMessage();
// Check that message was addressed for me. Could be a message from some other sensor
// as we?re automatically listening to pipe 0 (our writing pipe)
if (_veraavr_data.msg.radioId == 0){
done = 1;
break;
}
}
nrf24_stopListening();
return done;
}

message_s VeraAVR_retrieveMessage() {
return _veraavr_data.msg;
}

such a way i can request time separately:
Code: [Select]
if(!sync_timer) {
VeraAVR_requestStatus(0, V_TIME);
sync_timer = 5;
}

and later check for any kind of a message:

Code: [Select]
if(VeraAVR_checkForVeraMessage()) {

axlib_timer_blink_radio_run(5, 5);
message_s message = VeraAVR_retrieveMessage();

if (message.messageType == M_VARIABLE && message.type == V_TIME)  {
unsigned long time = atol(message.data) + 3600 * 4;
uint8_t hour, minute, second, day, month;
uint16_t year;

axlib_time_convert(time, &hour, &minute, &second);
axlib_date_convert(time, &day, &month, &year);

cli();
clock_hour = hour;
clock_minute = minute;
clock_second = second;
clock_day = day;
clock_month = month;
clock_year = year;
sei();

sync_timer = CLOCK_UPDATE_MIN; // next update in minutes
       }
}

relays are also perfect to use none blocking
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 06, 2013, 01:10:16 am
Some additional info. If you consider allowing for the plugin to work over ethernet. You'll have to make some modifications with the libraries in use. The reason for this is to allow both the nrf24l01 and an ethernet module to work as they both use the spi interface. A port of the RF24 library located here:

https://github.com/andykarpov/iBoardRF24

Allows you to set which pins are connected to the NRF24 module so you can hook up an ethernet shield or another module that uses the spi interface.

So if you use an ENC28J60 module you can use this library:

https://github.com/jcw/ethercard

So you would set the NRF Radio like this:

// Set up nRF24L01 radio
iBoardRF24 radio(3,8,5,6,7,2);

3 = ce, 8 = cs, 5 = mosi, 6 = miso, 7 = sck, 2 = irq (not normally used)

For the Ethercard library, you should modify the enc28j60.h and change lines 25 and 41 where is says csPin = 8 to csPin = 10. As it will clash with the iBoardRF24 settings or just change 8 to 10 for the radio(3,10,5,6,7,2);. You can use any of the digital pins for the iBoardRF24 library.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 06, 2013, 02:12:11 am
Correct hardware with correct drivers can work simultaneously on the same SPI bus.
Maniacbug mentioned that

Before switching to this project i had some success using mega 2560 + arduino ethernet + Nrf24l01+
Using standard Ethernet and RF24 libraries  - you can select this hardware too

I do not recommend you to use ENC28J60, better to use wiznet5100 (arduino ethernet shield is based on it). By the references applications using wiznet are much more robust
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 06, 2013, 05:17:18 am
Maniacbug mentioned in his blog that he used both the ENC28j60 and the NRF24l01 with out issue. He also used the EtherCard library that I posted above. The iBoardRF24 library which is a port of Maniacbug RF24 library allows you to set the pins so they run separate from each other.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 06, 2013, 05:30:01 am
I knew this library, it uses software spi instead of hardware
It is a rare reason to switch to software driver
Sure you free to choose it

As i understant enc28j60 is required more things to do by mcu like wiznet requires less
It is only the reason for applucation with wiznet to be more relaeble
But sure both can work
28j60 is designed to be less costly
About a dollar or a few as a difference is critical difference for enterprise but while you are doing for yourself i think it is resonable to choose the better one
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: FireBird on October 06, 2013, 09:26:20 am
Just wanted to say thanks again Hek for all your work on this! I received all the parts this week (shipped via sellers from Amazon Prime) not China. Everything works great because of your instructions on what to buy and step-by step on how to setup the hardware. (I'm new to Arduino). Without this cheaper option I would have never been able to monitor so many temperatures around the house.

So far I'm logging:

1. water heater outlet temperature
2. water heater exhaust flue pipe temperature (for heating times)
3. Deep freezer (great for alarming if freezer fails)
4. Attic temperature
5. Basement temperature

I'm only using 1 wireless Arduino to get all of these temperatures because it's located in the basement and I just ran Cat5 to each location. The Ardunio sensor is also powered by a 5 volt cell phone a/c  wall adapter. I'm using the Nano for both the gateway and the sensor, in the future I may use the cheaper Ardunio boards like Hek suggests.

I also plan on testing some battery powered sensors in the future, for pool water temperatures and inside my refrigerator.

I was worried about using the Arduino gateway with my current USB Hub on the Vera. USB stick for datamine, USB to serial for my alarm system, and now the Ardunio gateway. But so far everything works great after messing with the serial port settings on the Vera.

A few examples below....

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on October 06, 2013, 11:28:58 am
I don't know if this is possible ,would it be possible  to add a temperature sensor to the Arduino that is being used for the Gateway thats hooked to my Vera. Maybe create sensors in Vera based on the Gateway Arduino also.
Can this be done ?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 06, 2013, 12:45:09 pm
I don't know if this is possible ,would it be possible  to add a temperature sensor to the Arduino that is being used for the Gateway thats hooked to my Vera. Maybe create sensors in Vera based on the Gateway Arduino also.
Can this be done ?
sure this can be done, why not?
You can take a look to ArduinoGateway sketch, it is quite simple, you will need to combine it with DallasTemperatureSensor and make virtual node talking to GW without radio.

It is if you are going to use ds18b20 sensors. But you should be aware that usually this sensor requires 750ms to finalize each measurement at 12bit resolution and if your GW will be block waiting the sensor it will be not responding to both Vera and radio nodes.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on October 06, 2013, 01:12:03 pm
@axill
Thanks for the info. I will look into the code more and see what I can learn. Just wanted to know before I spend alot of time trying to do something that is not possible. In the past I've just used a 10k Thermistor to measure temp, so I don't know if I would use the ds18b20 or not. Maybe you could provide some sample code to create a virtual node to get me started.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 06, 2013, 01:52:15 pm
jackpot

using thermistor will be even simpler - just read it using analogRead();
example of virtual node for Arduino GW does not exist because nobody wrote it.
You can be the author )

Take a look at loop function. inside first if GW is receiving data from radio nodes and sending (printing to serial) to Vera.
You should put your sensor reading somewhere in the loop and as soon as you want to send data you will need to print message to serial in the same way sensors.printMessage() is doing.

Also you will need to present your virtual node once at GW startup like radio nodes are doing using vera.sendSensorPresentation:
Code: [Select]
vera.sendSensorPresentation(0, S_TEMP);
Code: [Select]
void loop() 
{   
  if (sensors.available()){
    // A new message was received from one of the sensors
    // Pass along the message to vera
    sensors.printMessage();
  }
  if (commandComplete) {
    // A command wass issued on vera side
    // We will now try to send it to the actuator
    commandComplete = false; 
    sensors.sendActuatorCommand(inputString);
    // clear the string:
    inputString = "";
  }
}
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 06, 2013, 02:18:17 pm
@hi all
Back behind a keyboard. Lots of activity in this thread now! Thats great. I'll read through and get back with some answers.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on October 06, 2013, 02:28:31 pm
@axill
Thankyou again ! It sure helps when someone like you gives us a starting point.
I'm all over it now ! ;D
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 06, 2013, 02:41:56 pm


After #include <avr/eeprom.h> you can add EEMEM atribute to any variable:
uint8_t vera_radio_id EEMEM;

After that instead of your constant you can use &vera_radio_id instead.
In case of one single eeprom variable in the sketch it will be evaluated to 0

Cool. Added to list.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 06, 2013, 03:14:52 pm
@Garrett
Can you please explain how you'd like to use it?

Like this:
Vera (plugin) -> IP-> Arduino with ip-shield and sensors connected.  (bypassing serial usb arduino)

So... should the plugin keep connections open for all ip-arduinos? Or just for one?

I'm planning to implement pretty radio specific stuff in the vera plugin (and library) ... all this is pretty pointless for an ethernet setup.

But maybe i'm missing the point ;)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 06, 2013, 03:20:08 pm
@hek
some consistency check is needed
I'm having some problems with my new device now and I can see a lot of garbage arduino gw is trying to execute from it.
in the future same can happen for example if you will forgot to migrate to a new data structure one of your devices.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: martinholmin on October 06, 2013, 03:43:56 pm
@hek

This looks really awesome! One again you have got me hooked on a new project :) . Arduinos and a bunch of different sensors ordered from China.

/M
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 06, 2013, 04:19:04 pm
Hi martin! Yes, this is fun!

@axill
One option could be to refuse messages from sent sensors with the wrong or older version. Since 1.2 all nodes report the library version they use. But that will only help if message format is constant.

Unfortunately I will still need to make small adjustments to the message format to cope with relaying.  Hopefully these changes will be fewer as the plugin/library matures.

Make sure to have your sensors accessible (no mounting behind drywalls!) for some more time ;)

Unfortunately I think OTA updates is impossible.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 06, 2013, 04:40:19 pm
hek
it is important to have the core of the message structure is fixed.
for any specific task data should came into .data field part and exactly this part can be under development in the future
sure relaying have to be reflected in the core

take a look at my proposals early - probably you will do not need additional space for relaying in each message

sometimes devices have to be hidden somewhere deep inside :) For some of my zwave staff it is even hard to press inclusion button. I cannot imagine how i will behave if will have to upgrade their firmware )

I still think that wireless upgrade is possible in the future. This why it will be nice to have Vera class not sticked to RF24 but having an abstraction layer between.
We had quite a deep discussion with mitekdg on how this can be archived. Currently we have:

arduino ->(spi)-> nrf24l01+ module -> (2.4Ggz base radio) -> (other parties)

most reliable solution can be like this:

arduino ->(spi, ISP)->[special module with nrf24 chip on board + mcu] -> (other parties)
or
arduino ->(UART/Serial, Reset)->[special module with nrf24 chip on board + mcu] -> (other parties)

special module can be build on 4-8k atmega with a special firmware which will assume only wired upgrade.
it will not only provide radio future to arduino but also will act as a bridge between PC mcu programming software (like avrdude) and a node.
This way arduino will have to run specially designed library interfacing to module instead of RF24.

interface between arduino and module can be SPI+ISP (etc. SPI + Reset pin) or Serial with programming using arduino bootloader

instead of atmega+nrf24 it can be nrf24LE01 which contains MCU and radio in one single chip

It is sure not for now because will require some research. But it can be a possible future of plugin we are talking now.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 06, 2013, 04:54:51 pm
I will have to add 1 byte (from/to) so receiving node know where message came from. If nodes starts sending messages between themselves (without involving gateway) this information is handy if nodes need to communicate back to sender.

Code: [Select]
typedef struct {
  uint8_t from;      // 1 byte. RadioId of sender node
  uint8_t to;                         // 1 byte. RadioId of destination node
  uint8_t childId           : 4;    // 4 bits. Up to 128 child sensors per radioId
  uint8_t messageType : 4;    // 4 bits. Type of message. See messageType
  uint8_t type;                   // 1 byte. variableType or deviceType depending on messageType
  char data[MSG_MAX_PAYLOAD_SIZE+1];  // Each message can transfer a payload of 29 bytes. Add one extra byte for \0
} message_s;
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 06, 2013, 04:57:15 pm
looks reasonable
just for the reference please see my structure i used before came here:

Code: [Select]
// basic network message structure, it is common to all network messages
struct axill_network_message {
unsigned char version; // 01 | version of the format
unsigned char data_type; // 01 | type of data in data[]
unsigned char control; // 01 | is used to be sure that message of right format
unsigned char to_addr[3]; // 03 | receiver address
unsigned char from_addr[3]; // 03 | transmitter address
unsigned char throuth_addr[3]; // 03 | address of a node though which we are sending message
unsigned char data[20]; // 20 | data to be send
};

control i thought should contain a function to check a consistency on receiving side
version - can be version of library or separate version of data format
probably control + version can fit into single byte

for address i used 3 byte format assuming that whole network in their 40 bit address have 16 bits common and 24 unique. Or probably in e future it will allow to have domains and sub domains.

in your case you assume that 32 bits will be common for the network while 8 bits are unique. May be it is a right time to increase to 16 unique bits? sure it will be a cost of data section but ... If you remember X10 devices they have just 16 unique addresses space. 10 years ago some one decided that it is sufficient for the automation. Today we increased 4 bits to 8. But... I hardly can imagine how to brake 16 bit address space restriction and to imagine the same for 8 bit is much much more easy.

if not 16 bits than may be 10 or 12?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 06, 2013, 05:17:54 pm
I have thought about another idea which could actually result in 0-configuration for finding relay nodes.

When a node (42) wakes up it sends out an "PING"-message to pipe 0.

Today all nodes listen to pipe 0. So all (relay)nodes in range will receive the "PING" message from 42. They all send a "PING"-message back to node 42 which then can store this info in an relay table. Node 42 should of cause prioritize sending messages directly to 0 (GATEWAY) if that is in range.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 06, 2013, 05:38:26 pm
can be a good idea
it will be a "self healing" instead of "managed healing" in zwave
for simplicity it is very good

"just in range" can be not that sufficient

what about using one or a combination of:
1 result of testRDP (better to look at RF24 scanner example)
2 number of retries radio chip did to reach particular relay
3 why not having a series of messages:
  - node broadcast to all
  - node get list of someone in range
  - node circle the list by sending ping to particular relay to understand 1 and 2
  - relay probably also can remember last testRDP and retries it uses to send reply to first PING and will present this data to node

this way we can be more precise on setting priorities

also i'm wondering on having any kind of a future to change channel network wide.
probably it is already a good idea to have BASIC network ID + channel taken from EEPROM

for this purpose a special "mobile" arduino with radio can be a solution.
as soon as you will decide to change a channel you can walk across your house with this arduino running a sketch which will present a special channel change command cycling through all 128 channels - assuming that we will be sure to update channel for any device running on any channel.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 06, 2013, 05:50:56 pm
Of cause I looked at the scanner example. I was hoping to find some signal strength thingie but the chip does not seem to expose this type of info.
 
We could probably fine tune the mechanism... But its a good start to have the sensor network build up on itself. 

Also note that after ping from node 42 a relay will then also know that node 42 is in range and can relay messages there. It should report this information back to vera and also keep it in memory as a direct route.
 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 06, 2013, 05:55:45 pm
Of cause I looked at the scanner example. I was hoping to find some signal strength thingie but the chip does not seem to expose this type of info.
what is missed in scanner example is a check on number of retries.
i got this idea from other nrf24 library.
i'm not sure RF24 provides access to this data but I can retrieve required code from library I mentioned.
maximum we have 15 retries, so we can have an indication from 0 to 15 + one bit of information derived from testRDP()
should be sufficient

Quote

We could probably fine tune the mechanism... But its a good start to have the sensor network build up on itself. 

Also note that after ping from node 42 a relay will then also know that node 42 is in range and can relay messages there. It should report this information back to vera and also keep it in memory as a direct route.
do you assume some kind of a neighbor list attached to vera device like zwave engine do?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 06, 2013, 06:05:04 pm

do you assume some kind of a neighbor list attached to vera device like zwave engine do?

Yes, that is the plan. From this neighbor list (of all arduino node devices) vera plugin can calculate one or many possible routes to a node.
And like you proposed hint the sensors by sending a special route message before the actual message (if needed).
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 06, 2013, 06:37:12 pm
want to share something about battery powered sensors

from other forum i got a guy with successful experience on running sensors directly from single cell lipo (working voltage from 2.5 to 4.2V)
to prevent nrf24 chip from damage it is powered through 1-2 diodes
arduino fuses changed to use internal oscillator at 8mgz  - this allows any arduino with atmega328p to run from 2.7 to 5.5V
similar result can be archived using 3 cell alkaline batteries - running voltage is from 3.3-4.95V through discharge circle, MCU can be powered directly, nrf24 will require LDO
similar also with 3 cell of ni-mh batteries with running voltage 3-3.6V, both mcu and radio chip can be powered directly

i also put here an example from the thread i mentioned (thread is in russian http://arduino.ru/forum/proekty/bolshie-chasy-pogodnaya-stantsiya).
what is interesting is that to save power a deep power down mode is used and watch dog timer is used to wake sensor up for the job periodically
some comments inside are in russian but fill free to ask me for translation/explanation

it was mentioned in the thread that consumption in sleeping circle is about 90uA, running 2mA.
I don think that using any step-up/step-down you will archive such a performance

Code: [Select]
001 #include <SPI.h>
002 #include "nRF24L01.h"
003 #include "RF24.h"
004 #include <avr/sleep.h>
005 #include <avr/wdt.h>
006 #include <Wire.h>
007 #include <OneWire.h>
008 #include <DallasTemperature.h>
009 #define ONE_WIRE_BUS 3
010 OneWire oneWire(ONE_WIRE_BUS);
011 DallasTemperature sensors(&oneWire);
012
013 int count;    //переменная для счётчика циклов
014
015 volatile boolean wdt_tripped=1;
016
017 RF24 radio(8,7);
018 const uint64_t pipes[2] = {
019   0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
020
021 //создаём структуру для передачи значений
022 typedef struct{       
023   int W;
024   int X;
025   float Y;
026   int Z;
027   long U;
028 }
029 B_t;
030 B_t duino2;
031
032 //режим сна для МК
033 void system_sleep(byte t) {
034   delay(2);                            // Wait for serial traffic
035   _SFR_BYTE(ADCSRA) &= ~_BV(ADEN);     // Switch ADC off
036   set_sleep_mode(SLEEP_MODE_PWR_DOWN);
037   sleep_enable();
038   sleep_mode();                        // System sleeps here
039   sleep_disable();
040   _SFR_BYTE(ADCSRA) |= _BV(ADEN);      // Switch ADC on
041 }
042
043 void wdt_interrupt_mode() {
044   wdt_reset();
045   WDTCSR |= _BV(WDIE); // Restore WDT interrupt mode
046 }
047
048 ISR(WDT_vect) {
049   wdt_tripped=1;  // set global volatile variable
050 }
051
052
053 void setup()
054 {
055   wdt_disable();
056   wdt_reset();
057   wdt_enable(WDTO_8S);   //пробуждение каждые 8 сек
058   count = 0;
059    
060   pinMode(2, OUTPUT); //Пин на который подключено питание радио модуля
061   digitalWrite(2,HIGH);
062
063   sensors.begin();
064   sensors.setWaitForConversion(false); //Без ожидания конверсии температуры
065   sensors.requestTemperatures();  //Запросить температуру
066   delay(1000); // Подождать первой конверсии
067 }
068
069 void loop(void)
070 {
071   wdt_interrupt_mode();
072   if (wdt_tripped)
073   {
074     count++;
075     wdt_tripped = 0;
076     if (count == 3) //тут можно увеличить интервал времени между отправками данных по RF24 за счёт счётчика циклов 8*3
077     {
078       count = 0;
079       float t = sensors.getTempCByIndex(0); //Читаем температуру
080       sensors.requestTemperatures(); //Запрашиваем подготовку температуры для следующего раза
081       //записываем в структуру данные для передачи
082       duino2.W = 11;  // этот номер передатчика для идентификации в принятом пакете данных
083       duino2.X = getBandgap ();  // передаём напряжение батареи
084       duino2.Y = t;    // передаём температуру
085       duino2.Z = (int)(1.48* analogRead(A2));   // Солнышко - читаем освещенность солнечной батареи
086       duino2.U++;      // счетчик передач используется для контроля качества канала
087  
088       digitalWrite(2,HIGH); //подаём питание на NRF24, затем готовим канал
089       radio.begin();
090       radio.setRetries(10,15);
091       radio.openWritingPipe(pipes[0]);
092       radio.powerUp();
093       radio.stopListening(); // отключаем режим приёма
094
095       bool ok = radio.write( &duino2, sizeof(duino2) ); //отправляем данные по RF24
096       delay (20);
097       radio.powerDown(); // гасим штатно RF24
098       digitalWrite(2,LOW); // отключаем питание RF24
099     }
100   }
101   system_sleep(WDTO_8S);   //МК засыпает
102 }
103
104 //внутренний контроль напряжения на батарее
105 const long InternalReferenceVoltage = 1062;
106 int getBandgap ()
107 {
108   // REFS0 : Selects AVcc external reference
109   // MUX3 MUX2 MUX1 : Selects 1.1V (VBG)
110   ADMUX = _BV (REFS0) | _BV (MUX3) | _BV (MUX2) | _BV (MUX1);
111   ADCSRA |= _BV( ADSC );  // start conversion
112   while (ADCSRA & _BV (ADSC))
113   {
114   }  // wait for conversion to complete
115   int results = (((InternalReferenceVoltage * 1024) / ADC) + 5) / 10;
116   return results;
117 } // end of getBandgap
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 06, 2013, 08:04:15 pm
hek
may be bug?

i spend plenty of time trying to understand how my node is producing a garbage like this:
Code: [Select]
01 10/07/13 3:57:35.666 luup_log:71: Arduino plugin: 3;5;0;1;1.2 <0x322eb680>
06 10/07/13 3:57:35.667 Device_Variable::m_szValue_set device: 204 service: urn:upnp-org:serviceId:VContainer1 variable: ArduinoLibVersion was: 1.2 now: 1.2 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x322eb680>
50 10/07/13 3:57:40.644 luup_log:71: Arduino plugin: Sending command: 3;10;2;0 <0x30e70680>
50 10/07/13 3:57:51.578 luup_log:71: Arduino plugin: Sending command: 3;10;2;1 <0x320eb680>
01 10/07/13 3:57:51.656 luup_log:71: Arduino plugin: 54;6;3;54;66666662 <0x322eb680>
01 10/07/13 3:57:51.666 luup_log:71: Arduino plugin: 54;6;3;54;66666662 <0x322eb680>
01 10/07/13 3:57:51.667 luup_log:71: Arduino plugin: 54;6;3;54;66666662 <0x322eb680>
01 10/07/13 3:57:51.676 luup_log:71: Arduino plugin: 54;6;3;54;66666662 <0x322eb680>
01 10/07/13 3:57:51.678 luup_log:71: Arduino plugin: 54;6;3;54;66666662 <0x322eb680>
01 10/07/13 3:57:51.685 luup_log:71: Arduino plugin: 54;6;3;54;66666662 <0x322eb680>
01 10/07/13 3:57:51.695 luup_log:71: Arduino plugin: 54;6;3;54;66666662 <0x322eb680>
01 10/07/13 3:58:05.726 luup_log:71: Arduino plugin: 3;6;0;3;1.2 <0x322eb680>
06 10/07/13 3:58:05.726 Device_Variable::m_szValue_set device: 205 service: urn:upnp-org:serviceId:VContainer1 variable: ArduinoLibVersion was: 1.2 now: 1.2 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x322eb680>

i do have only nodes 2 & 3, I do not have node 54. Some time i can see all zeroes in the log like "0;0;0;0;0".
I thought that my node is issuing this to radio.
Later I found that if I get rid of any radio.startListening() this garbage will disappear.
It seams that garbage is generated by this peace of Vera::sendActuatorCommand on a GW side

Code: [Select]
if (ok) {
// Send acc ok back to vera (to update GUI)
printVeraMessage(sensorRadioId, childId, M_VARIABLE, type,  value);
}

as i see you try to update status of the switch inside vera based on at a fact that message send somewhere regardless that it is received and executed. Why not letting node to respond about actual status change? The following code is working right for my 5 output channels node:
Code: [Select]
} else if(message.messageType == M_VARIABLE && message.type == V_LIGHT) {
uint8_t relay = atoi(message.data);
//axlib_timer_blink_buzzer_run(1, 1);
if(message.childId == child_out1) { if(relay) { out1On(); } else {out1Off(); } }
if(message.childId == child_out2) { if(relay) { out2On(); } else {out2Off(); } }
if(message.childId == child_out3) { if(relay) { out3On(); } else {out3Off(); } }
if(message.childId == child_out4) { if(relay) { out4On(); } else {out4Off(); } }
if(message.childId == child_out5) { if(relay) { out5On(); } else {out5Off(); } }
VeraAVR_sendVariable_int(message.childId, V_LIGHT, (relay)?1:0);
show_timer = 0;
}
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 06, 2013, 08:42:52 pm
I can tell you that plugin is so good that even complicated devices is true to be efficient))
I hope I'm finished with my next device
device is designed to do a job:
- count water flow from hot and cold flow meters. this will be reported to vera, currently as distance devices
- measure temperature on both tubes (not really needed but it zero cost)
- integrates with leakage protections system in two way - alarm to vera, valve close command back from vera
- additional inputs and outputs, in total two opto-isolated inputs, 2 opto-isolated and 3 relays outputs

it also has backup battery to keep count water flow and it reports battery to vera
Yes! it also run stateless clock as in my previous device

what is male me happy is how reliable is integration - data flows instantly from vera to device and vise versa
 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: RichardTSchaefer on October 06, 2013, 10:53:05 pm
Quote
- integrates with leakage protections system in two way - alarm to vera, valve close command back from vera

What is your leakage protection system ? Any flow while away ?

This should work with pulse based energy meters as well.
Might be nice to have a scaling factor into meaning full units done by the device as well. So display would be liters or gallons or kw.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 07, 2013, 12:07:32 am
@Garrett
Can you please explain how you'd like to use it?

Like this:
Vera (plugin) -> IP-> Arduino with ip-shield and sensors connected.  (bypassing serial usb arduino)

So... should the plugin keep connections open for all ip-arduinos? Or just for one?

I'm planning to implement pretty radio specific stuff in the vera plugin (and library) ... all this is pretty pointless for an ethernet setup.

But maybe i'm missing the point ;)

Hek,

It would be used for the gateway. So instead of using the usb port for the gateway for the serial interface, the ethernet interface would be the connection between vera and the arduino gateway.

Vera (plugin) -> IP -> Arduino Gateway

The vera plugin would create a connection to the gateway via ip just like the serial interface. The input and output can be pretty much the same as you would do for the serial connection.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 07, 2013, 12:10:54 am
want to share something about battery powered sensors

from other forum i got a guy with successful experience on running sensors directly from single cell lipo (working voltage from 2.5 to 4.2V)
to prevent nrf24 chip from damage it is powered through 1-2 diodes
arduino fuses changed to use internal oscillator at 8mgz  - this allows any arduino with atmega328p to run from 2.7 to 5.5V
similar result can be archived using 3 cell alkaline batteries - running voltage is from 3.3-4.95V through discharge circle, MCU can be powered directly, nrf24 will require LDO
similar also with 3 cell of ni-mh batteries with running voltage 3-3.6V, both mcu and radio chip can be powered directly

i also put here an example from the thread i mentioned (thread is in russian http://arduino.ru/forum/proekty/bolshie-chasy-pogodnaya-stantsiya).
what is interesting is that to save power a deep power down mode is used and watch dog timer is used to wake sensor up for the job periodically
some comments inside are in russian but fill free to ask me for translation/explanation

it was mentioned in the thread that consumption in sleeping circle is about 90uA, running 2mA.
I don think that using any step-up/step-down you will archive such a performance

I purchased the Pololu Adjustable Step-Up/Step-Down Voltage Regulator here:

http://www.pololu.com/catalog/product/2118

The reason for this is that I can use any battery pack from 2.7 to 11.8V and adjust the voltage depending on arduino board I am using. In this case it will be the arduino pro mini 3v3 model. I'd rather use a power source that will provide a constant power.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 07, 2013, 12:24:54 am
Hek,

A suggestion for updating the variables in the Vera plugin. To avoid updating a value of the plugin or any of the child devices where the value has not actually changed you can use something like this:

Code: [Select]
--
-- Update variable if changed
-- Return true if changed or false if no change
--
function setVariableIfChanged(serviceId, name, value, deviceId)
    local curValue = luup.variable_get(serviceId, name, deviceId)
   
    if ((value ~= curValue) or (curValue == nil)) then
        luup.variable_set(serviceId, name, value, deviceId)
        return true
       
    else
        return false
       
    end
end

You would use this function to set all of the variables. This prevents vera from making unneeded calls and have her act on a variable value that has not changed.  For example events, etc. This code was taking from the DSC plugin which I tweaked. Other plugins use something similar and is considered to be good practice.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 07, 2013, 02:36:28 am
What is your leakage protection system ? Any flow while away ?
it is a special system mounted near main house valves. It requires to install special motor driven valves and to install water presence sensors.
Main valves will be closed on any water presence regardless away status. Sensors usually mounted in a place of most risky on leakage. Sensors can be wired or wireless. This systems has an integration connector which I use to source alarm signal and to be able to force valves be closed. I plan to close valves on vacation event (it is an event vera generates after preset number of hours after away status).
Quote
This should work with pulse based energy meters as well.
Might be nice to have a scaling factor into meaning full units done by the device as well. So display would be liters or gallons or kw.
sure nice to have an universal thing) i do not think it can directly measure energy but i'm sure that with hek's plugin any type of device can be attached to vera. I already have a device which controls my stove and oven, it has current sensors and i plan to reprogram it to be connected with Arduino GW. I think it will act also as energy meter.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: nullx8 on October 07, 2013, 02:51:52 am
I hope I'm finished with my next device


how much would you charge for a copy of that ? ;)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 07, 2013, 03:00:42 am
how much would you charge for a copy of that ? ;)
i can share all needed documents (circuit, PCB design, sketch and even 3d models for enclosure to be printed) free of charge.
Be prepared that  I'm using plain atmel chips, not in framework of arduino. I'm managing special port of hek's library for that.

But if you want me to assemble it for you it can be too expensive :) but if you see it is a commercial value we can organize business on this together :)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 07, 2013, 03:17:42 am
Hek,

You would use this function to set all of the variables. This prevents vera from making unneeded calls and have her act on a variable value that has not changed.  For example events, etc. This code was taking from the DSC plugin which I tweaked. Other plugins use something similar and is considered to be good practice.

- Garrett

Ok, changed this in the plugin.
Regarding ip-interface. If this only requires small changes in the plugin code. Then why not? I will have to finish up on the current development. I'll add this to 1.4 planning.


Here is the current list:

CHANGES 1.3

-- FINISHED (CHECHED IN TO TRUNK) --
* More debug info is printed to serial monitor in sensors.
* Nodes that receive messages from vera don't need to busy wait.
  See new example in RelayActuator sketch.
* Increased transfer speed (1MBPS) between radios.
* Sent time to sensors uses vera configured timezone
* Protocol change. from/to added in message header. This change
  requires sensors to update their library version.
* Vera library subclass of RF24 (like RF24network).
* Variables in vera only updated if changed.

-- PLANNED/UNDER IMPLEMENTATION --
* A device is created in vera for each physical arduino/radio
  This device will hold info about node, such as library version, battery info
  relay information, signal strength/neighbors
* Support for message relaying. All nodes can act as relay. This functionality can be
  used for communicating with sensors far away. An relay forwards messages
  between sensors and vera gateway. Multiple relays (message hops) are supported.
  See RelayNode sketch for an example how to create an relay node.
* LastUpdate
* Signal level/neighbors is calculated and sent to vera each time a sensor is started
* Send one message for registering all attached sensors (needs update on vera side) and a new
  library function. Each registration message can present up to 28 sensors.
* Support for setting channel in Vera gateway and sensor sketches. Probably EEMEM attribute
* Use the EEMEM attribute


PLANNED 1.4
* Support IP connection in vera plugin

BUGS that needs to be investigated/fixed
* Sometimes interrupted transmits from sensors was interpreted as a sensor
  presentation on vera side. Tried to fix this behavior by introducing
  a special message end token for presentation messages.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 07, 2013, 03:31:21 am
First part committed to trunk. Just for your info axill.

@all
DO NO USE THIS YET!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 07, 2013, 03:58:24 am
hek thanks a lot!
as always thanks for a great job!
looking forward for the release

why not using while instead of if?
Code: [Select]
boolean Vera::messageAvailable() {
    if (radio.available()) {

I see you decided to switch to 1mbit - is it because you agreed to implement relaying?
I dot not think communication speed is critical for home automation but 1mbit is preferable from power consumption of battery devices - it is benefit. But it also the disadvantage comparing to 250kbit - as higher speed as more retries will be used for delivery.

Please do not forget to add M_CUSTOM. What about switching to 10 or 12 or 16 bits address space for nodes?
It is so easy to run out of 256 nodes. If not tomorrow than in year or two

looking to sources got a question - why not to increase Serial speed in connection between vera and arduino?
57600 or even 115200 is not an issue for both vera and arduino
on a wide network it can be very important to have high throughput

What about using any kind of bug/features tracking?

Can I use something like "1.35" for Library version? It will distinguish AVR devices from arduino.

can anyone recommend a good tool for compare&merge sources? I will manage my copy of Vera.cpp in plain C for AVR.
I plan also to publish it, just need to understand the best place.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 07, 2013, 04:52:41 am
Hek,

You would use this function to set all of the variables. This prevents vera from making unneeded calls and have her act on a variable value that has not changed.  For example events, etc. This code was taking from the DSC plugin which I tweaked. Other plugins use something similar and is considered to be good practice.

- Garrett

Ok, changed this in the plugin.
Regarding ip-interface. If this only requires small changes in the plugin code. Then why not? I will have to finish up on the current development. I'll add this to 1.4 planning.


Here is the current list:

CHANGES 1.3

-- FINISHED (CHECHED IN TO TRUNK) --
* More debug info is printed to serial monitor in sensors.
* Nodes that receive messages from vera don't need to busy wait.
  See new example in RelayActuator sketch.
* Increased transfer speed (1MBPS) between radios.
* Sent time to sensors uses vera configured timezone
* Protocol change. from/to added in message header. This change
  requires sensors to update their library version.
* Vera library subclass of RF24 (like RF24network).
* Variables in vera only updated if changed.

-- PLANNED/UNDER IMPLEMENTATION --
* A device is created in vera for each physical arduino/radio
  This device will hold info about node, such as library version, battery info
  relay information, signal strength/neighbors
* Support for message relaying. All nodes can act as relay. This functionality can be
  used for communicating with sensors far away. An relay forwards messages
  between sensors and vera gateway. Multiple relays (message hops) are supported.
  See RelayNode sketch for an example how to create an relay node.
* LastUpdate
* Signal level/neighbors is calculated and sent to vera each time a sensor is started
* Send one message for registering all attached sensors (needs update on vera side) and a new
  library function. Each registration message can present up to 28 sensors.
* Support for setting channel in Vera gateway and sensor sketches. Probably EEMEM attribute
* Use the EEMEM attribute


PLANNED 1.4
* Support IP connection in vera plugin

BUGS that needs to be investigated/fixed
* Sometimes interrupted transmits from sensors was interpreted as a sensor
  presentation on vera side. Tried to fix this behavior by introducing
  a special message end token for presentation messages.

Hek,

I do not think it would require too much work. Where you are printing out to serial you would do the same for the ip interface, but using the functions intended for the ethernet library being used. I am placing my order for parts as we speak. I placed an order for a few pieces locally to get me started faster and will order a bulk of the parts from China (not sure how long that will take). I have a few Arduino Uno's and Megas available I can use to experiment with for the time being.

Looking forward to using this project and hopefully provide some assistance as well.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 07, 2013, 04:57:34 am
before switching to this project i did ethernet to nrf24 gateway based on mega and arduino ethernet shield
i'm equipped to test IP connection immediately if needed 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 07, 2013, 05:09:27 am
One of the reasons I ask for IP based gateway is that I do not have to have the arduino gateway next to vera and I can place it anywhere on my network. It would also give us another option for interfacing with Vera.

I also have an ethernet shield, but would like to find a more cost effective way to implement ethernet with the arduino as the shield is pretty expensive.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 07, 2013, 05:17:40 am
One of the reasons I ask for IP based gateway is that I do not have to have the arduino gateway next to vera and I can place it anywhere on my network. It would also give us another option for interfacing with Vera.
it is nice to have as an option

Quote
I also have an ethernet shield, but would like to find a more cost effective way to implement ethernet with the arduino as the shield is pretty expensive.
what do you think to use instead of ethernet shield?
mine costs me $10

it is also an option to use shield based on ENC28j60, it starts from $4, but I would prefer to use wiznet chip (arduino ethernet is based on it) because it is much more robust
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 07, 2013, 06:11:56 am
Axill,

Where did you get one for $10? That sounds more like my price. If we can setting on an network module, than that would make our library choice better and we can try and get work to get ip communication rolling.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 07, 2013, 06:18:42 am
Where did you get one for $10?
I like China)
It was a good price on byuincoins.com but now it is sold out.
I think similar prices should be on aliexpress
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 07, 2013, 06:57:49 am
I found this:

http://imall.iteadstudio.com/prototyping/basic-module/m120525007.html

A US supplier of this module robotshop.com stocks them, but they are not in stock at the moment. Ordering from itead, would be cheap if you used regular mail, but can get very expensive when ordering via DHL or UPS to another country.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 07, 2013, 07:03:30 am
I found this:

http://imall.iteadstudio.com/prototyping/basic-module/m120525007.html
excellent price!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 07, 2013, 01:31:31 pm
Now possible to place tickets for bugs/features

http://code.mios.com/trac/mios_arduino-sensor/newticket

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 07, 2013, 01:50:36 pm
I would like to open up the arduino-plugin-wiki for public modifications.. but i'm afraid this will render spam.

So.. if you want to help improving the documentation. Please ask @mcvflorin for an code.mios.com account and PM me to get wiki update rights.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: guessed on October 07, 2013, 02:36:31 pm
@hek,
The Ticket mechanism used to draw spam also.  Hopefully you won't see that.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on October 07, 2013, 02:47:37 pm
Hek - amazingly awesome project!!! Nice work and thank you!!!  Picked up a Veralite just two weeks ago and came across your project - perfect timing. I've began some testing and basically have everything working okay. Currently in the process of customizing your work to suit my home automation.

First part of my project is to build a "Wireless LCD Display Station" for the Veralite. The idea behind the display station is provide status of sensors around the house, so not having to use a computer or smartphone to get information - wife friendly interface. :-).

To start it will have the capability to display current time, climate inside/outside (temperature, humidity, pressure) and caller-id on a 16x2 LCD display. Additionally, the station will have LED's to indicate status of other senors around the house (i.e. garage dr, doorbell, motion, etc.).

BTW, I moved your "vera.requestStatus(CHILD_ID, V_TIME);" time code into a subroutine called "getTimeFunction" and now using time sync capabilities included as part of the standard Time library. Then I put the following code in void setup(). The time is resync'd every hour (or any interval) from Vera automatically.

 // Set time on Arduino
  setSyncProvider(getTimeFunction);  // Vera is time provider
  setSyncInterval(3600);  // get time from Vera every hour

Thanks again for all your work! Cheers!

Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 07, 2013, 03:27:04 pm
@axill
Do you really think anyone will have more than 255 radio nodes over the same channel?! I would probably plug in another arduino/radio over another channel if I ever exceeded 255 nodes.  BTW The vera would probably collapse before this ;)

 
@guessed
Thanks for the info. Will keep it under observation for a while.

@joe
Thanks! Nice little project you got going. Please post some pictures and thanks for sharing your improvements (will try to incorporate it).


I'm preparing moving the project to GIT so you can share your little example sketches and/or improvements a little easier. But when I switch the subversion repo will be wiped (if I understand it correctly).
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 07, 2013, 03:45:27 pm
First part of my project is to build a "Wireless LCD Display Station" for the Veralite. The idea behind the display station is provide status of sensors around the house, so not having to use a computer or smartphone to get information - wife friendly interface. :-).
Joe, while you have wifi why you need Arduino plugin? You can use Vera API to get all the information including current time for your display.
Arduino GW is needed for wifi less nrf24 radio enabled devices.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 07, 2013, 03:56:59 pm
@axill
Do you really think anyone will have more than 255 radio nodes over the same channel?! I would probably plug in another arduino/radio over another channel if I ever exceeded 255 nodes.  BTW The vera would probably collapse before this ;)
@hek at least 2 additional bits will be good :) Vera i hope will continue be upgrading.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on October 07, 2013, 04:06:39 pm
First part of my project is to build a "Wireless LCD Display Station" for the Veralite. The idea behind the display station is provide status of sensors around the house, so not having to use a computer or smartphone to get information - wife friendly interface. :-).
Joe, while you have wifi why you need Arduino plugin? You can use Vera API to get all the information including current time for your display.
Arduino GW is needed for wifi less nrf24 radio enabled devices.

Sorry for confusion ... a wireless display station using RF24L01 radio and not WiFi.

Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 07, 2013, 04:09:23 pm
Sorry for confusion ... a wireless display station using RF24L01 radio and not WiFi.
O! it is much more interesting ) will be nice if you will join us and share examples.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on October 07, 2013, 04:21:24 pm
Sorry for confusion ... a wireless display station using RF24L01 radio and not WiFi.
O! it is much more interesting ) will be nice if you will join us and share examples.

Will share for sure ... my development is slow as I have only small amounts of time to work on it. :-) Waiting on 1.3 to complete to incorporate new improvements. Thanks for all you guys hard work!

Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 06:50:31 am
Could someone post the version 1.21 zip in this thread. I only have the latest trunk-version and forgot to make a backup when switching to Git. :-[

Thanks
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 06:57:56 am
@hek I'm not sure it is what you asking for but please check

should dimmer work? I'm getting "No implementation" error
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on October 08, 2013, 08:01:57 am
Hi Hek,
Again this is just awsome stuff...thank you very much for your efforts. I hope i can contribute somehow.

Today i received some radios and have hooked them up to some arduinos i already have.
I've loaded code 1.2 which i downloaded the other day in preparation.

My nano is connected to the vera and plugin loaded - all looks ok.
Ive then run up an duemilanove again with a radio and a DHT sensor - loaded the sketches etc.

My problem... i cant see any new devices created on my Vera -isn't this automagically meant to occur?

I feel i'm so close to seeing the magic!



Here is the output from the duemilanove:
Code: [Select]
Sending the following message to Vera:
9;0;1;1;47.3
Message fully received!
Sending the following message to Vera:
9;1;1;0;22.4
Message fully received!
Radio id stored in EEMPROM: 9
Sending the following message to Vera:
9;0;0;7;1.2
Message fully received!
Sending the following message to Vera:
9;1;0;6;1.2
Message fully received!
H: 47.40
T: 22.50
Sending the following message to Vera:
9;0;1;1;472
Message fully received!
Sending the following message to Vera:
9;1;1;0;22.5
Message fully received!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 08:09:23 am
@greglions
Let me answer to you on experience i have.

It is very usefull to monitor log activity in vera during debugging:
- use your favorit ssh client. From mac use in terminal:
>ssh -l root <vers ip>
- type on vera command prompt:
>tail -f /var/log/cmh/LuaLog.log | grep Arduino

As soon as you powered on your radio node (or just after sketch was downloaded or reset happened to arduino) you should see some activity is going on

If no activity happened you should check wire connections one agsin
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 08:10:26 am
Also makr sure that arduino plugin device is not get red
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on October 08, 2013, 08:22:08 am
Hi Axill, many thanks for your reply...
I've just looked for the logfile you mention and its not there! Ill recheck my connections - the plugin isnt red either ( im assuming you mean in the UI5 )


Code: [Select]
root@MiOS_xxxxxxxx:/tmp/log/cmh# ls /var/log/cmh/
InternetOk.log      NetworkMonitor.log  signal.flag.log
LuaUPnP.log         serproxy.log        signal.log
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 08:24:54 am
I may misstype log file name and currently cannot check, messaging from mobile
You probably can check name by yorself
It is system lig, it have to be here regardless arduino
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 08:26:07 am
Oh missed your file list
You need file started from Lua
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on October 08, 2013, 08:32:09 am
Ok cool - i can see lots going on in that file..especially if i "reload" in UI5.

At quick glance nothing obvious for arduino stuff.....

Do you grep for a particular string?

Thanks again for your help!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 08:33:22 am
grep Arduino
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on October 08, 2013, 08:58:02 am
Whoooooo! Its working...not sure exactly what i did though ???

In the log below, around 23:51, i reset the duemilanove- and the gateway picked it up...

Thanks again axill and Hek! I can now get to sleep dreaming of ideas instead of WTF!!! ;-)

Code: [Select]
root@MiOS_xxxxx:/# tail -f /var/log/cmh/LuaUPnP.log |grep Arduino
01      10/08/13 23:48:04.651   luup_log:73: Arduino plugin: 9;1;1;0;22.2 <0x2e7a1680>
01      10/08/13 23:48:37.661   luup_log:73: Arduino plugin: 9;0;1;1;47 <0x2e7a1680>
01      10/08/13 23:48:37.692   luup_log:73: Arduino plugin: 9;1;1;0;22.5 <0x2e7a1680>
13705 root      1672 S    grep Arduino
13705 root      1672 S    grep Arduino
13705 root      1672 S    grep Arduino
09      10/08/13 23:49:15.875   JobHandler_LuaUPnP::Run device 73 Arduino Gateway Plugin room 6 type urn:schemas-arduino-cc:device:arduino:1 id  parent 0/0xaa9858 upnp: 0 <0x2b200000>
50      10/08/13 23:49:24.944   luup_log:73: Arduino plugin: loading library L_Arduino ... <0x2bb33680>
50      10/08/13 23:49:24.976   luup_log:73: Arduino plugin: library L_Arduino loaded <0x2bb33680>
50      10/08/13 23:49:24.977   luup_log:73: Arduino plugin: Serial port is connected <0x2bb33680>
50      10/08/13 23:49:24.977   luup_log:73: Arduino plugin: Baud is 38400 <0x2bb33680>
50      10/08/13 23:49:24.979   luup_log:73: Arduino plugin: Sending command: 0;0;33;Get Version <0x2bb33680>
01      10/08/13 23:49:25.001   luup_log:73: Arduino plugin: 0;0;99;0;version=1.2 <0x2eb33680>
06      10/08/13 23:49:25.002   Device_Variable::m_szValue_set device: 73 service: urn:upnp-arduino-cc:serviceId:arduino1 variable: ArduinoLibVersion was: 1.2 now: 1.2 #hooks: 0 upnp: 0 v:0xb67118/NONE duplicate:1 <0x2eb33680>
01      10/08/13 23:49:43.731   luup_log:73: Arduino plugin: 9;0;1;1;47 __LEAK__ this:20480 start:888832 to 0xf4a000 <0x2eb33680>
01      10/08/13 23:49:43.751   luup_log:73: Arduino plugin: 9;1;1;0;22.2 <0x2eb33680>
01      10/08/13 23:50:16.761   luup_log:73: Arduino plugin: 9;0;1;1;47 <0x2eb33680>
01      10/08/13 23:50:16.791   luup_log:73: Arduino plugin: 9;1;1;0;22.3 <0x2eb33680>
01      10/08/13 23:50:49.801   luup_log:73: Arduino plugin: 9;1;1;0;22.4 <0x2eb33680>
01      10/08/13 23:51:02.501   luup_log:73: Arduino plugin: 9;0;0;7;1.2 <0x2eb33680>
01      10/08/13 23:51:02.502   luup_log:73: Arduino plugin: New arduino sensor found using device file: D_HumiditySensor1.xml <0x2eb33680>
02      10/08/13 23:51:04.884   luup_log:73: Arduino plugin: Found new Arduino sensor. Need to restart. Please wait. <0x2eb33680>
13705 root      1676 S    grep Arduino
13705 root      1676 S    grep Arduino
13705 root      1676 S    grep Arduino
09      10/08/13 23:51:15.115   JobHandler_LuaUPnP::Run device 73 Arduino Gateway Plugin room 6 type urn:schemas-arduino-cc:device:arduino:1 id  parent 0/0x85e6a0 upnp: 0 <0x2b7f5000>
09      10/08/13 23:51:15.115   JobHandler_LuaUPnP::Run device 76 Arduino Humidity 9;0 room 0 type urn:schemas-micasaverde-com:device:HumiditySensor:1 id 9;0 parent 73/0x8612b8 upnp: 0 <0x2b7f5000>
50      10/08/13 23:51:24.106   luup_log:73: Arduino plugin: loading library L_Arduino ... __LEAK__ this:114688 start:933888 to 0xd0e000 <0x2c129680>
50      10/08/13 23:51:24.182   luup_log:73: Arduino plugin: library L_Arduino loaded <0x2c129680>
50      10/08/13 23:51:24.182   luup_log:73: Arduino plugin: Serial port is connected <0x2c129680>
50      10/08/13 23:51:24.183   luup_log:73: Arduino plugin: Baud is 38400 <0x2c129680>
50      10/08/13 23:51:24.185   luup_log:73: Arduino plugin: Sending command: 0;0;33;Get Version <0x2c129680>
01      10/08/13 23:51:24.202   luup_log:73: Arduino plugin: 0;0;99;0;version=1.2 <0x2e529680>
06      10/08/13 23:51:24.202   Device_Variable::m_szValue_set device: 73 service: urn:upnp-arduino-cc:serviceId:arduino1 variable: ArduinoLibVersion was: 1.2 now: 1.2 #hooks: 0 upnp: 0 v:0x91f490/NONE duplicate:1 <0x2e529680>
01      10/08/13 23:51:41.861   luup_log:73: Arduino plugin: 9;0;1;1;47 <0x2e529680>
01      10/08/13 23:51:41.862   luup_log:73: Arduino plugin: Setting variable 'CurrentLevel' to value '47' <0x2e529680>
01      10/08/13 23:51:41.881   luup_log:73: Arduino plugin: 9;1;1;0;22.1 <0x2e529680>
01      10/08/13 23:52:47.891   luup_log:73: Arduino plugin: 9;0;1;1;47 <0x2e529680>
01      10/08/13 23:52:47.892   luup_log:73: Arduino plugin: Setting variable 'CurrentLevel' to value '47' <0x2e529680>
01      10/08/13 23:52:47.911   luup_log:73: Arduino plugin: 9;1;1;0;22.2 <0x2e529680>

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 09:03:14 am
You'll have to restart and then reload browser window. Right now you also need to restart the arduino the same number of times you have sensors (one new device is created on vera side each time). This will soon change.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 09:04:11 am
My congratulations!)

I also get progress - easelly re-wrote my existing device and not it is connected to vera. Only dimmer is not working, it seams some programming is still required on Vera side
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on October 08, 2013, 09:04:35 am
Hi Hek,
Again this is just awsome stuff...thank you very much for your efforts. I hope i can contribute somehow.

Today i received some radios and have hooked them up to some arduinos i already have.
I've loaded code 1.2 which i downloaded the other day in preparation.

My nano is connected to the vera and plugin loaded - all looks ok.
Ive then run up an duemilanove again with a radio and a DHT sensor - loaded the sketches etc.

My problem... i cant see any new devices created on my Vera -isn't this automagically meant to occur?

I feel i'm so close to seeing the magic!

It appears your Arduino GW is receiving messages from your sensor, but possibly your GW is not communicating with Vera. May want to double check the "Serial Port configuration" in APPS --> Develop Apps tab in the Vera GUI.

I had some trouble with this portion of the configuration too. Had to upload the LUA files twice - for some reason Veralite didn't upload correctly. You are close thou ...

I've also checked logs during config, by ssh into Veralite and typing:
    tail -f /var/log/cmh/LuaUPnP.log | grep -i arduino

Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 09:05:10 am
@hek I'm not sure it is what you asking for but please check

should dimmer work? I'm getting "No implementation" error

Thanks. I'll link this from the wiki while the 1.3 development continues.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 09:07:51 am
@hek do you have any specific way of deleting wrongly created nodes?

I faced today an issue that radio id which was reused is not working. I had to recteate nodes assigning ID mannuaky to one which was never get assigned
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 09:32:13 am
Sometimes I think vera keeps a list of devices somewhere that isn't visible in the GUI. They can suddenly pop up back again and the only way to delete then is by doing url-delete-trick.

I've experienced this a couple of times as well. Probably an Vera bug.


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 10:14:40 am
I see, probably we need to reflect it in a wiki
It looks like node is not responding, but as soon as you create fresh devices with never used id - node start working while node itself was not modified

What about dimmer? Should it work, or you plan to workout missing part?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 11:01:24 am
I don't have any good dim-sensors to try the concept with. A trimpot? The analog inputs could probably be used to simulate a dimmer somehow..

I will just have to finish up on the stuff planned ;)

A question. I'm curently implementing the new sensor presenatation where all presentation data is sent in to vera in one or more big chunks. What is preferred?

1. For the following we need to keep a small buffer  [128 bytes] in library to buffer up the presentation data and then send it all :
   vera.registerChildSensor(S_DOOR) // Will get id = 1
   vera.registerChildSensor(S_DOOR) // Will get id = 2
   vera.registerChildSensor(S_TEMP) // Will get Id = 3
   vera.sendChildPresentation(); // Sends all registered sensors to vera which will be created in one step

or

2. The following does not require any buffer. For sensors with static number of sensor it is ok, but for some sensors (like dallas ) it will be more complicated to build up this array dynamically.
  vera.sendChildPresentation({S_TEMP, S_TEMP, S_TEMP,S_DOOR}); // Will get child id 1,2,3,4


Child id 0 will be reserved for main/radio device

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 11:14:22 am
@hek why you considering to change current implementation?
Dinamic child_id assignment is a nice simification but the price could me mess on a nide upgrade by adding new children

I for found a good practice to define on top of a sketch enum to name my children.
Later i can easelly can refer any child id by name
It makes my program consistent
With dynamic assignment you will have nice presetnation and very trickier later referencies
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 08, 2013, 12:01:48 pm
I believe he is doing this to prevent from having to reload the Vera luup engine for each new sensor. Is that correct? First option looks good.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 12:34:26 pm
Correct Garrett. The reload/arduino restart cycle is very annoying and I get many questions regarding the behavior.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 01:32:51 pm
I believe he is doing this to prevent from having to reload the Vera luup engine for each new sensor. Is that correct? First option looks good.
common... you are not going to do it more than once
zwave inclusion even more annoying

why not do it slightly different?
if there will be a function like bool getSensorStatus( child_id, sensor_type) we can organize a circle like this:
Code: [Select]
for(int i=0; i<ziseof(children); i++) {
    if(vera.getSensorStatus(children[i], children_types[i])) {
        vera.deleteSensor(children[i]);   // to be sure that there is no existing children of incorrect type
        vera.endSensorPresentation(children[i], children_types[i]));
        delay_ms(20000);
    }
}

presentation with delay of 20 sec guaranties that all sensors will be created on first run - it is option one

option 2 - is to organize time&size limited buffer on GW side (new devices can potentially came from different nodes at the same time, this why is better to do buffer on GW side, I think...) - you accumulate new sensors in a buffer until time elapsed or size limit reached.

What do you think guys?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 08, 2013, 02:08:57 pm
Just got my parts to hold me until my larger shipment comes in from overseas. Now to get the 1.2 build files and start tinkering!

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 02:36:41 pm
Axill, I will have a go for your option 2. This will require minimal changes of example sketches (they should probably do all presentation before request status and other stuff).

Note that I will need reserve one child id for radio vera device. If I pick 0xFF (255). Hopefully no one uses this yet ;)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 02:41:55 pm
I don't have any good dim-sensors to try the concept with. A trimpot? The analog inputs could probably be used to simulate a dimmer somehow..

I think you do not need dimmer for this, you can print incoming values to Serial and see them in serial monitor of the node as usual

Quote
A question. I'm curently implementing the new sensor presenatation where all presentation data is sent in to vera in one or more big chunks. What is preferred?

1. For the following we need to keep a small buffer  [128 bytes] in library to buffer up the presentation data and then send it all :
   vera.registerChildSensor(S_DOOR) // Will get id = 1
   vera.registerChildSensor(S_DOOR) // Will get id = 2
   vera.registerChildSensor(S_TEMP) // Will get Id = 3
   vera.sendChildPresentation(); // Sends all registered sensors to vera which will be created in one step

or

2. The following does not require any buffer. For sensors with static number of sensor it is ok, but for some sensors (like dallas ) it will be more complicated to build up this array dynamically.
  vera.sendChildPresentation({S_TEMP, S_TEMP, S_TEMP,S_DOOR}); // Will get child id 1,2,3,4


Child id 0 will be reserved for main/radio device
I've got one more idea.What if we will use array at a node side to define structure of sensors? This even can be PROGMEM array with a size from 1 to 16. This array can be synchronized with vera by one function call all 16 can be send as one single packet to GW (4 bits child id + 4 bits type = 8 bits / byte for a child = 16 bytes for all). Something like this:
Code: [Select]
enum {child_switch_left=0, child_switch_right, child_motion };
struct {
   uint8_t child_id:4;
   uint8_t type:4;
} child_config;
const struct childs[] = {
   { child_switch_left, V_LIGHT },
   { child_switch_right, V_LIGHT },
   { child_motion, V_MOTION }
};
...
setup() {
...
vera.sendSensorPresentation(childs, sizeof(childs));
}
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 03:07:11 pm
But currently 127 child sensors is supported and they won't fit in one message to gateway anyway.

When thinking of this one step further I will probably do like this:

All sensor presentations will be stored in gateway. This can be limited to the latest 100 sensors presented or something.
I'll add a new button in Vera plugin ("Update Devices").
Pressing this button will request the list of found devices found since last time or since gateway was restarted.
All new devices will be created in one go.

 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 03:12:14 pm
But currently 127 child sensors is supported and they won't fit in one message to gateway anyway.
the structure I see version 1.2 there is 4 bits for child id = 16 children maximum. Where is my mistake?
Code: [Select]
typedef struct {
  uint8_t radioId;                   // 1 byte. Up to 256 radios in one network
  uint8_t childId            : 4;    // 4 bits. Up to 128 child sensors per radioId
  uint8_t messageType        : 4;    // 4 bits. Type of message. See messageType
  uint8_t type;                   // 1 byte. variableType or deviceType depending on messageType
  char data[MSG_MAX_PAYLOAD_SIZE+1];  // Each message can transfer a payload of 29 bytes. Add one extra byte for \0
} message_s;
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 08, 2013, 03:21:06 pm
Has anyone gotten the Arduino Uno working with Vera? I found a few posts saying I have to mess with ser2net. If anyone has any info, it would be much appreciated.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 03:30:06 pm
Has anyone gotten the Arduino Uno working with Vera? I found a few posts saying I have to mess with ser2net. If anyone has any info, it would be much appreciated.
Garrett, do you mean UNO working as Gateway? I only know that while nano is having standard FTDI chip which vera has driver for, UNO is having atmega chip acting as a bridge from uart to USB with a special firmware. Has anybody wrote a driver for it I cannot imagine.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 08, 2013, 03:34:03 pm
Yes, the uno as a gateway. When I plug the unit into vera it attaches to /dev/ttyACM0.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 03:35:29 pm
Yes, the uno as a gateway. When I plug the unit into vera it attaches to /dev/ttyACM0.
if it is attached it means that linux found a driver for it
what else?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 03:36:45 pm
But currently 127 child sensors is supported and they won't fit in one message to gateway anyway.
the structure I see version 1.2 there is 4 bits for child id = 16 children maximum. Where is my mistake?
Code: [Select]
typedef struct {
  uint8_t radioId;                   // 1 byte. Up to 256 radios in one network
  uint8_t childId            : 4;    // 4 bits. Up to 128 child sensors per radioId
  uint8_t messageType        : 4;    // 4 bits. Type of message. See messageType
  uint8_t type;                   // 1 byte. variableType or deviceType depending on messageType
  char data[MSG_MAX_PAYLOAD_SIZE+1];  // Each message can transfer a payload of 29 bytes. Add one extra byte for \0
} message_s;

No misstake. You could pack up to 28 (max payload) presentations in each message. Basically what I thought of doing in alternative 2 (but without childid which would fit 56 presentations) from previous post. But unforutnately it also have the same drawbacks if you want to create sensors dynamically when sketch executes.

I will keep the current api on sensor side.

@garrett
I did some testing with Uno and ser2net but I gave up. Too much hassle.

 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 03:38:59 pm
Roadmap added

http://code.mios.com/trac/mios_arduino-sensor/roadmap
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 03:40:04 pm
No misstake. You could pack up to 28 (max payload) presentations in each message.
@hek i'm about something else. You use 4 bits to represent child_id. How you can support 127 children??
I do not understand
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 08, 2013, 03:44:28 pm
So if I run ser2net -C 3481:raw:0:/dev/ttyACM0:38400, I can telnet to that port and see the serial data from the arduino. Need to figure out how to get the vera plugin to use that connection.

Code: [Select]
0;0;99;0;message=Arduino startup complete
- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 03:46:31 pm
Roadmap added

http://code.mios.com/trac/mios_arduino-sensor/roadmap
great staff!

why not add TCP as an alternative, not replacing USB?
Quote
Support IP connection (instead of USB) in vera plugin

I will suggest not go so fast for any other radio hardware. It is better to make more functionality and less bugs using what we have (nrf24)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 03:49:02 pm
Sorry, I did not say that alt2 would fit 128 presentations. I would need to send them in multiple messages also.. that why i did the comment "it would not fin in ONE message". Thinking out loud..  :D
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 03:52:05 pm
So if I run ser2net -C 3481:raw:0:/dev/ttyACM0:38400, I can telnet to that port and see the serial data from the arduino. Need to figure out how to get the vera plugin to use that connection.

Code: [Select]
0;0;99;0;message=Arduino startup complete
- Garrett

You can do an os.execute in vera starup luup box. But you'll still have to modify the plugin a bit I guess to use it..
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 08, 2013, 03:53:51 pm
Sorry, I did not say that alt2 would fit 128 presentations. I would need to send them in multiple messages also.. that why i did the comment "it would not fin in ONE message". Thinking out loud..  :D
that is fine ... but still... for 128 children you need 7 bits! any way.
for example I made a call:
vera.sendSensorPresentation(127, V_MOTION);

in which part of a message you will put 3 additional bits needed to represent 127?
the code bellow will send only 4 bits, and 127 will be send as 15
Code: [Select]
boolean Vera::sendData(uint8_t childId, messageType messageType, uint8_t type, const char *data) {
int dataLength = strlen(data);
if (dataLength <= MSG_MAX_PAYLOAD_SIZE) {
msg.radioId = radioId;
msg.childId = childId;
msg.messageType = messageType;
msg.type = type;
memcpy(msg.data, data, dataLength);
if (DEBUG && radioId!=0) { Serial.println("Sending the following message to Vera:");printVeraMessage(); }
if (dataLength < MSG_MAX_PAYLOAD_SIZE) {
msg.data[dataLength] = '\0';
}
int msgLength = MSG_HEADER_LENGTH + dataLength + 1;
//printVeraMessage();
if (radio->write(&msg, MSG_HEADER_LENGTH + min(32,msgLength))) {
if (DEBUG&& radioId!=0) { printVeraMessage("Message fully received!"); }
return true;
} else {
if (DEBUG && radioId!=0) {printVeraMessage("No ack received");}
return false;
}
} else {
if (DEBUG && radioId!=0) {printVeraMessage("Message too large");}
return false;
}
}
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 08, 2013, 03:55:37 pm
why not add TCP as an alternative, not replacing USB?

That is what I meant ;)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 08, 2013, 09:44:14 pm
I need to tinker with it more (had to sleep). But I have the plugin able utopia connect to the the serproxy connected to the arduino. I can see that it is receiving data from my one sensor, how I'm still having issues with the plugin working. The vera logs print out the messages received from the sensor node. I'll have to mess with it more later tonight.

- Garrett

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 09, 2013, 02:06:03 am
So I have the gateway working with the plugin (sort of). It is reporting the messages sent from the arduino node that has a dht22 sensor connected to it. This is what is reported in the log:

01   10/09/13 1:56:08.890   luup_log:97: Arduino plugin: 105;0;1;1;43 <0x2fa23680>
01   10/09/13 1:56:41.809   luup_log:97: Arduino plugin: 105;0;1;1;43 <0x2fa23680>

This is connected via serproxy via the localhost. The only thing it did not do was get the gateway version after connecting via luup.io.open(deviceId, ipAddress, port). I need to figure out why it wont run the command at start up. I am not home to reset the arduino sensor node to have it populate the child devices. Hopefully by reseting that sensor node, it will tell the gateway to tell vera to populate the devices. I am going to clean up some code and post it to allow for ip connection via the gateway (more like an example for future implementing). I am also going to modify the arduino sketches to include conversion of temperature etc for us US folks who use the standard system. Which can be set via a value in the sketch to convert before sending to Vera.

More to come...

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 09, 2013, 02:56:19 am
I am also going to modify the arduino sketches to include conversion of temperature etc for us US folks who use the standard system. Which can be set via a value in the sketch to convert before sending to Vera.

More to come...

- Garrett

Great! I will implement some sort of setting for this that can be fetched by sensors at startup (like time). But it will be pushed to  1.4.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 09, 2013, 04:41:12 am
cannot get rid from this garbage:
Quote
   luup_log:71: Arduino plugin: 0;0;0;0; <0x32ddd680>

by presenting new children I'm getting random childs created to random nodes
what it is about?
does anyone has the same?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 09, 2013, 10:17:37 am
by debugging I found that an empty message (all bytes zero) is received by GW
radio message is of 5 bytes long, data is empty string, extended log looks like:
Quote
0;0;99;0;message=Arduino startup complete
getMessage: len=5 strlen(data)=1
7;1;1;2;0
getMessage: len=5 strlen(data)=0
0;0;0;0;
getMessage: len=5 strlen(data)=0
0;0;0;0;
getMessage: len=5 strlen(data)=0
0;0;0;0;
getMessage: len=5 strlen(data)=0
0;0;0;0;
getMessage: len=5 strlen(data)=1
7;1;1;20;0

I checked nodes program code and find nothing about this. Have no idea
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 09, 2013, 10:59:24 am
I have seen this from time to time. Would be good to find out why this is happening. But I guess it will disappear if we add some crc checksum.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 09, 2013, 01:31:40 pm
I am experiencing something very strange, if I change the sleep mode for the HumiditySensor sketch for the DHT22 to 300 (for 5 minute sleep time). The arduino will not properly sleep and will update the temperature and humidity values with in seconds of each other. If I change it back to 30 seconds, it will properly sleep for the 30 seconds. Can anyone else reproduce this?

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 09, 2013, 01:42:27 pm
Figured it out you need to define SLEEP_TIME as an unsigned long. So you need to replace this:

Code: [Select]
#define SLEEP_TIME 30
with

Code: [Select]
unsigned long SLEEP_TIME = 30;
I am going to go over the rest of the sketches and see if I can knock out any more bugs. Hek, how do you want me to participate in helping you with development?

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 09, 2013, 01:59:53 pm
Just to share. I re-programmed my two existing devices in the framework of arduino plugin. I disconnect them from talking to each other directly and create PLTS logic for their communication.

Node 1 is a high power (3 channels, 20A/220V maximum per channel) switch witch power measurement individually per 3 channels and PWM controlled fan cooling for triacs. I'v created 2 S_LIGHT witch setting of V_WATT, 4 S_MOTION sensors - indicating 3 channels are in use and 4th - overheating of triacs

Node 2 is a stove fan controller with ability to individually switch on/off left/right switch and 4 modes of the fan. I've created 2 S_LIGHT and 1 S_DIMMER.

Before this excessive node 1 sends directly to node 2 updates on power consumption and this let me switch on the light and different modes of the fan. Now with Vera plugin I able to put this logic into vera using PLTS plugin - it switches on individually lights and switch them off with timeout. I also can see consumed power and as soon as S_DIMMER will be implemented can manage fan mode based on time ON or/and power consumed.

All this from the functionality point of view looks very cool. I'm still experienced stability issues. I did a careful review with partial rewrite  of the code and hope will merge this before 1.3 release. Communication is an issue. I'm facing loss of messages on both sides (GW and nodes)

I've got that as a general guidelines anyone should follow:
- create as simpler nodes as possible
- try design nodes in a way without their direct communication
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 09, 2013, 03:38:26 pm
Figured it out you need to define SLEEP_TIME as an unsigned long. So you need to replace this:

Code: [Select]
#define SLEEP_TIME 30
with

Code: [Select]
unsigned long SLEEP_TIME = 30;
I am going to go over the rest of the sketches and see if I can knock out any more bugs. Hek, how do you want me to participate in helping you with development?

- Garrett


I appreciate any help. Are you familiar with git?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on October 09, 2013, 08:10:50 pm
Hi Hek,

Have you documented how you use the 5v to 3.3v voltage converters? i cant see it on the "Connecting RFModule page"

The reason i ask is that ive seen a page suggesting a cheap and cheerful way of dropping down the voltage for the radios is to use two 1N4001 diodes in series which should drop 1.4v across them.

Ive not tested this myself, but will try to do so tonight....

(Yep i didnt order the 3.3v regulators in my order! )
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 10, 2013, 01:22:17 am
@greglions
No. This part is not documented yet and it is only applicable if using pro minis.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 10, 2013, 01:37:32 am
@greglions
absolutely sure you can use a few diodes to drop the voltage, it is better to use 3 diodes if you going to power nrf24 from 5v
with 2 diodes you will be not safe to exceed 3.6v module maximum
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 10, 2013, 04:01:31 am
Figured it out you need to define SLEEP_TIME as an unsigned long. So you need to replace this:

Code: [Select]
#define SLEEP_TIME 30
with

Code: [Select]
unsigned long SLEEP_TIME = 30;
I am going to go over the rest of the sketches and see if I can knock out any more bugs. Hek, how do you want me to participate in helping you with development?

- Garrett


I appreciate any help. Are you familiar with git?

Hek,

Yes, I am familiar with git. I use it every day.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 10, 2013, 08:06:56 am
Hek,

Yes, I am familiar with git. I use it every day.

Garrett, good and welcome on board! )
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on October 10, 2013, 09:08:37 am
Could someone please tell me what rf channel the nrf24l01 is using ? Is it set somewhere in the code ? I would like to try some different channels to see if I could increase range even more.
Thanks for any info.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 10, 2013, 09:22:29 am
Could someone please tell me what rf channel the nrf24l01 is using ? Is it set somewhere in the code ? I would like to try some different channels to see if I could increase range even more.
Thanks for any info.
the default channel is used. Default channel is 76 (decimal). You can set channel using radio.setChannel(). With 1.2 you probably need to hack Vera::begin it has this commented

take a look at this sketch http://code.mios.com/trac/mios_arduino-sensor/browser/VeraArduino/Arduino/libraries/RF24/examples/scanner
it can help you find out a not busy channel
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on October 10, 2013, 09:26:05 am
@axill;

Thankyou , I will give it a go.........
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 10, 2013, 11:52:46 am
@garrettwp
Can you help me organize AVR module in git  in a way that i will be able to incorporate changes from Vera.cpp & Vera.h to AVR version VeraAVR.c & VeraAVR.h?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on October 11, 2013, 02:04:31 pm
I've done some work on a RF24 wireless remote LCD display. I want to be able to get weather information from the Weather Underground Vera plugin app to my remote wireless display.  What's the best method to have a remote wireless device (sensor) request a variable from another Vera app?

I guess it's possible to customize the gateway lua code to accomplish this.  I think the 2.3 release will allow for customized messages to and from a remote sensor.

Thanks,
Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 11, 2013, 03:04:30 pm
@joek
You can create a scene that triggers on weather change.
In the lua tab you do a sendCommand to the sensor using VAR_1,...,VAR_5 as container for data.

For example:
luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand",
                 {radioId="2", variableId="VAR_1", value="500"},
                 <deviceId>)

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on October 11, 2013, 07:30:59 pm
@joek
You can create a scene that triggers on weather change.
In the lua tab you do a sendCommand to the sensor using VAR_1,...,VAR_5 as container for data.

For example:
luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand",
                 {radioId="2", variableId="VAR_1", value="500"},
                 <deviceId>)

I am confused on which release I should be using.  With v1.2 works fine,  but can't get v1.22 "master" to work. I need to receive RF24 messages at the sensor that are non-blocking, which I believe v1.22 has.

Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 12, 2013, 02:21:50 am
You should use 1.21 for now.

The 1.22 was/is not tested when moving development to git. We're currently working in 1.2dev branch.. But wait testing it until I say that we need beta testers...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: 4integration on October 12, 2013, 08:01:48 am
Hi,

I am doing some prototyping with light sensor to build a PowerMeter for main power line (blinking diod). It's using DigitalOutput and interrupt. Since I am a beginner of Arduino/Vera I have some questions:

1) When using the serial monitor I get a lot of garbage characters with print's but the initial "Sending the following message to Vera:" shows correctly. Baud is set to 38400. In some tests yesterday it worked...Any idea? (makes debugging difficult)

The code below, please shoot at it (not polished though :) )


Code: [Select]
#include <Sleep_n0m1.h>
#include <SPI.h>
#include <RF24.h>
#include <EEPROM.h> 
#include <Vera.h> 
#include <Time.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 4

#define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your PowerMeter sensor.  (Only 2 and 3 generates interrupt!)
#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
#define CHILD_ID 0   // Id of the sensor child

RF24 radio(9,10);
Vera vera(RADIO_ID, &radio);
Sleep sleep;

// Definitions/Variables specific for this PowerMeter sketch
const int BLINKS_PER_KWH = 1000;

volatile unsigned long blinks = 0; // Counts power pulses in interrupt, 1 pulse = 1 watt
const int sendInterval = 30;       // should be around 300 (5 min) the interval in seconds between each log
time_t nextTrigger;                // Keep track on when to send data next time
long totalBlinksSinceStart = 0;

/*
 * Setup the application once when starting up
 */
void setup() 
{
  Serial.begin(38400);  // Used to type in characters
  while (! Serial);     // Wait untilSerial is ready
  vera.begin();

  pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the powermeter sensor digital pin as input

radio.powerUp();
  // Register all sensors to Vera (they will be created as child devices)
  vera.sendSensorPresentation(CHILD_ID, S_POWER);
  delay(500); //delay to allow serial to fully print before sleep
  radio.powerDown();
  nextTrigger = now() + sendInterval; // schedule the logging time
}

/*
 * Run continuously
 */
void loop() {
  // Read digital blink value
  boolean blink = digitalRead(DIGITAL_INPUT_SENSOR);
  if (blink == LOW) { // Blink detected
    blinks++;
    totalBlinksSinceStart++;
    Serial.print("Blink ");
    Serial.println(blinks);
    Serial.print(", total since start: ");
    Serial.print(totalBlinksSinceStart);
  }

  if( now() >= nextTrigger) {
    sendDataToGateway();
    blinks=0;
    nextTrigger = now() + sendInterval;// schedule the next log time 
  }

  sleep.pwrDownMode(); //set sleep mode
  sleep.sleepInterrupt(INTERRUPT,CHANGE);
}

/*
* Send data to Vera Gateway
 */
void sendDataToGateway() {
  float kwh = blinks/BLINKS_PER_KWH;
  int kwhInt = (int)(kwh+0.5); // round up
  // Send data
  vera.sendVariable(CHILD_ID, V_KWH, kwhInt);
  Serial.print("KWH Value sent: ");   
  Serial.print(kwhInt);   
  Serial.print(", based on blinks: ");   
  Serial.println(blinks);   
  // Power down the radio.  Note that the radio will get powered back up
  // on the next write() call.
  delay(200); //delay to allow serial to fully print before sleep
  radio.powerDown();
}
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 14, 2013, 04:52:29 pm
I have some news from development  in a visual form:
http://www.youtube.com/watch?v=fTI2_t2zlfM


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on October 14, 2013, 04:56:51 pm
Nice one axill!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 14, 2013, 05:02:48 pm
Nice one axill!
thanks! it is a team work)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on October 16, 2013, 01:49:21 am
Hi Hek/axill,

I downloaded the latest code today: http://code.mios.com/git_public/mios/arduino-sensor.git/tree/refs/heads/1.2dev?js=1

Ive hit an error it seems with the Vera plugin. ive attached the error from LuaUPNP.log below...
Any ideas?

 
Code: [Select]
50      10/16/13 16:43:40.100   luup_log:73: Arduino plugin: loading library L_Arduino ... <0x2b49f680>
01      10/16/13 16:43:40.128   luup_require require L_Arduino failed [string "module("L_Arduino", package.seeall)..."]:93: attempt to call global 'RELAY_NODE' (a nil value) <0x2b49f680>
50      10/16/13 16:43:40.129   luup_log:73: Arduino plugin: library L_Arduino loaded <0x2b49f680>
50      10/16/13 16:43:40.129   luup_log:73: Arduino plugin: loading library L_Arduino ... <0x2b49f680>
02      10/16/13 16:43:40.130   luup_require duplicate L_Arduino <0x2b49f680>
01      10/16/13 16:43:40.131   luup_log:73: Arduino plugin: plugin is not installed correctly. Library L_Arduino cannot be loaded. <0x2b49f680>
01      10/16/13 16:43:40.132   LuaInterface::CallFunction_Startup-2 device 73 function startup failed (null) with return false <0x2b49f680
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 16, 2013, 03:09:55 am
Hi gregl,

The 1.2dev branch is still under heavy development and we've not started testing yet. It will most probably not work in the current state!

I will post here when we need beta testers.. and it will happen soon!

But I came really far with the message routing last night and hopefully we'll see a radio network that is self healing (without involving vera). You will just need to start a new arduinio/radio unit without any prior configuration. The node will find the shortest route to gateway and routing tables (in all descending nodes) will be updated automatically. You will also be able to send messages between nodes without vera involvement. This makes the library useful even if you don't own a vera (you will only lose the auto-id functionality). 

Pretty sweet (it it works).

Axill will also create a AVR variant of the library and has recently finalized the (optional) include button/rx/tx/err blink functionality of GW. Looks beautiful!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on October 16, 2013, 06:09:58 am
Hi Hek,

Understood... Im working my way around the "git" system - not quite as obvious as to which one to download.

Anyway,  i found the cause.
In L_Arduino.lua line 93
was
Code: [Select]
  RELAY_NODE      {38, "urn:upnp-arduino-cc:serviceId:arduinonode1", "RelayNode", ""},i changed to
Code: [Select]
RELAY_NODE={38, "urn:upnp-arduino-cc:serviceId:arduinonode1", "RelayNode", ""},
re-uploaded and the plugin loaded properly.

Thanks again guys...look forward to testing!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 16, 2013, 02:04:54 pm
Are these units enough (or too many) to select from in Arduino plugin?

An sensor will be able to request a unit type format from Vera.  And then adopt the data it sends in to Vera according to preferred format.

local tUnitTypes = {
   UNIT_LENGTH = {"mm","cm","m","in","ft"},
   UNIT_SPEED = {"km/h", "m/s", "mph"},
   UNIT_TEMPERATURE = {"C", "F"},
   UNIT_PRESSURE = {"mBar", "hPa"},
   UNIT_MASS = {"Kg","oz","lb"},
}
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: ChrisK on October 16, 2013, 08:39:52 pm
@hek,

I use light levels to trigger events.  My sensors are not calibrated so levels between 0 and 100 work for me.  Others have expressed desires for values in lumen.  Just a thought.

Anyway, love the work that you guys have done.  I am very anxious to see the progress.  I will be switching some of my work with XBees to this.

Thanks,
Chris
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on October 16, 2013, 10:23:17 pm
Hi Hek,  perhaps add grams (g)  to mass units



Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on October 16, 2013, 11:42:37 pm
@hek
CO2 meter and "ppm" unit required or one universal unit-type?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 17, 2013, 03:56:48 am
Universal units will not be part of the configuration (as there is nothing to choose between :).

Gregl.. your right.. I will only keep m(eter), g(ram) for SI units.

Speed can probably also be removed? If i choose length in meter i will also probably want speed in m/s.

local tUnitTypes = {
   UNIT_LENGTH = {"m","in","ft"},
(   UNIT_SPEED = {"km/h", "m/s", "mph"}, )
   UNIT_TEMPERATURE = {"C", "F"},
   UNIT_PRESSURE = {"mBar", "hPa", "inches"},
   UNIT_MASS = {"g","oz","lb"},
}
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 17, 2013, 04:05:14 am
hek,

You may want to have a look here:

Weather sensors: standardizing wind, rainfall, pressure (http://forum.micasaverde.com/index.php/topic,11815.0.html)

And the following post:

Here (http://forum.micasaverde.com/index.php/topic,11815.msg131097.html#msg131097)

As you already have seen and posted on the above thread, You may want to try and follow the units listed in the document?

For Pressure, can you add inches for us US folks.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 17, 2013, 04:45:10 am
Yes Garrett, thanks.. Your document was the inspiration together with the following site:

http://www.gordonengland.co.uk/conversion/temperature.htm

The best thing would be if mcv took care of this configuration and provided an api for plugin to fetch it..

- Henrik
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on October 20, 2013, 06:58:38 am
I have been following this thread for a while and I have realy high hopes for the plugin. Many thanks to everyone that is working hard to make tis all happen.

Now I was wondering if it is possible to put more than one "sensor" in to one Arduino Pro Mini? I guess the amount of I/O is enough but is there some other limitation than comes allong?

What I had in mind is one Arduino Pro Mini would take care of monitoring status of 2 garagedoors (2bi in), controlling the 2 garagedoors (2bi out), measure the distance to 2 cars (2an in) and 2 LEDs to indicate that the cars are close enouh to the wall (2bi out). Would this be posible or is it better to devide the functonality on several Arduino Pro Minis?
Would the distance metering even be fast enouh so my wife dont trash the garage/car?

Looking forward to some comments before i take the plunge in to the world of Arduino.

Br,
Tomas
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 20, 2013, 07:19:12 am
@korttoma
You can have register up to 256 child sensors from one arduino. So yes, this works already.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 20, 2013, 07:23:10 am
@korttoma i have success on having 7 sensors on simple atmega8 and 11 sensors on atmega168 :)
your arduino has even more powerful MCU
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 20, 2013, 07:28:39 am
i think i found a good way of powering battery powered sensors. It is about mcp1640 and ncp1402 step-up chips.
for anyone who is not afraid of soldering just a few components it should work fine.
both chips allows to get 3.3V from a single alkaline or ni-mh battery and have low power consumption
will try that myself as soon as i will get the chip 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on October 20, 2013, 01:32:31 pm
i think i found a good way of powering battery powered sensors. It is about mcp1640 and ncp1402 step-up chips.
for anyone who is not afraid of soldering just a few components it should work fine.
both chips allows to get 3.3V from a single alkaline or ni-mh battery and have low power consumption
will try that myself as soon as i will get the chip

I am waiting for components to arrive to test out low power battery operated sensors using atmega328 chips.  Found this site to be helpful: http://gammon.com.au/power

Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on October 21, 2013, 02:45:47 am
Thanks everyone for confirming that the Arduino Pro Mini is powerful enough to handle many sensors at once.

So how about the communication between the VERA and the sensor?
Is it really fast enough to get the distance value to vera and a scene in vera then can enable an output of the Arduino fast enough to park a car?
Or would it be better to code this feature in to the Arduino? (Is this possible?)

(When a say distance sensor is sending the value via the communication is there any chance that the communication could collide with some other sensors communication and need to be resent? How is the sending of data normally done from a sensor? Is it done at a set interval or if a value change is big enough? Or both?)

grateful for any comment
Br,
Tomas
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 21, 2013, 02:58:25 am
You can very easy turn on/off some diods directly in the sketch code for your distance measuring arduino.

If you choose to send distance via vera to do some actions it could certainly be some delays (very specific to your setup).

If you look at the sketch code for the distance sensor you will probably see that it's sleeping most of the time. You'll have to change the frequency as described on the wiki and in the sketch code if you want more readings.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on October 21, 2013, 03:08:56 am
Thanks hek for your reply.

I will try to include the car parking functionality to the distance measuring sketch then. (Can I post here if I'm having trouble getting it to work or should I create a separate thread?)

Br,
Tomas
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 21, 2013, 03:30:31 am
Maybe its time for a sub-forum? Guess there will be discussions regarding implementation of different sensor types etc which would fit better in their own threads...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on October 21, 2013, 03:37:16 am
@hek it is a good idea to start a subforum
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 21, 2013, 04:08:27 am
The usual rule of thumb that we follow here is that if the thread has several hundred replies (like this one). It is eligible for a child forum. You'll have to get in contact with MCVFlorin to have him create the sub-forum.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 21, 2013, 04:25:13 am
Ok, I have sent an PM to mcvflorin.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on October 21, 2013, 06:55:04 am
Is there a Zip Archive with the libraries somwhere and I just cant find them of do I have to download every file one by one?

The wiki link to the libraries does not give me anything but a "Trac Error" -> http://code.mios.com/trac/mios_arduino-sensor/browser/trunk/Arduino/libraries#

Same goes for the links to the sensor sketches "Trac Error" on all of them.
 What I'm I doing wrong?

Br,
Tomas
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on October 21, 2013, 08:03:31 am
http://code.mios.com/trac/mios_arduino-sensor/browser/VeraArduino/Arduino/libraries
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on October 21, 2013, 08:14:53 am
@hek

Is it possible to make a change to the HumiditySensor.ino sensor sketch?   For some reason the humidity does not display the decimal point in the Vera Device - the value is truncated (to and integer) as opposed to rounded-up. I can read the floating point value at the Arduino sketch, so not sure where it's getting truncated.

As an example:  humidity sensor value is 45.9 ==> displays as 45 in Vera GUI

Temperature value is good.

Thanks for all your work!!!

Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 21, 2013, 08:41:16 am
@joek
I don't think the DHT sensor gives any decimals on humidity. Please have a look at the DHT library for more details.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: chowda633 on October 21, 2013, 11:10:43 am
Just ordered everything very excited too start playing with everything. great work!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on October 21, 2013, 11:58:52 am
http://code.mios.com/trac/mios_arduino-sensor/browser/VeraArduino/Arduino/libraries

I did manage ti find this also but how can I download the complete libraries folder from here? When I have downloaded other things from the site there has been a possibility to download as Zip Archive from a link at the bottom of the page. Now I can only get one file at the time, is this really the only way?

What am I overlooking? Sorry for being such a noob but I'm no software developer...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 21, 2013, 12:24:48 pm
http://code.mios.com/trac/mios_arduino-sensor/browser/VeraArduino/Arduino/libraries

I did manage ti find this also but how can I download the complete libraries folder from here? When I have downloaded other things from the site there has been a possibility to download as Zip Archive from a link at the bottom of the page. Now I can only get one file at the time, is this really the only way?

What am I overlooking? Sorry for being such a noob but I'm no software developer...

korttoma, please use version 1.2.1 for now. As I explained a couple of pages up we're in a phase of heavy development right now and the git repo does not hold any working version. The wiki will be updated as soon as I release beta of 1.3.

You can download the 1.2.1 zip here:
http://forum.micasaverde.com/index.php/topic,16170.msg130599.html#msg130599
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on October 21, 2013, 12:55:18 pm
Thanks hek!
I just want to get aquainted with the whole Arduino consept so version makes no differance to me.
Placed an order for the hardware today so I guess i have a month or so befor it gets here.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on October 21, 2013, 03:35:42 pm
@joek
I don't think the DHT sensor gives any decimals on humidity. Please have a look at the DHT library for more details.

Take a look at the screenshot output using a DHT22 sensor. Output shows humidity with 1/10 accuracy.

Thanks!

Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: 4integration on October 21, 2013, 03:39:57 pm
@joek

Have you tried to change the line
Code: [Select]
vera.sendVariable(0, V_HUM, humidity);
to

Code: [Select]
vera.sendVariable(0, V_HUM, humidity, 2);
Last number, how many decimals you want. Not tested though but it's an easy change for you to test :)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on October 21, 2013, 03:46:55 pm
@joek

Have you tried to change the line
Code: [Select]
vera.sendVariable(0, V_HUM, humidity);
to

Code: [Select]
vera.sendVariable(0, V_HUM, humidity, 2);
Last number, how many decimals you want. Not tested though but it's an easy change for you to test :)

Yes that addressed my concern.  Thank you for the suggestion! Since DHT22 outputs to 1/10 precision I used the following:

Code: [Select]
vera.sendVariable(0, V_HUM, humidity, 1);
Now Vera GUI shows humidity as expected.

Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on October 25, 2013, 09:23:29 pm
Any chance of adding "DoorLock1" to the sensor choice in the Vera.cpp file?  or how I could do it ?
Thanks
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 26, 2013, 03:39:39 am

Any chance of adding "DoorLock1" to the sensor choice in the Vera.cpp file?  or how I could do it ?
Thanks

Yes, I'll will add it. Is it a standard device type in vera?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on October 26, 2013, 09:04:50 am
@hek,

Yes it is a standard device type.

Thanks it's much appreciated
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 26, 2013, 03:09:30 pm
Regarding formats and units. After some consideration I will only implement one configuration options in the arduino gw plugin.

Unit: Metric/Imperial

A sensor can fetch this setting from vera and report its value in the unit user wants..

Metric == Celsius, m, cm, m/s, ...
Imperial == Fahrenheit, ft, gallon, ...

Pretty funny articles regarding metric vs imperial I stumbled upon while searching:
http://blog.philenotfound.com/2010/07/why-do-americans-insist-on-being.html
http://www.science20.com/hammock_physicist/metric_vs_imperial_end_epic_battle
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clandmeter on October 28, 2013, 05:42:46 am
Hi, Im not able to clone http://code.mios.com/git/mios/arduino-sensor.git it keeps asking me for username/password.
Is there an anonymous way to clone it?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: 4integration on October 28, 2013, 05:55:46 am
Hi, Im not able to clone http://code.mios.com/git/mios/arduino-sensor.git it keeps asking me for username/password.
Is there an anonymous way to clone it?

Try:
http://code.mios.com/git_public/mios/arduino-sensor.git
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clandmeter on October 28, 2013, 06:22:28 am
Hi, Im not able to clone http://code.mios.com/git/mios/arduino-sensor.git it keeps asking me for username/password.
Is there an anonymous way to clone it?

Try:
http://code.mios.com/git_public/mios/arduino-sensor.git

Thanks!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: ChrisK on October 28, 2013, 04:15:02 pm
I put together a sensor using a Teensy.  It has two ultrasonic transducers for distance, and 8 contact closures acting as motions sensors.  This is using version 1.21 of the software as the basis. 

The distance sensors work perfectly.  The 8 motion sensors show up, but only 6 respond.  It looks like the messages are sent correctly but 7 and 8 never show motion.  Is there a limitation that would cause this behavior?

There is something else peculiar, focusing on motion sensor 1, which is really a reed switch and magnet.  Usually it works correctly.  However, sometimes it seems to be just the opposite of what it should be, i.e. motion when it should show no motion.  At first I suspected a flakey reed switch, but as I monitored messages sent via the serial monitor, they were correct.  It is as if it got out of sync.  I need to do more trouble shooting, but wonder if anyone else has run across this sort of behavior? 

Finally, my contact closures will actually be monitoring doors.  Is there a more appropriate icon that represents open and closed doors instead of motion that I could use in a Vera Lite?

Many thanks,
Chris

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 28, 2013, 04:30:22 pm
I put together a sensor using a Teensy.  It has two ultrasonic transducers for distance, and 8 contact closures acting as motions sensors.  This is using version 1.21 of the software as the basis. 

The distance sensors work perfectly.  The 8 motion sensors show up, but only 6 respond.  It looks like the messages are sent correctly but 7 and 8 never show motion.  Is there a limitation that would cause this behavior?

There is something else peculiar, focusing on motion sensor 1, which is really a reed switch and magnet.  Usually it works correctly.  However, sometimes it seems to be just the opposite of what it should be, i.e. motion when it should show no motion.  At first I suspected a flakey reed switch, but as I monitored messages sent via the serial monitor, they were correct.  It is as if it got out of sync.  I need to do more trouble shooting, but wonder if anyone else has run across this sort of behavior? 

Finally, my contact closures will actually be monitoring doors.  Is there a more appropriate icon that represents open and closed doors instead of motion that I could use in a Vera Lite?

Many thanks,
Chris

No limitation I know about..

Maybe you need to pull down the pin (to ground) correctly. Please have a look at the attached picture. A 10kOhm resistor would work fine.

You can perhaps use S_DOOR instead of S_MOTION.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: ChrisK on October 30, 2013, 12:13:42 pm
Maybe you need to pull down the pin (to ground) correctly. Please have a look at the attached picture. A 10kOhm resistor would work fine.

You can perhaps use S_DOOR instead of S_MOTION.

Thanks for the suggestion.  I was actually grounding the pin simulating the reed switch with a jumper.  With the actual reed switch in place, the input is switching from 0.00V to VCC.  I am using the internal pullups.   

I'll do more testing this weekend when time permits.

Thanks,
Chris
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clandmeter on October 31, 2013, 01:05:32 pm
I would like to start using the adruino sensors with my new veralite.
Because I'm still new to vera and never touched arduino before i have a few questions.

One of the sensors I would like to add first is a "door lock sensor".
Because the front-door lock is the only way to detect if there is anybody in home, I would like to trigger some scenes based on it.
One of the solutions to detect a locked door is by using a sensor like: http://shop.igs-hagen.de/Riegelschaltkontakt-VdS-Klasse-C-ohne-Kabel-mit-Loetanschluessen
The only problem with this sensor is its price (around 25 euro inc shipping).
I've seen some sensors which seem interesting like: http://www.robotshop.com/en/sfe-photo-interrupter-gp1a57hrj00f.html
This seems like a interesting solution (based on price) but its probably hard to including in my door frame.

My questions is, are they alternate solution that would be possible to use with the arduino plugin?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on October 31, 2013, 01:29:12 pm
@clandmeter

You could probably use the interruptor with an Arduino yes. But I guess you'll have to google a bit to see how to connect them.

Here is an example.
http://hobbybotics.com/projects/hobbybotics-photo-interrupter-v1-0/
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on November 04, 2013, 04:40:13 pm
1.3 Beta 1

http://forum.micasaverde.com/index.php/topic,17371.0.html
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on November 06, 2013, 04:06:20 pm
Unsuccessful in sending a message to a sensor using "Test Luup code" in Vera GUI.

Can someone pls give an example how I can send a message to a sensor node from Vera using v1.3beta?

I've asked the question prior and received code below, but not sure what value to use for radioId and deviceId or if the syntax changed in v1.3.

Code: [Select]
luup.call_action("urn:upnp-arduino-cc:serviceId:arduino1", "SendCommand",
                 {radioId="2", variableId="VAR_1", value="500"},
                 <deviceId>)

On the Arduino sensor I used the following code to receive:

Code: [Select]
if (gw.messageAvailable()) {
    message_s message = gw.getMessage();
    Serial.println("my message received");
    Serial.println(message.data);
  }

Thanks,
Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on November 06, 2013, 04:45:16 pm
radioId == the devices altId under advanced tab (for example "1;2")
deviceId == the device# under settings tab of device you want to send to.

Note.. I have not tested this in the new version yet.. So please give some feedback.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on November 07, 2013, 09:14:27 pm
@axill and @garrettwp

Do you think this would be make for suitable hardware for an Ethernet gateway?

http://www.ebay.com/itm/Ethernet-Shield-W5100-Arduino-Main-Board-2009-UNO-ATMega-328-1280-MEGA2560-/400356634583?pt=LH_DefaultDomain_0&hash=item5d371d6fd7

More info:
http://arduino.cc/en/Main/ArduinoBoardEthernet

It would need some work on the SPI selects or could use the SD card select?

EDIT:
Ethernet and Arduino:

http://www.ebay.com/itm/UNO-R3-2012-MEGA328PU-ATMEGA16U2-Arduino-Compatible-Ethernet-Shield-W5100-/290961146094?pt=LH_DefaultDomain_0&hash=item43bea2c0ee

Or all on the one PCB:
https://www.sparkfun.com/products/11229
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: martinholmin on November 08, 2013, 06:22:59 am
I finally got my my final shipment from China. The radio modules of course. So I will try to get some soldering done during the weekend. Haven't been this excited by a project for very long. Thanks @hek and all other contributors.

Does anyone have some schematic or a picture on how to solder the small voltage regulators for the radio modules? I guess my soldering and coding skills are good, but i can't brag about the electronics stuff  :)

Cheers,

/Martin

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on November 08, 2013, 07:15:27 am
@martin

http://www.farnell.com/datasheets/578820.pdf

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on November 08, 2013, 07:43:06 am
radioId == the devices altId under advanced tab (for example "1;2")
deviceId == the device# under settings tab of device you want to send to.

Note.. I have not tested this in the new version yet.. So please give some feedback.

Confirmed it does work with v1.3beta. I used the node altid for radioId - in my case that's 2;255 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: martinholmin on November 08, 2013, 04:04:43 pm
Happiness!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on November 10, 2013, 04:55:49 pm
Morning all,

Has anyone yet done a sketch to emulate a Zwave light switch? Basically a relayactuator which also has a push button input to toggle the load? The arduino side shouldn't be too difficult( combine relayactuator with ButtonStateChange sketch), but we also need to tell vera that the load has been toggled, else it will toggle it back at the next refresh....

So how do i send this message back to vera??

Then i've been thinking, what if a milliseconds after pressing the button vera does its refresh and send back the incorrect state? ( id say the chances are quite small of this happening) So what if the arduino/vera kept a "state counter" to prevent an earlier state overiding a newer one?
eg:
statecounter=10 - the light is off.
statecounter=11 - the light was turned on by vera ui
statecounter=12  - the light was turned off by push button  ( vera needs to know! )


Or is this unnecessary as vera only sends the messages when it thinks there is a statechange?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on November 10, 2013, 05:11:50 pm
Morning all,

Has anyone yet done a sketch to emulate a Zwave light switch? Basically a relayactuator which also has a push button input to toggle the load? The arduino side shouldn't be too difficult( combine relayactuator with ButtonStateChange sketch), but we also need to tell vera that the load has been toggled, else it will toggle it back at the next refresh....

So how do i send this message back to vera??

No problem, to set/send variable state to vera side (when user pushed the toggle button). Just call:
gw.sendVariable(<childId>, V_LIGHT, "1");

Where "1"== on  and "0" == off.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on November 11, 2013, 05:23:02 am
Thanks Hek.

Here is my modified code with a single button to toggle the relay state... It works but can get out of sync with the state displayed in Vera...will keep looking, but appreciate an experts eye.


Code: [Select]
#include <Relay.h>

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



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

#define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 1

#define RELAY_ON 0
#define RELAY_OFF 1

int buttonPin = 5;    // pushbutton with 10k pulldown
int buttVal;
int previousVal;
int state;
long time = 0;         // the last time the output pin was toggled
long debounce = 200;   // the debounce time, increase if the output flickers


#define CHILD_ID 3   // Id of the sensor child


Relay gw(9,10);
Sleep sleep;



void setup() 

  Serial.begin(BAUD_RATE);  // Used to write debug info

  gw.begin(RADIO_ID);

  // Set buttonPin as Input
  pinMode(buttonPin, INPUT);
  state = digitalRead(buttonPin); //read initial state

  // Register all sensors to gw (they will be created as child devices)
  for (int i=0; i<NUMBER_OF_RELAYS;i++) {
    gw.sendSensorPresentation(RELAY_1+i, S_LIGHT);
  }

  // Fetch relay status
  for (int i=0; i<NUMBER_OF_RELAYS;i++) {
    // Make sure relays are off when starting up
    digitalWrite(RELAY_1+i, RELAY_OFF);
    // Then set relay pins in output mode
    pinMode(RELAY_1+i, OUTPUT);   
     
    // Request/wait for relay status
    gw.getStatus(RELAY_1+i, V_LIGHT);
    setRelayStatus(gw.getMessage()); // Wait here until status message arrive from gw
  }
 
}


/*
*  Example on how to asynchronously check for new messages from gw
*/
void loop()
{
  //Serial.println("begin loop");
 if (gw.messageAvailable()) {
 message_s message = gw.getMessage();
  setRelayStatus(message);
}


  buttVal = digitalRead(buttonPin);      // read input value and store it in val

   if (buttVal == HIGH && previousVal == LOW && millis() - time > debounce) {
    if (state == HIGH){
      gw.sendVariable(CHILD_ID, V_LIGHT, state);
      digitalWrite(CHILD_ID, state);
      state = LOW;
    }
    else {
      gw.sendVariable(CHILD_ID, V_LIGHT, state);
      digitalWrite(CHILD_ID, state);
      state = HIGH;
    } 
    time = millis();   
  }

     previousVal = buttVal;

    }
 
 
 

void setRelayStatus(message_s message) {
  if (message.header.messageType=M_SET_VARIABLE &&
      message.header.type==V_LIGHT) {
     int incomingRelayStatus = atoi(message.data);
     // Change relay state
     digitalWrite(message.header.childId, incomingRelayStatus==1?RELAY_ON:RELAY_OFF);
     // Write some debug info
     Serial.print("Incoming change for relay on pin:");
     Serial.print(message.header.childId);
     Serial.print(", New status: ");
     Serial.println(incomingRelayStatus);
   }
}
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on November 11, 2013, 06:58:07 am
I have not tried it.. but something like this.

Note that there still could be inconsistency if the updated status message from sensor never reaches gateway. Maybe the gateway also should send an ack message back to sensor to fix this flaw. I'll see what I can do tonight..

Code: [Select]
#include <Relay.h>

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



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

#define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 1

#define RELAY_ON 0
#define RELAY_OFF 1

int buttonPin = 5;    // pushbutton with 10k pulldown
int buttVal;
int switched = 0;
int previousVal;
int state;
long pressTime = 0;         // the last time the output pin was toggled
long debounce = 200;   // the debounce time, increase if the output flickers


#define CHILD_ID 3   // Id of the sensor child


Relay gw(9,10);
Sleep sleep;



void setup() 

  Serial.begin(BAUD_RATE);  // Used to write debug info

  gw.begin(RADIO_ID);

  // Set buttonPin as Input
  pinMode(buttonPin, INPUT);
  buttVal = digitalRead(buttonPin); //read initial state

  // Register all sensors to gw (they will be created as child devices)
  gw.sendSensorPresentation(RELAY_1, S_LIGHT);

  // Make sure relays are off when starting up
  digitalWrite(RELAY_1, RELAY_OFF);
  // Then set relay pins in output mode
  pinMode(RELAY_1, OUTPUT);   
     
  // Request/wait for relay status
  gw.getStatus(RELAY_1, V_LIGHT);
  setRelayStatus(gw.getMessage()); // Wait here until status message arrive from gw
 
}


/*
*  Example on how to asynchronously check for new messages from gw
*/
void loop()
{
  //Serial.println("begin loop");
  if (gw.messageAvailable()) {
    message_s message = gw.getMessage();
    setRelayStatus(message);
  }

  buttVal = digitalRead(buttonPin);      // read input value and store it in val

  if (buttVal == HIGH && previousVal == LOW) {
      pressTime = millis();
      switched = 0;
   }

   // Swith state if button pressed more than 200 msec
   if (buttVal == HIGH && switched == 0 && millis() - pressTime > debounce) {
     state = state==1?0:1;
     digitalWrite(RELAY_1, state==1?RELAY_ON:RELAY_OFF);
     gw.sendVariable(RELAY_1, V_LIGHT, state);
     switched = 1;
     Serial.print("Button pressed, new state:");
     Serial.println(state);
    }
 
    previousVal = buttVal;

}
 
 
 

void setRelayStatus(message_s message) {
  if (message.header.messageType=M_SET_VARIABLE &&
      message.header.type==V_LIGHT) {
     state = atoi(message.data);
     // Change relay state
     digitalWrite(message.header.childId, state==1?RELAY_ON:RELAY_OFF);
     // Write some debug info
     Serial.print("Incoming change for relay on pin:");
     Serial.print(message.header.childId);
     Serial.print(", New status: ");
     Serial.println(state);
   }
}
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on November 11, 2013, 04:20:59 pm
HI Hek - thanks that seems more reliable. Will continue to test!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on November 14, 2013, 11:02:58 am
I have a question about the serial port config on a Vera 3. I'm running the latest Beta release and it appears to be working for me.

But ---
In the serial tab on Vera the device number comes up as "usb-rt3883-ohci-1" but in the docs it says
"usb-rt3883-ehci-2.5"  ???
Am I doing something wrong ? Also the USB light flashes constantly, is that normal ?

Please don't think I'm complaining , just want to know if I'm doing things correctly.
Great App by the way !
Thanks
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on November 14, 2013, 12:45:57 pm
It is probably ok. Don't really know how vera names serial devices.. 

It you want it to flash less (it flashes when there is serial data traffic). Open vera.h (in libraries) and comment out debug flag at the top.

// DEBUG

Re-compile and upload code to vera gateway.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: pcarneyhome on November 15, 2013, 01:59:26 pm
Question about relays

Hek this is really great stuff! I'm really blown away. Well here goes with a dumb question, but i'm a tinkerer at best, so most of this stuff is over my head. My question is about using the Relay node. I downloaded the latest updates and installed Plugin 1.2+, placed library files under the Arduino folder into Arduino IDE and got my Gateway to work and to see a motion sensor (yeah me!). I know it's simple for someone who knows what they are doing, but huge learning curve for me. I just can't seem to get the RelayActuator.ino to be recognized by my VeraGateway. I suspect it has something to do with the AVR folder that came in the download, but don't know what to do with it. Do i replace individual library files into the Arduino library? Or replace the whole folder? Thanks again!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on November 15, 2013, 02:34:07 pm
What do you mean by "recognized"? Are you able to download the RelayActuator to a an arduino board? If so.. try to turn on Tools->"Serial monitor" to see what is going on (baud rate 115200).

You don't need AVR folder. Just delete it.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: chowda633 on November 27, 2013, 12:42:18 pm
hek this stuff is amazing just trying to get it too work now lol.

Followed the Wikki new to the arduino stuff. What I have so far is it showing up in the UI5 I got the gateway plugin working. Its all plugged into the vera. Now every time I try to load a sketch I get all kinds of errors in the Arduino program. I have never used it before so I am still learning. I tried copying and pasting the code into it and tried loading it from the library I can't get it too work at all. What am I doing wrong?

Every time I hit the upload button I get things like this.

Getting close too getting this stuff working I think.

sketch_nov27a:3: error: expected unqualified-id before numeric constant
sketch_nov27a:5: error: expected unqualified-id before numeric constant
sketch_nov27a:7: error: expected unqualified-id before numeric constant
sketch_nov27a:9: error: expected unqualified-id before numeric constant
sketch_nov27a:2: error: expected unqualified-id before numeric constant
sketch_nov27a:9: error: expected unqualified-id before numeric constant
sketch_nov27a:10: error: expected unqualified-id before numeric constant
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on November 28, 2013, 05:59:09 am
sketch_nov27a:3: error: expected unqualified-id before numeric constant
sketch_nov27a:5: error: expected unqualified-id before numeric constant
sketch_nov27a:7: error: expected unqualified-id before numeric constant
sketch_nov27a:9: error: expected unqualified-id before numeric constant
sketch_nov27a:2: error: expected unqualified-id before numeric constant
sketch_nov27a:9: error: expected unqualified-id before numeric constant
sketch_nov27a:10: error: expected unqualified-id before numeric constant

This does not say much....
Try downloading everything as a zip. Make sure to install all provided libraries in the Arduino IDE. Under libraries/Vera/examples/ you'll find all example sketches. Open one of the in the Arduino IDE and test to compile.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: chowda633 on November 28, 2013, 01:44:19 pm
Ok thanks for the quick reply. On the Arduino site reading the basics on how too use these things. I think I got too learn how to operate the Arduino first lol.

sketch_nov27a:3: error: expected unqualified-id before numeric constant
sketch_nov27a:5: error: expected unqualified-id before numeric constant
sketch_nov27a:7: error: expected unqualified-id before numeric constant
sketch_nov27a:9: error: expected unqualified-id before numeric constant
sketch_nov27a:2: error: expected unqualified-id before numeric constant
sketch_nov27a:9: error: expected unqualified-id before numeric constant
sketch_nov27a:10: error: expected unqualified-id before numeric constant

This does not say much....
Try downloading everything as a zip. Make sure to install all provided libraries in the Arduino IDE. Under libraries/Vera/examples/ you'll find all example sketches. Open one of the in the Arduino IDE and test to compile.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on November 28, 2013, 11:14:55 pm
Hi Guys,

Last week i got my latest delivery of cheap Arduino Nano's, and another bunch of radios, motion sensors etc.  Exciting moment indeed!

But i had a problem....the radios did not seem to want to properly communicate.. i rechecked my connections 100 times..tested the cables,checked all pins worked as inputs/outputs and voltages ok.....but nothing wanted to work.  :'(

I tried from the RF24 library the example sketches..still no luck, so i had a look on google and found this to be a common problem! It looks like some of the 3.3v regulators are not so great and the solution is to connect a capacitor between 3.3v and GND.
I tried a few poly caps i had on hand..no luck, but then i tried some 100uF electros and instantly it all started to work!!!
The thread i found for more info is: http://forum.arduino.cc/index.php?topic=171611.0

Im happy again!!!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on November 28, 2013, 11:52:16 pm
@gregl

I ordered a batch of the following socket boards to avoid any issues with the NRF24L01, hope they work correctly:

http://www.aliexpress.com/item/10-pieces-of-Socket-Adapter-Module-Board-for-NRF24L01-Wireless-module-Free-Registered-Shipping/1317308017.html

-Tomas
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on November 29, 2013, 12:12:06 am
Hi Thomas.

Id say they definitely will help to avoid this issue i had.

The reason i went with the Nanos for my sensors was to prevent having to mess around with a 3.3v regulator as needed if you use  a pro-mini ( which does not have the 3.3v out ).
I was able to get the Nanos for $6.80 AUS so think im still in front...

In my masterplan for Hek's excellent plugin, is to use 123d.circuits.io/circuits to design some pcb's which would have a socket for a nano, a radio and terminals for connecting sensors.
I was thinking of a series of these which we could have an "actuator pcb with 2 relays and two button input terminals. These could replace zwave radios...tucked behind my switchplates for much lower cost. ( sh*t load more effort) but lots more fun...

Anyway, time to go drink some beer!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on November 30, 2013, 07:38:13 pm
Pulse sensor example sketch added:

http://code.mios.com/trac/mios_arduino-sensor/wiki/EnergyMeterPulseSensor

Capture you whole house consumption by placing a small light sensor on your house meter counting the blinks. The sketch code converts this into KWH and Watts and sends it back to your Vera wirelessly.


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: twistedsanity on December 01, 2013, 05:26:50 am
Awsome I've been looking into seeing if I could do this and you've just handed it out on a plate. You absolute star, thank you so so much. I plan to make three of these, gas, electricity and a battery powered water. The water meter is about 10 to 12 metres away from the property 40cm deep under a cover on a public footpath, so may be a bit more of a challenge to make it work.

Sent from my GT-I9300 using Tapatalk

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dvbit on December 01, 2013, 04:56:38 pm
Battery Pack...
Hek could this be ok for the sensors?

http://www.aliexpress.com/item/2pcs-Battery-Holder-Box-Case-w-Wire-3-X-AAA-4-5V-Switch/496408284.html

Or
http://www.aliexpress.com/item/Free-Shipping-10pcs-lot-Plastic-Battery-Holder-Case-Box-3-AAA-LR03-For-Flashlight-Torch/834970435.html
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 01, 2013, 05:40:31 pm
@Dvbit
Sorry, I cannot help you on choosing batterypack. I have still not done any battery testing myself.

Someone else?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on December 01, 2013, 06:35:50 pm
Awsome I've been looking into seeing if I could do this and you've just handed it out on a plate. You absolute star, thank you so so much. I plan to make three of these, gas, electricity and a battery powered water. The water meter is about 10 to 12 metres away from the property 40cm deep under a cover on a public footpath, so may be a bit more of a challenge to make it work.

Sent from my GT-I9300 using Tapatalk

Agreed - truly awesome stuff Hek!

@Twistedsanity, to power your remote water meter sensor, you could use one of these to "charge" a battery/supercap..
http://www.seeedstudio.com/depot/36v-micro-hydro-generator-p-634.html?cPath=1
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: RichardTSchaefer on December 01, 2013, 06:38:37 pm
@hek
Bravo!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: twistedsanity on December 01, 2013, 07:41:05 pm
Awsome I've been looking into seeing if I could do this and you've just handed it out on a plate. You absolute star, thank you so so much. I plan to make three of these, gas, electricity and a battery powered water. The water meter is about 10 to 12 metres away from the property 40cm deep under a cover on a public footpath, so may be a bit more of a challenge to make it work.

Sent from my GT-I9300 using Tapatalk

Agreed - truly awesome stuff Hek!

@Twistedsanity, to power your remote water meter sensor, you could use one of these to "charge" a battery/supercap..
http://www.seeedstudio.com/depot/36v-micro-hydro-generator-p-634.html?cPath=1

As much as I would like to, I'm not sure the water company would be too pleased with me attaching that to the side of the meter, nor would the council like me digging up the path to do so. Over here the water meter is in a hole about 20cm dia, and at quite a depth with hardly any room. But great idea. I will probably go with a lithium ion pack and try to plan only for a yearly charge.

Sent from my TouchPad using Tapatalk 4
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: RichardTSchaefer on December 01, 2013, 11:00:01 pm
For outdoor use you should be able to rig up a solar charger and rechargeable battery and extend the battery life considerably.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on December 02, 2013, 04:35:22 pm
Hi Hek,
With the energy meter, in the code comments you say
Code: [Select]
// Unfortunately millis() won't increment when the Arduino is in
// sleepmode. So we cannot make this sensor sleep if we also want
// to calculate/report watt-number.

What if you asked from vera the time then calculate on the arduino?

Cheers,
Greg
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on December 02, 2013, 07:54:19 pm
Hi Hek,

Can you advise on the below... I'm trying to combine the motion sensor sketch with the relayactuator sketch. Here is the code:

Code: [Select]
#include <Relay.h>
#include <SPI.h>
#include <EEPROM.h> 
#include <RF24.h>

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

#define RELAY_PIN  4  // Arduino Digital I/O pin number for relay use 5,6
#define BUTTON_PIN  5  // Arduino Digital I/O pin number for button (with 10k pulldown) use 7,8

#define RLY_CHILD_ID 1   // Id of the sensor child

#define RELAY_ON 0
#define RELAY_OFF 1
#define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)

#define MS_CHILD_ID 0   // Id of the sensor child

Sensor gw(9,10);

int buttVal;
int previousVal;
int state;
int switched = 0;
long pressTime = 0;    // the last time the button pin was pressed
long debounce = 200;   // the debounce time, increase if the output flickers


void setup() 

  Serial.begin(BAUD_RATE);  // Used to type in characters
  gw.begin(RADIO_ID);
  pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
  pinMode(BUTTON_PIN, INPUT);  // Set buttonPin as Input
 
  // Register all sensors to gw (they will be created as child devices)
  gw.sendSensorPresentation(MS_CHILD_ID, S_MOTION);
  gw.sendSensorPresentation(RLY_CHILD_ID, S_LIGHT);

  buttVal = digitalRead(BUTTON_PIN); //read initial state

// Make sure relays are off when starting up
  digitalWrite(RELAY_PIN, RELAY_OFF);
  // Then set relay pins in output mode
  pinMode(RELAY_PIN, OUTPUT);   
     
  // Request/wait for relay status
  gw.getStatus(RLY_CHILD_ID, V_LIGHT);
  setRelayStatus(gw.getMessage()); // Wait here until status message arrive from gw

}

void loop()     
{
// Motion Sensor Section - Start
  // Read digital motion value
  boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
   
  Serial.println(tripped);
  gw.sendVariable(MS_CHILD_ID, V_TRIPPED, tripped?"1":"0");  // Send tripped value to gw
// Motion Sensor Section - End 

// Relay Actuator Section - Start 
if (gw.messageAvailable()) {
    // ot new messsage from gw
    message_s message = gw.getMessage();
    setRelayStatus(message);
  }

  buttVal = digitalRead(BUTTON_PIN);      // read input value and store it in val

  if (buttVal == HIGH && previousVal == LOW) {
      // Start counter from when button was pressed
      pressTime = millis();
      switched = 0;
   }

   if (buttVal == HIGH && switched == 0 && millis() - pressTime > debounce) {
     // Switch state if button pressed more than 200 msec
     state = state==1?0:1;
     gw.sendVariable(RLY_CHILD_ID, V_LIGHT, state); // We will receive an ack message
     switched = 1; // No more switches until button is released
    }
    previousVal = buttVal;
// Relay Actuator Section - End
 
}



void setRelayStatus(message_s message) {
  if (message.header.type==V_LIGHT) { // This could be M_ACK_VARIABLE or M_SET_VARIABLE
     state = atoi(message.data);
     // Change relay state
     digitalWrite(RELAY_PIN, state==1?RELAY_ON:RELAY_OFF);
     // Write some debug info
     Serial.print(message.header.messageType == M_ACK_VARIABLE ? "Button":"Gateway");
     Serial.print(" change. New state: ");
     Serial.println(state == 1 ?"on":"off" );
   }
}

Not many changes than just a merge. I did rename the childid's, removed the sleeping so the relay could be controlled at any time.

All works ok... however looking at the serial output of the sketch, it is constantly relaying messages (flooding), and control of the output relay is intermittant...i think due to the flooding:

Log output from the sketch:
Code: [Select]
Relaying message back to gateway.
Sending message: from=7, to=0, childId=0, mtype=1, type=16, crc=211, payload='0', sent via 0
Sent successfully
0
Relaying message back to gateway.
Sending message: from=7, to=0, childId=0, mtype=1, type=16, crc=211, payload='0', sent via 0
Sent successfully
0
Relaying message back to gateway.
Sending message: from=7, to=0, childId=0, mtype=1, type=16, crc=211, payload='0', sent via 0
Sent successfully
0
Relaying message back to gateway.
Sending message: from=7, to=0, childId=0, mtype=1, type=16, crc=211, payload='0', sent via 0
Sent successfully
0
Relaying message back to gateway.
Sending message: from=7, to=0, childId=0, mtype=1, type=16, crc=211, payload='0', sent via 0
Sent successfully
0
Relaying message back to gateway.
Sending message: from=7, to=0, childId=0, mtype=1, type=16, crc=211, payload='0', sent via 0
Sent successfully
0
Relaying message back to gateway.
Sending message: from=7, to=0, childId=0, mtype=1, type=16, crc=211, payload='0', sent via 0
Sent successfully
0
Relaying message back to gateway.
Sending message: from=7, to=0, childId=0, mtype=1, type=16, crc=211, payload='0', sent via 0
Sent successfully
0
Relaying message back to gateway.
Sending message: from=7, to=0, childId=0, mtype=1, type=16, crc=211, payload='0', sent via 0
Sent successfully
0
Relaying message back to gateway.
Sending message: from=7, to=0, childId=0, mtype=1, type=16, crc=211, payload='0', sent via 0
Sent successfully
0

I thought this was perhaps because its repeating its own messages? all other arduino's are powered down. So i changed "Relay gw(9,10);" to "Sensor gw(9,10);" - same thing occurs.

As i now write this, is the "Relaying message back to gateway" making me think that its in "relay mode" but really the message should be something like "Sending message back to gateway" as in  its nothing to do with the radio relay function. Certainly the device appears in Vera as "Arduino NODE 7"
If so i guess what i need to do is only send the motion device output 7:0 every so often....5secs? But is even that too frequent?? but then i should use the interupt function in case it detects motion...and send immediately!

Your thoughts?

Cheers,
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 03, 2013, 01:26:03 am
Hi Hek,
With the energy meter, in the code comments you say
Code: [Select]
// Unfortunately millis() won't increment when the Arduino is in
// sleepmode. So we cannot make this sensor sleep if we also want
// to calculate/report watt-number.

What if you asked from vera the time then calculate on the arduino?

Cheers,
Greg

I don't think it would be accurate enough..  microsecond precision  But maybe someone could could compare  the results when fetching time from vera.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 03, 2013, 01:30:09 am
Quote
void loop()     
{
// Motion Sensor Section - Start
  // Read digital motion value
  boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
   
  Serial.println(tripped);
  gw.sendVariable(MS_CHILD_ID, V_TRIPPED, tripped?"1":"0");  // Send tripped value to gw


Here you must check if tripped value has changed since last loop before sending the value to vera..
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on December 04, 2013, 08:05:04 am
I've found it's not possible to power the nRF24L01+ directly from the 3.3v pin on the Mega2560 Arduino board. After searching the internet others have reported the same problem. Some have used a decoupling capacitor with success.

To get around the problem I've used three rectifier diodes in series connected to 5v off the Mega2560. I also successfully used a 3.3v regular off the 5v to power the radio. Either works fine.

I hope this may save someone else time in their development!

Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on December 09, 2013, 08:02:59 am
Very similar to what korttoma posted. I would rather not use three dimmable devices (but may be needed for vera control). I would like to create a new device where you can set the hue, saturation, and brightness. Similar to what the Philips Hue Bulbs can do. This would make it very easy for my app AutHomation to support it as I already support the Philips Hue and MiLight / LimitlessLED RGB bulbs with a color wheel.

Since your plugin allows to send variables to the sensor nodes, we can send the required data to the arduino that handles the rgb led strips with the values. The code for rgb arduino can handle converting either hue, saturation, and brightness (HSV) or rgb values to change the strips.

I am trying to find a more cost effective way to the Philips Hue rgb strips with out the expensive price tag and overcome the limitation of what the MiLight / LimitlessLED has.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 09, 2013, 08:33:29 am
Yes, this would work fine! Thanks for the link korttoma!
You could even create your own device type with 3 slides if you want a nicer vera gui. I'll add it to the repo when or if you choose this solution.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: RichardTSchaefer on December 09, 2013, 10:00:28 am
What is the range on the wireless outdoors (i.e. no obstructructions) ? This may be perfect for an outdoor lighting project I am planning.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: martinholmin on December 09, 2013, 11:28:00 am
I'm slowly starting to get things running. Still got some problems getting the Pro Minis working with the radio chip, but i'll try out to add a capacitor after the voltage regulator.

Regarding the voltage regulator i can recommend to get LE33's from ELFA (If you live in the Nordics). Price was pretty decent. (Well, price didn't matter after soldering a couple of SOT23's :D)

My biggest concern right now is how to mount the sensors around the house. I would like to have small clean white boxes where the "lid" can be customized based of sensor type. If any of you have a solution where the WAF > 9 please share some pictures.

I have also been thinking about creating a custom PCB combining the pro mini and the radio chip. Would anyone be interested in that? It should obviously be called the "hekboard"

I can't thank you enough hek for this initiative. I haven't had a project this fun for a long time.

Cheers

/Martin
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: RichardTSchaefer on December 09, 2013, 12:16:23 pm
How fast could a group of sensor respond to change requests (i.e. at what change rate ?)
    Rate/sensor ?
    Rate/controller ?

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 09, 2013, 02:08:21 pm

What code base should I be working from 1.3beta1? I am going to need to spend some time looking over the code to understand it all. A lot has changed since this project first started. Is there anything I need to know?

- Garrett

You should look at HEAD which contains the latest bugfixes:
http://code.mios.com/git_public/mios/arduino-sensor.git/tree/HEAD?js=1

I'm drafting a CLA based on apache (http://www.apache.org/licenses/icla.txt) for contributors. Hope that is ok for you?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 09, 2013, 03:13:46 pm
How fast could a group of sensor respond to change requests (i.e. at what change rate ?)
    Rate/sensor ?
    Rate/controller ?

If the gateway has direct contact with a sensor the reaction time is  faster than my z-wave devices. You could probably send 5-10 requests/updates per second. I have no multi-hop statistics. But with 2 hops I see almost no latency either.. The problem is that you never know when vera decides to do something else which blocks all other execution for a while. :)



Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on December 09, 2013, 03:46:22 pm
Hek, I am in the process of updating my test arduinos with the new code. I found that the isMetricSystem is not working correctly. It seems to always return true. I copied the code for the Dallas Temp sketch into the DHT sketch. Not sure what is going on. The Vera is set to Imperial. The serial output for the DHT sensor node shows that the value is I, however the metric variable returns true no matter what.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on December 09, 2013, 04:18:32 pm
Hek,

Another issue. How do I get a sensor to show up in Vera? The gateway is connected to Vera and it is recieving data from a sensor using the DHT humidity sketch. However the child devices are not being generated. I could not find any instructions on how to add sensors with the new code changes from 1.2dev.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on December 09, 2013, 04:22:21 pm
Hi Garrett,

Did you update the plugin in Vera also?
If so then the "Arduino Gateway plugin " device will show ver 1.2+ and have an Start Stop buttons for Including new devices. ( Also make sure you updated the sketch on the g/w arduino )
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on December 09, 2013, 04:36:04 pm
All files on Vera were updated. New sketches were updated to new versions. I tried hitting the start button and the logs showed that inclusion mode was set, however it stops not long after.

- Garrett

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 09, 2013, 04:42:32 pm
Hek, I am in the process of updating my test arduinos with the new code. I found that the isMetricSystem is not working correctly. It seems to always return true. I copied the code for the Dallas Temp sketch into the DHT sketch. Not sure what is going on. The Vera is set to Imperial. The serial output for the DHT sensor node shows that the value is I, however the metric variable returns true no matter what.

Thanks, a fix has been commited!



EDIT: Replied the wrong message!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 09, 2013, 04:50:54 pm
Hek,

Another issue. How do I get a sensor to show up in Vera? The gateway is connected to Vera and it is recieving data from a sensor using the DHT humidity sketch. However the child devices are not being generated. I could not find any instructions on how to add sensors with the new code changes from 1.2dev.

- Garrett

Sometimes vera has problems adding child devices if you previously deleted a child-device with the same "altId". Vera hides the device but it is still stored somewhere (sometimes...).. To be sure that deleted devices really is gone try restarting your vera box. Setup->Net wifi->Reboot.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on December 09, 2013, 10:10:53 pm
Hek,

I rebooted my development Vera and still I can not get the sensors to add to Vera. To make sure I understand the new process, to include a new sensor, I hit the start button on the Vera dashboard to include new sensors? Do I do anything on the sensor side? This is what I get in the log:

Code: [Select]
08 12/09/13 22:06:56.478 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x2fa30680>
08 12/09/13 22:06:56.478 JobHandler_LuaUPnP::HandleActionRequest argument action=LogIpRequest <0x2fa30680>
08 12/09/13 22:06:56.478 JobHandler_LuaUPnP::HandleActionRequest argument IpAddress=192.168.20.181 <0x2fa30680>
08 12/09/13 22:06:56.479 JobHandler_LuaUPnP::HandleActionRequest argument MacAddress=bc:52:b7:31:df:29 <0x2fa30680>
02 12/09/13 22:07:05.100 LOG_CHECK_MEMORY_LEAK pMem start 0x104f000 now 0x1051000 last 0x104f000 leaked 8192 <0x2bbef680>
08 12/09/13 22:07:34.970 JobHandler_LuaUPnP::HandleActionRequest device: 132 service: urn:upnp-arduino-cc:serviceId:arduino1 action: StartInclusion <0x2f430680>
08 12/09/13 22:07:34.970 JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=132 <0x2f430680>
08 12/09/13 22:07:34.970 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:upnp-arduino-cc:serviceId:arduino1 <0x2f430680>
08 12/09/13 22:07:34.970 JobHandler_LuaUPnP::HandleActionRequest argument action=StartInclusion <0x2f430680>
08 12/09/13 22:07:34.971 JobHandler_LuaUPnP::HandleActionRequest argument rand=0.354310002643615 <0x2f430680>
01 12/09/13 22:07:34.972 luup_log:132: Arduino: Sending command: 0;0;4;6;1 <0x2f430680>
01 12/09/13 22:07:34.986 luup_log:132: Arduino: 0;0;4;6;1 <0x308aa680>
01 12/09/13 22:07:34.987 luup_log:132: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,InclusionMode, 1, 132 <0x308aa680>
06 12/09/13 22:07:34.987 Device_Variable::m_szValue_set device: 132 service: urn:upnp-arduino-cc:serviceId:arduino1 variable: InclusionMode was: 0 now: 1 #hooks: 0 upnp: 0 v:0xb91d60/NONE duplicate:0 <0x308aa680>
01 12/09/13 22:07:34.988 luup_log:132: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,InclusionFoundCountHR, 0 devices found, 132 <0x308aa680>
06 12/09/13 22:07:34.988 Device_Variable::m_szValue_set device: 132 service: urn:upnp-arduino-cc:serviceId:arduino1 variable: InclusionFoundCountHR was:  now: 0 devices found #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x308aa680>
01 12/09/13 22:07:34.989 luup_log:132: Arduino: 0;0;4;6;0 <0x308aa680>
01 12/09/13 22:07:34.990 luup_log:132: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,InclusionMode, 0, 132 <0x308aa680>
06 12/09/13 22:07:34.990 Device_Variable::m_szValue_set device: 132 service: urn:upnp-arduino-cc:serviceId:arduino1 variable: InclusionMode was: 1 now: 0 #hooks: 0 upnp: 0 v:0xb91d60/NONE duplicate:0 <0x308aa680>
01 12/09/13 22:07:34.991 luup_log:132: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,InclusionFoundCountHR, , 132 <0x308aa680>
06 12/09/13 22:07:34.991 Device_Variable::m_szValue_set device: 132 service: urn:upnp-arduino-cc:serviceId:arduino1 variable: InclusionFoundCountHR was: 0 devices found now:  #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x308aa680>
01 12/09/13 22:07:34.992 luup_log:132: Arduino: Inclusion mode ended. <0x308aa680>


- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on December 09, 2013, 10:14:15 pm
Hi Garrett, cab you post a log from your sensor?  If its not being assined a radio id, then it probably needs adding a capacitor as mentioned a few posts back.

Sent from my Nexus 5 using Tapatalk

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on December 09, 2013, 10:20:15 pm
I got it to finally include. It was being assigned an radio id previously. I pulled in the change that Hek made for the isMetricSystem fix and copied the files over to the library directory. I must have not had one of the files copy over. I reflashed all of the arduinos and finally got it to find the new devices. Sorry for the noise in thread.

I am going to start working on getting the rgb code.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 10, 2013, 01:30:20 am
No problem,

There was a previous problem with inclusion mode (it only lasted for <1 second). Only affected people using arduino gateway sketch with  previous 2-argument constructor (now minimum three arguments). This was fixed a week ago.  You seems to have used the older constructor/code...

Glad it works better now!

 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on December 10, 2013, 01:47:07 am
That is what it appears to be. I think I copied it over from the 1.3beta1 branch before switching to the head branch. It appears to be working. Have not had much time to play with it. Now time to poke around and see what needs to be done to get led control working.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on December 12, 2013, 04:20:03 am
@garrettwp

What's happening re: using an IP connected gateway?

As far as I can see the main problem is that the Ethernet Wiznet Chip and the Nordic RF chip both have to co-exist on the same SPI bus. Seems that should be possible! It is unlikely a second software SPI implementation is required. Just need to implement some slave selects? Software wise it looks fairly easy - just need to sort the SPI bus.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: C4Vette on December 12, 2013, 01:04:32 pm
Wow, what a great project!
My compliments to all developers, I really like this stuff.
Still have to buy a Vera but this projects is a real bonus.
The problem with all those different domotica controllers is that none of them is ideal for all stuff I would like to connect but this project sure helps and also fits perfectly my hobby-needs.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on December 13, 2013, 04:00:30 am
I had a look at using an Ethernet connection for the gateway using this hardware:

http://arduino.cc/en/Main/ArduinoBoardEthernet

The pin mappings have been set up in the test code to allow the Ethernet IC and the radio to share the SPI bus.

For debugging the IP connection is on port 80, so I can easily send some gibberish to it via a browser. The interchange is echoed out the serial port, so it can be monitored - refer code. Here is the result of the test code:

Test URL:

http://IP_ADDRESS_OF_ARDUINO?Hello_Test

Gibberish rx'ed by Arduino:

Code: [Select]
GET /?Hello_Test HTTP/1.1
Host: xxx.xx.xx.60
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive

Arduino's reaction:

Code: [Select]
0;0;4;11;Arduino startup complete.
xxx.xx.xx.60
GET /?Hello_Test HTTP/1.1
0;0;4;11;Relaying message back to gateway.
0;0;4;11;Sending message: from=0, to=0, childId=1, mtype=13, type=8, crc=209, payload='', sent via 0
0;0;4;11;Send failed. No ack received.
Host: xxx.xx.xx.60
0;0;4;11;Relaying message back to gateway.
0;0;4;11;Sending message: from=0, to=0, childId=1, mtype=13, type=8, crc=209, payload='', sent via 0
0;0;4;11;Send failed. No ack received.
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0
0;0;4;11;Relaying message back to gateway.
0;0;4;11;Sending message: from=0, to=0, childId=0, mtype=0, type=8, crc=57, payload='', sent via 0
0;0;4;11;Send failed. No ack received.
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
0;0;4;11;Relaying message back to gateway.
0;0;4;11;Sending message: from=0, to=0, childId=1, mtype=13, type=8, crc=209, payload='', sent via 0
0;0;4;11;Send failed. No ack received.
Accept-Language: en-US,en;q=0.5
0;0;4;11;Relaying message back to gateway.
0;0;4;11;Sending message: from=0, to=0, childId=0, mtype=13, type=8, crc=148, payload='', sent via 0
0;0;4;11;Send failed. No ack received.
Accept-Encoding: gzip, deflate
0;0;4;11;Relaying message back to gateway.
0;0;4;11;Sending message: from=0, to=0, childId=1, mtype=13, type=8, crc=209, payload='', sent via 0
0;0;4;11;Send failed. No ack received.
Connection: keep-alive
0;0;4;11;Relaying message back to gateway.
0;0;4;11;Sending message: from=0, to=0, childId=1, mtype=13, type=8, crc=209, payload='', sent via 0
0;0;4;11;Send failed. No ack received.

0;0;4;11;Relaying message back to gateway.
0;0;4;11;Sending message: from=0, to=0, childId=1, mtype=13, type=8, crc=209, payload='', sent via 0
0;0;4;11;Send failed. No ack received.

The demo code could be altered, so the GET line only was extracted and actual radio commands inserted in  the test URL - purely for testing.

"gateway.cpp" needs some sort of flag, so it knows whether to use IP writes or to use the serial connection as the interface. Likewise, if using an IP connection, the serial connection could be used to echo information as required based on a serial debug on/off flag?

"gateway.cpp" also needs a pointer to the Ethernet Server server object, so it can perform Ethernet writes().

Not sure if this would work but a gw.useIP(pointer_to_object, echoToSerial) function could be invoked to change the mode from the default of serial to use an IP interface?

Test code - uses DHCP:

Code: [Select]
/*
Copyright (C) 2013 Henrik Ekblad <henrik.ekblad@gmail.com>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.

DESCRIPTION:
The ArduinoGateway prints data received from sensors on the serial link.
The gateway accepts input on the client interface, which is then sent out to the radio network.

The GW code is designed for Arduino Nano 328p / 16MHz
NOTE: the ATmega168 does not have enough memory to run this program

Wire connections (OPTIONAL):
- Inclusion button should be connected between the digital pin defined by INCLUSION_MODE_PIN and GND
- TX/RX/ERROR LEDs need to be connected between +5V (anode) and the digital pins defined by RADIO_TX_LED_PIN,
-    RADIO_RX_LED_PIN and RADIO_ERROR_LED_PIN with a 270 to 330 Ohm resistor in series

LED utilisation:
- RX (green)  - blink fast on radio message received. In inclusion mode will blink fast only on presentation received
- TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
- ERR (red)   - fast blink on error during transmission error or receive CRC error

*/

#include <Ethernet.h>   // http://arduino.cc/en/Reference/Ethernet
#include <SPI.h> 
#include <EEPROM.h> 
#include <RF24.h>
#include <MsTimer2.h>
#include <PinChangeInt.h>
#include <Gateway.h> 
#include <stdarg.h>
#include <avr/progmem.h>

/*
Arduino Ethernet w/o PoE
http://arduino.cc/en/Main/ArduinoBoardEthernet
17  SCL  (not used)
16  SDA  (not used)
15  AREF (not used)
14  GND
13  Radio & Ethernet SPI SCK          (a LED on some PCBs)
12  Radio & Ethernet SPI MISO         
11  Radio & Ethernet SPI MOSI         
10  Ethernet SPI Slave Select         (Pin 10, the SS pin, must be an o/p to put SPI in master mode)
9   Radio TX LED using on board LED   
8   Radio RX LED
7   Radio error LED
6   Radio SPI Slave Select
5   Radio Chip Enable
4   SD card SPI Slave Select
3   Inclusion mode button             (10K pull down to GND, button to VCC)
2   Radio IRQ pin                     (W5100 Int, if linked to pin 2)
1   TX to FTDI
0   RX to FTDI
*/

#define INCLUSION_MODE_TIME 1  // Number of minutes inclusion mode is enabled
#define INCLUSION_MODE_PIN  3  // Digital pin used for inclusion mode button

// sensor PCBs: RF24 radio(9,10) ---> this Ethernet PCB: RF24 radio(5,6);
#define RADIO_CE_PIN        5  // radio chip enable
#define RADIO_SPI_SS_PIN    6  // radio SPI serial select
#define RADIO_ERROR_LED_PIN 7
#define RADIO_RX_LED_PIN    8
#define RADIO_TX_LED_PIN    9  // the PCB, on board LED

#define IP_PORT 80 

// MAC address as seen on underside of PCB
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x04, 0x21 };

// a R/W server on the port
EthernetServer server = EthernetServer(IP_PORT);

Gateway gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN, INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, RADIO_RX_LED_PIN, RADIO_TX_LED_PIN, RADIO_ERROR_LED_PIN);

// if LED blinking and include mode button are not required, use this constructor instead
//Gateway gw(RADIO_CE_PIN, RADIO_SPI_SS_PIN, INCLUSION_MODE_TIME);

// a string to hold incoming commands from client interface
String inputString = "";

void ledTimersInterrupt()
{
   gw.ledTimersInterrupt();
}

void startInclusionInterrupt()
{
   gw.startInclusionInterrupt();
}

void processCommands()
{
   // if an incoming client connects, there will be
   // bytes available to read via the client object
   EthernetClient client = server.available();

   if (client)
   {
      // read the bytes incoming from the client
      char inChar = client.read();

      // echo the bytes to the serial port
      Serial.print(inChar);

      // if newline then command is complete
      if (inChar == '\n')
      {  // a command was issued by the client
         // we will now try to send it to the actuator
         gw.parseAndSend(inputString);
     
         // clear the string:
         inputString = "";
      }
      else
      {  // add it to the inputString:
         inputString += inChar;
      }
   }
}

void setup() 
{
   // reserve bytes for the inputString. RadioId;ChildId;VAR=VALUE
   inputString.reserve(MAX_RECEIVE_LENGTH);

   // serial baud rate is set here to 115,200 - see VeraAVR.h
   gw.begin();
 
   Ethernet.begin(mac);

   Serial.println(Ethernet.localIP());
 
   // give the Ethernet interface a second to initialize
   delay(1000);

   // start listening for clients
   server.begin();

   // C++ classes and interrupts really sucks. Need to attach interrupt
   // outside the Gateway class due to language shortcomings! Gah!
   if (gw.isLedMode())
   {
      // add LED timer interrupt
      MsTimer2::set(300, ledTimersInterrupt);
      MsTimer2::start();

      // add interrupt for inclusion button to pin
      PCintPort::attachInterrupt(INCLUSION_MODE_PIN, startInclusionInterrupt, RISING);
   }
}

void loop()
{
   // check for incoming commands from clients
   processCommands();
   
   // has any new message been received from one of the radio sensors?
   gw.processRadioMessage();
}

Code compiles to 30,724 bytes out of 32,256 bytes - so getting close to maxed out!!

So interested in comments or has someone else almost completed this?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 13, 2013, 05:34:59 am
Nice work. Ouch.. 30724 bytes... ))

I have ordered a
http://www.ebay.co.uk/itm/300960761285?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

Will do some tests myself during holidays if it reaches me in time...



Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on December 13, 2013, 05:43:12 am
What about using a Spark Core for the Ethernet interface. Or use a 702n router. Save on memory if its critical.

Sent from my Nexus 5 using Tapatalk

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on December 14, 2013, 12:25:24 pm
I've found it's not possible to power the nRF24L01+ directly from the 3.3v pin on the Mega2560 Arduino board. After searching the internet others have reported the same problem. Some have used a decoupling capacitor with success.

To get around the problem I've used three rectifier diodes in series connected to 5v off the Mega2560. I also successfully used a 3.3v regular off the 5v to power the radio. Either works fine.

I hope this may save someone else time in their development!

Joe

I'm slowly starting to get things running. Still got some problems getting the Pro Minis working with the radio chip, but i'll try out to add a capacitor after the voltage regulator.

Regarding the voltage regulator i can recommend to get LE33's from ELFA (If you live in the Nordics). Price was pretty decent. (Well, price didn't matter after soldering a couple of SOT23's :D)

My biggest concern right now is how to mount the sensors around the house. I would like to have small clean white boxes where the "lid" can be customized based of sensor type. If any of you have a solution where the WAF > 9 please share some pictures.

I have also been thinking about creating a custom PCB combining the pro mini and the radio chip. Would anyone be interested in that? It should obviously be called the "hekboard"

I can't thank you enough hek for this initiative. I haven't had a project this fun for a long time.

Cheers

/Martin

Finally getting around to building my test sensors with the parts I receive about a month ago. A snow storm is happening as we speak so it is a good time to goof around. I just spent a few hours trying to figure out why my Arduino nano was not working with the nrf24 module on the 3v3 rail. I could not get any sensor to send the message to the nano and the ping from the sensor was not being acknowledged from the gateway. One of the things I bought when I ordered my parts was a nrf24 adapter that takes 5v and converts it to 3v3. I decided to give that a try and see what happens. As soon as I hooked up the adapter board, everything started to work. I am going to try and place a capacitor on the 3v3 rail and see if that helps. 

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on December 14, 2013, 05:42:40 pm
Quote
Finally getting around to building my test sensors with the parts I receive about a month ago. A snow storm is happening as we speak so it is a good time to goof around. I just spent a few hours trying to figure out why my Arduino nano was not working with the nrf24 module on the 3v3 rail. I could not get any sensor to send the message to the nano and the ping from the sensor was not being acknowledged from the gateway. One of the things I bought when I ordered my parts was a nrf24 adapter that takes 5v and converts it to 3v3. I decided to give that a try and see what happens. As soon as I hooked up the adapter board, everything started to work. I am going to try and place a capacitor on the 3v3 rail and see if that helps.

I had a couple of nRF24L01 with a sma antenna that I could never get to work. I gave up trying to use them for awhile. Decided to try the capacitor trick and it worked great. I simply Hot Glued a 47uf cap on the back of the nRF24L01 and soldered it directly to the 3v3 in and ground pin.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: bluman on December 15, 2013, 05:10:01 am
Thanks to all those who have contributed to this, Hek your dedication is admirable.

I've bought the hardware to build the gateway, I have a question is regards to downloading from GitHub, how does one obtain the Arduino library files (and others) without copying and pasting into notepad or other software? Is there a specific way to interact with GitHub or a direct download somewhere to access the files? If not, I'd like to host such a download (eg zip files) as a way to contribute to this project.

Sorry for the GitHub newbie question. 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: chris66 on December 15, 2013, 10:45:33 am
@hek, great plugin,

looking at your roadmap  I've read: "Receive/send data to 433Mhz devices. Much of this depends on library support."
Does it mean reading also all kind of devices like Oregon sensors?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Derek Macias on December 15, 2013, 11:30:19 am
Thanks to all those who have contributed to this, Hek your dedication is admirable.

I've bought the hardware to build the gateway, I have a question is regards to downloading from GitHub, how does one obtain the Arduino library files (and others) without copying and pasting into notepad or other software? Is there a specific way to interact with GitHub or a direct download somewhere to access the files? If not, I'd like to host such a download (eg zip files) as a way to contribute to this project.

Sorry for the GitHub newbie question.
If you're in the tree section there will be a menu towards the top that looks like this:

summary | shortlog | log | commit | commitdiff | tree snapshot (tar.gz tar.bz2 zip)

Just click on the archive type you want at the end, for example zip and you will be prompted to download the whole directory tree in zip format.
I didnt figure it out at first either.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 15, 2013, 01:39:11 pm
@hek, great plugin,

looking at your roadmap  I've read: "Receive/send data to 433Mhz devices. Much of this depends on library support."
Does it mean reading also all kind of devices like Oregon sensors?

It might... I've done some test and I could control one of my el-cheapo 433 noname-plugs. I don't have any Oregon sensors to test.. But it all depends on how much the Arduino libraries can handle (i won't write my own).

I've tested with this library: https://bitbucket.org/fuzzillogic/433mhzforarduino/wiki/Home

The module I used was: http://www.ebay.com/itm/433Mhz-RF-Transmitter-And-Receiver-Kit-K0E1-Module-For-Arduino-Project-1PCS-New-/231045507464?pt=AU_B_I_Electrical_Test_Equipment&hash=item35cb62a988 (http://www.ebay.com/itm/433Mhz-RF-Transmitter-And-Receiver-Kit-K0E1-Module-For-Arduino-Project-1PCS-New-/231045507464?pt=AU_B_I_Electrical_Test_Equipment&hash=item35cb62a988).
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: chris66 on December 16, 2013, 03:49:28 am
@hek, very interesting,

As I have different Oregon sensors (Wind Hygro Temp) I could send you some logs (from RFXreceiver and Vera) if it can help, when you will be ready...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: bluman on December 16, 2013, 07:26:33 am
Thanks to all those who have contributed to this, Hek your dedication is admirable.

I've bought the hardware to build the gateway, I have a question is regards to downloading from GitHub, how does one obtain the Arduino library files (and others) without copying and pasting into notepad or other software? Is there a specific way to interact with GitHub or a direct download somewhere to access the files? If not, I'd like to host such a download (eg zip files) as a way to contribute to this project.

Sorry for the GitHub newbie question.
If you're in the tree section there will be a menu towards the top that looks like this:

summary | shortlog | log | commit | commitdiff | tree snapshot (tar.gz tar.bz2 zip)

Just click on the archive type you want at the end, for example zip and you will be prompted to download the whole directory tree in zip format.
I didnt figure it out at first either.

Thanks Derek, I've managed to get the relay actuator working without any issues at all.

Hek I take my hat off to you as this is one of the most simple electronics integration projects I've attempted. My goal is to control my ducted air turning it on and off via its dry contact interface. Thanks again.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 16, 2013, 07:31:10 am
Hek I take my hat off to you as this is one of the most simple electronics integration projects I've attempted. My goal is to control my ducted air turning it on and off via its dry contact interface. Thanks again.

Nice to hear you got it working.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on December 18, 2013, 01:57:41 am
Hek,

For future reference you may want to change the logging for most of the lua code to use code 50 and not 1. So for not critical issues, change the 1 to a 50 for the log() call function.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: bluman on December 18, 2013, 05:45:49 am
Hek,

Would it be possible to expand your already awesome project to include a four push-button remote sensor? My idea is that this would present four virtual switches in the Vera UI which could be used as triggers. They do not necessarily need to control a local relay like your existing sketch, just toggle the virtual switch in the Vera UI.

Other than the Z-Wave Mini Mote there is a distinct lack of Z-Wave wall mount style switches, at least here in Australia.
http://zwave.com.au/index.php?_a=viewProd&productId=14

My experimentation so far shows that your wireless sensor solution is very robust and more responsive than my existing Z-Wave devices.

Unfortunately I am not a coder, however I'm fine with the electronics side of the construction.     

Regards
Bluman
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 18, 2013, 08:04:19 am
Bluman,
You can create up to 255 virtual switches in your sketch by doing:

Code: [Select]
gw.sendSensorPresentation(<CHILD_ID,> S_LIGHT);
Where child id is between 0-255.

Set virtual switch by doing:
Code: [Select]
gw.sendVariable(<CHILD_ID>, V_LIGHT, state);

Where state is 1 or 0.





Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 18, 2013, 08:09:19 am
A little christmas present for you all. My kids and I have put together an Arduino controlled ginger bread castle:

https://www.youtube.com/watch?v=JKzPyGwsXXI

We have not had time to decorate it yet..

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Derek Macias on December 18, 2013, 02:00:17 pm
I read back through the thread but didn't see it mentioned.  I was wondering if a sensor or relay or LCD could be merged with the gateway sketch.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on December 18, 2013, 02:09:19 pm
Where child id is between 0-255.
Henrik,

sorry to comment you  ;)
id should be between 0-254 because NODE_CHILD_ID=255

Regards,
Alexander
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on December 18, 2013, 02:12:14 pm
I read back through the thread but didn't see it mentioned.  I was wondering if a sensor or relay or LCD could be merged with the gateway sketch.
Why not? Just play with gateway sketch as you like keeping the main functionality not broken.
But I will suggest not to add anything to gateway if you plan to build more or less complex network because your gateway need to be fast enough to handle communication.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Derek Macias on December 18, 2013, 03:49:45 pm
I have just been having some zwave issues with Vera in the back room so I'm moving her to the cubby above the fireplace where I already have a arduino relay setup for the gas fireplace. Just thought I might add the relay to the gateway.  I'll give it a go.q
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on December 18, 2013, 05:05:56 pm
Would it be possible to set up a Nrf24L01 and Arduino to simply monitor the traffic on my sensor network. Was thinking I might use the RelayNode sketch to do that but I'm not sure. I would not want it to interfere with normal operations just monitor like when you are using the serial port. My Vera-Arduino Gateway is in an awkward place to use the serial monitor.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on December 18, 2013, 05:16:48 pm
Why not to monitor log file on Vera side? You can use ssh and log remotely and you will be able to monitor radio network through gateway logging
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jackpot on December 18, 2013, 05:46:08 pm
Quote
Why not to monitor log file on Vera side? You can use ssh and log remotely and you will be able to monitor radio network through gateway logging

Thanks,
Yes I have also done that. But if I could see the data using using an Arduino + Radio I could just use just about any dumb terminal over serial.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on December 22, 2013, 05:47:34 am
Merry Christmas!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on December 22, 2013, 05:52:14 am
Merry Christmas!
@korttoma are you launched a watchcat instead of a watchdog?  ;D
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 22, 2013, 07:05:46 am
Merry christmas!

https://www.youtube.com/watch?v=qJ8q5SY96sA
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on December 22, 2013, 09:16:00 am
Merry Christmas!
@korttoma are you launched a watchcat instead of a watchdog?  ;D

Yeah, notifications from watchcat did not work so I had to go arduino ;)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: twistedsanity on December 22, 2013, 04:19:46 pm
Happy Xmas,

Sorry to ask what may seem like a stupid question, but I'm stuck combining multiple elements and not sure if it is possible because of the pins required. Yes I'm not very good with arduino coding but still trying to learn.

Ideally i'm trying to use the 'Energy Meter - Pulse Sensor' twice so I can measure electricity and again to measure my gas consumption. I'm not using the suggested Light sensor but a hall effect sensor as both meters have a magnetic pulse. I have it working as a single sensor device but struggling using more than one. Does anyone have the needed skills and inclination to help? I appreciate no one wants to waste time on a useless individual but any pointers are welcome.

At the same time if possible, which shouldn't be too difficult for me (famous last words) I hope to add a double relay to switch two different devices, a DHT temp and humidity sensor, and a couple of independent distance sensors to make sure the other half or I don't reverse into the back of the garage.

Before I waste too much time should this work or do certain devices need to be split due to the specific type of pin requirement?
Thanks
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: veravance on December 27, 2013, 04:26:37 pm
Hi,
I  installed the plugin in a vera lite but i have this error message
"Arduino plugin : Plugin not correctly installed"

I reloaded the vera but the problem is always here ...

The Gateway is connected throught a usb hub.

Could you help me ?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on December 27, 2013, 06:38:47 pm
make sure that serial port is configured on vera according to plugin wiki
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 28, 2013, 04:57:20 am
At the same time if possible, which shouldn't be too difficult for me (famous last words) I hope to add a double relay to switch two different devices, a DHT temp and humidity sensor, and a couple of independent distance sensors to make sure the other half or I don't reverse into the back of the garage.

It is just to start counting how many digital pins you'll need.
2 - 2x relays
1 - Humidity
4 - 2x distance

= 7 pins, which shouldn't be any problem.

But make sure to power the sensors directly from power source when attaching this many. There is a limitation on how much you can take from the Arduino.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on December 29, 2013, 06:55:55 pm
Hello,

HEK, first off let me say thanks for all the work you did with this project!  I am so excited to have a project like this to work on. 

I am very new to both the Vera and Arduino but I have been reading a lot over the last month.  I have read this thread in it's entirety as well as all the documentation on the wiki.  I thought I followed the instructions completely but I can't get the sensors working.  I initially built the humidity sensor but couldn't pair it with the gateway.  I thought I had done something wrong so I built the light sensor and had the same thing happen.

It looks like the gateway is working correctly because I am seeing activity in the vera logs:
Code: [Select]
08 12/29/13 16:29:07.731 JobHandler_LuaUPnP::HandleActionRequest device: 18 service: urn:upnp-arduino-cc:serviceId:arduino1 action: StartInclusion <0x2e8bf680>
08 12/29/13 16:29:07.732 JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=18 <0x2e8bf680>
08 12/29/13 16:29:07.732 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:upnp-arduino-cc:serviceId:arduino1 <0x2e8bf680>
08 12/29/13 16:29:07.732 JobHandler_LuaUPnP::HandleActionRequest argument action=StartInclusion <0x2e8bf680>
08 12/29/13 16:29:07.732 JobHandler_LuaUPnP::HandleActionRequest argument rand=0.08884167345240712 <0x2e8bf680>
01 12/29/13 16:29:07.733 luup_log:18: Arduino: Sending command: 0;0;4;6;1 <0x2e8bf680>
01 12/29/13 16:29:07.749 luup_log:18: Arduino: 0;0;4;6;1 <0x2d6bf680>
01 12/29/13 16:29:07.749 luup_log:18: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,InclusionMode, 1, 18 <0x2d6bf680>
01 12/29/13 16:29:07.750 luup_log:18: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,InclusionFoundCountHR, 0 devices found, 18 <0x2d6bf680>
02 12/29/13 16:29:10.103 ZW_Send_Data node 5 NO ROUTE (nil) <0x2c2bf680>
04 12/29/13 16:29:10.239 __LEAK__ this:12288 start:1429504 to 0x127d000 <0x2bebf680>
02 12/29/13 16:29:25.101 LOG_CHECK_MEMORY_LEAK pMem start 0x1279000 now 0x127d000 last 0x127a000 leaked 16384 <0x2bebf680>
02 12/29/13 16:29:40.103 ZW_Send_Data node 6 NO ROUTE (nil) <0x2c2bf680>
04 12/29/13 16:29:40.239 <0x2bebf680>
02 12/29/13 16:30:00.100 Energy::LogEnergyUsageOnServer <0x2c0bf680>
02 12/29/13 16:30:00.101 Energy::LogEnergyUsageOnServer 2013-12-29 16:30:00 <0x2c0bf680>
01 12/29/13 16:30:07.739 luup_log:18: Arduino: 0;0;4;6;0 <0x2d6bf680>
01 12/29/13 16:30:07.739 luup_log:18: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,InclusionMode, 0, 18 <0x2d6bf680>
06 12/29/13 16:30:07.740 Device_Variable::m_szValue_set device: 18 service: urn:upnp-arduino-cc:serviceId:arduino1 variable: InclusionMode was: 1 now: 0 #hooks: 0 upnp: 0 v:0xf6c6d0/NONE duplicate:0 <0x2d6bf680>
01 12/29/13 16:30:07.740 luup_log:18: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,InclusionFoundCountHR, , 18 <0x2d6bf680>
06 12/29/13 16:30:07.741 Device_Variable::m_szValue_set device: 18 service: urn:upnp-arduino-cc:serviceId:arduino1 variable: InclusionFoundCountHR was: 0 devices found now:  #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2d6bf680>
01 12/29/13 16:30:07.741 luup_log:18: Arduino: Inclusion mode ended. <0x2d6bf680>

Does anyone have any idea what I'm doing wrong?  I'm not sure what to try next.  Here is a picture of the light sensor in case that helps.

Thanks
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on December 29, 2013, 06:59:57 pm
Looks like the sensor(s) aren't responding or the gateway is not TX/Rxing. Have a look at the serial output of the sensors - what do you see there?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on December 29, 2013, 07:02:39 pm
@hek - I've got the code working to use an IP connected main gateway, rather than a serial connected one. Are you interested in making use of the code? - if so can I PM you?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on December 29, 2013, 07:04:25 pm
The activity you see is an activity of the plugin, not gateway
Try no disconnect gateway arduino from vera and connect to your PC
Inside arduino serial monitor your should see wireless activity coming from your light sensor
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: twistedsanity on December 29, 2013, 07:07:04 pm
Are you sure you are powering the rf24 correctly? I had to use use a 5v pro mini and then stepdown to power the rf24 as I didn't have a 3.3v arduino to hand.

This applies to the gateway and client devices.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on December 29, 2013, 08:01:22 pm
Wow, thanks for the quick replies!

a-lurker and axill, this is what I see in the serial monitor:
Code: [Select]
0;0;4;11;Received: from=255, to=255, childId=255, mtype=4, type=9, crc=184, ''
0;0;4;11;Message crc ok.
0;0;4;11;Answer ping message.
0;0;4;11;Answer ping message. 1
0;0;4;11;Sending: from=0, to=255, childId=255, mtype=4, type=10, crc=34, '0', sent via 255
0;0;4;11;Send failed. No ack received.
0;0;4;11;Received: from=255, to=255, childId=255, mtype=4, type=9, crc=184, ''
0;0;4;11;Message crc ok.
0;0;4;11;Answer ping message.
0;0;4;11;Answer ping message. 1
0;0;4;11;Sending: from=0, to=255, childId=255, mtype=4, type=10, crc=34, '0', sent via 255
0;0;4;11;Send failed. No ack received.

That all looks like gibberish to me.  Any idea what I should do next?


twistedsanity, I'm pretty sure I have the correct power.  I got the SOT23 regulators recommended by HEK in the buying guide.  They are incredibly small (and hard to solder) but I'm getting 3.3v when I test it.

I'm starting to wonder if I'm reading the pin diagram correctly.  Is this the order of the pins?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on December 29, 2013, 08:24:39 pm
In this photo, pin one has a small square box around it on the overlay.

http://code.mios.com/trac/mios_arduino-sensor/attachment/wiki/ConnectingRadioModule/nRF24L01.jpg

Bit hard to see what's happening in your photo but it may be back to front?

http://code.mios.com/trac/mios_arduino-sensor/wiki/ConnectingRadioModule
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on December 29, 2013, 09:02:58 pm
Ok, thanks for clarifying.  I had it connected correctly. Any other ideas what I could be doing wrong?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 30, 2013, 03:43:11 am
@petewill
It looks like your sensor successfully sends a ping/relay request to the GW (to find its neighbors). But when gw tries to reply it does not seem to reach the sensor. So it cannot be entirely wrong.

Have you tried adding a capacitor?
Could you provide the serial log of the sensor as well?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 30, 2013, 05:12:38 am
@hek - I've got the code working to use an IP connected main gateway, rather than a serial connected one. Are you interested in making use of the code? - if so can I PM you?

Sure, send it by email, you'll find my address on the wiki.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on December 30, 2013, 06:54:25 am
@hek - I've got the code working to use an IP connected main gateway, rather than a serial connected one. Are you interested in making use of the code? - if so can I PM you?

Sure, send it by email, you'll find my address on the wiki.

That is awesome news! I guess that is one thing I can take off my list to try and add!

a-lurker,

What ethernet board (chip) are you using? Wiznet? enc28j60?

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jasonfire on December 30, 2013, 10:01:04 am
@hek - I've got the code working to use an IP connected main gateway, rather than a serial connected one. Are you interested in making use of the code? - if so can I PM you?

Sure, send it by email, you'll find my address on the wiki.

That is awesome news! I guess that is one thing I can take off my list to try and add!

a-lurker,

What ethernet board (chip) are you using? Wiznet? enc28j60?

- Garrett

Guys this might answer my question.  I currently use the NX-584e board to connect my CADDAX alarm system to my vera lite via the USB connection.  Is there a way to keep using this setup and use the Arduino Senor Plugin? 

- Jason
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 30, 2013, 10:04:14 am
Use an USB-hub.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on December 30, 2013, 10:06:12 am
a-lurker mentioned in a earlier post that he was going to use the following hardware:
http://arduino.cc/en/Main/ArduinoBoardEthernet

It would be nice to know tough if other hardware combinations have any chance of working.


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 30, 2013, 10:16:49 am
a-lurker mentioned in a earlier post that he was going to use the following hardware:
http://arduino.cc/en/Main/ArduinoBoardEthernet

It would be nice to know tough if other hardware combinations have any chance of working.

I don't see any reason for it not to work with other ethernet modules. Should work the same way. My ENC28J60 modules still haven't arrived.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on December 30, 2013, 10:21:47 am
No! they are different! very different
wiznet - easier to code. a lot of libraries and examples.
enc - much more difficult to code. Only 1 lib. and practically no docs, some examples

so we need to choose wiznet or enc.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on December 30, 2013, 03:18:12 pm
@HEK
Sorry it took me so long to reply.   Anyway, here is the result from the serial monitor:
Code: [Select]
Sending: from=255, to=255, childId=255, mtype=4, type=9, crc=184, '', sent via 255
Send failed. No ack received.
No relay nodes was found. Trying again in 10 seconds.
Sending: from=255, to=255, childId=255, mtype=4, type=9, crc=184, '', sent via 255
Send failed. No ack received.
No relay nodes was found. Trying again in 10 seconds.
Sending: from=255, to=255, childId=255, mtype=4, type=9, crc=184, '', sent via 255
Send failed. No ack received.
No relay nodes was found. Trying again in 10 seconds.

I was reading about adding a capacitor.  I don't have any so I ordered a kit from Amazon.  Hopefully it will be here in the next couple of days so I can try it.  Just so I'm 100% clear I would push it in the wires between the 3.3v and the ground, similar to what you did with the resistor in the humidity sensor, right?

Thanks again for the help!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 30, 2013, 04:44:39 pm
Hi petewill,

Yes, between ground and 3.3V. This will remove some of the ripple on the powerline.

Also try switching radio (if you have a couple of extra) to rule out any hw failure. How far apart are the radios?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on December 30, 2013, 10:26:05 pm
hek,

Thank you.  I will try connecting the capacitor when it arrives.  It's supposed to be here on 1/2/14.

I tried switching out the radio on the gateway and got the same message.  Just for fun I tried connecting/communicating to the other sensor I have built for the DHT22 and I got the same results from the gateway serial monitor.  For the most recent tests I have been doing (using the serial monitor) the radios have been about 1-2 ft apart.

I am currently powering both the Nano and the Pro Mini from USB plugged into the computer.  That's not an issue is it?  The Pro Mini is connected via the FT232RL USB To Serial Adapter.  I am still doing my research on how to power these when not connected to the computer via USB.

Thanks again!

Pete
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on December 31, 2013, 05:25:20 am
No! they are different! very different
wiznet - easier to code. a lot of libraries and examples.
enc - much more difficult to code. Only 1 lib. and practically no docs, some examples

so we need to choose wiznet or enc.

It would be nice to get a-lurkers comment on this since he is the only one with experience of the code he provided.

I tried to look in to the hardware a-lurker used but wiznet or enc is not mentioned, or did I just not look close enough?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on December 31, 2013, 07:27:20 am
No! they are different! very different
wiznet - easier to code. a lot of libraries and examples.
enc - much more difficult to code. Only 1 lib. and practically no docs, some examples

so we need to choose wiznet or enc.

It would be nice to get a-lurkers comment on this since he is the only one with experience of the code he provided.

I tried to look in to the hardware a-lurker used but wiznet or enc is not mentioned, or did I just not look close enough?

The board that he references uses a wiznet 5100 chip.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: scud on December 31, 2013, 07:48:19 am
@hek, I'm having issues similar to petewill. Vera sees the sensor (a BMP085 in my case), creates the node and the sensors, but never receives any measurements after that to be displayed.  I'll try the capacitor this weekend to see if it helps.

WRT the Ethernet shield, there is a library for the ENC the claims compatibility, although I haven't tried it. https://github.com/ntruchsess/arduino_uip

Sal
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on December 31, 2013, 09:32:29 am
@hek, I'm having issues similar to petewill. Vera sees the sensor (a BMP085 in my case), creates the node and the sensors, but never receives any measurements after that to be displayed.  I'll try the capacitor this weekend to see if it helps.

If your node and sensors are being created in vera you have nothing wrong with the communication.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on December 31, 2013, 09:55:30 pm
hek,

I received the capacitors today and I connected a 4.7uF between the ground 3.3v connections on the radio (see picture) but unfortunately that didn't help.  Here is the code I'm getting now:

Code: [Select]
0;0;4;11;Arduino startup complete.
0;0;4;11;Received: from=139, to=139, childId=139, mtype=11, type=184, crc=184, ''
0;0;4;11;Message crc error.
0;0;4;11;Received: from=255, to=255, childId=255, mtype=4, type=9, crc=184, ''
0;0;4;11;Message crc ok.
0;0;4;11;Answer ping message.
0;0;4;11;Answer ping message. 1
0;0;4;11;Sending: from=0, to=255, childId=255, mtype=4, type=10, crc=34, '0', sent via 255
0;0;4;11;Send failed. No ack received.
0;0;4;11;Received: from=255, to=255, childId=255, mtype=4, type=9, crc=184, ''
0;0;4;11;Message crc ok.

I tried uploading the gateway code  to the Nano again but that didn't help. I built everything using version 1.2.  Should I be on the 1.3 beta?

Thanks again for your help!  I can't wait until this is working.  This is by far the most exciting project I have worked on in a couple of years.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on December 31, 2013, 10:00:53 pm
@hek, I'm having issues similar to petewill. Vera sees the sensor (a BMP085 in my case), creates the node and the sensors, but never receives any measurements after that to be displayed.
Sal

Happy New Year all!

Sal - watch the serial monitor ( on your PC) for the arduino sensor... do you see it periodically sending  payload values?
eg:

Mess crc ok.
Received message: from=4, to=0, childId=0, mtype=1, type=1, crc=236, payload='54.4'
Mess crc ok.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 01, 2014, 05:03:30 am

I tried uploading the gateway code  to the Nano again but that didn't help. I built everything using version 1.2.  Should I be on the 1.3 beta?

You should run the latest 1.3 HEAD revision on the gateway and sensors. It won't work if you mix library versions. You will find the latest zip-file to download down at the revision history on wiki.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on January 01, 2014, 11:27:06 am
hek,

It's working!!!!  I downloaded the most recent code from the wiki and re-uploaded it to the gateway and Vera.  I monitored in the serial monitor and it was still giving the same message.  Based on what you said earlier about the power most likely being the cause I decided to connect my pro mini to an external power supply instead of powering via the FT232RL USB To Serial Adapter.  As soon as I did that I got different results in the serial monitor (no more errors).  I then connected the Nano to the Vera and after a couple of reset/refresh cycles (and configuring the serial port) I was able to include the devices.

Thank you SO much for your help with this!!!  I can't wait to put some of these to use!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 01, 2014, 11:39:11 am
Great! Now the fun begins!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on January 02, 2014, 07:00:18 am
Could someone share a sketch file that contains a combination of sensors? I'm having trouble wrapping my head around how to accomplish this.
My goal is to create a sketch to control 2 garage doors using Relays and also monitor their state using reed switches.

I started out from the RelayWithButtonActuator.ino sketch by hek, but in this one all functionality is under one CHILD_ID (1 child device). I guess I will end up with 4 child devices (2 of the type S_LIGHT and 2 with the type S_MOTION). Unless they can be combined in to some kind of door lock type device that probably is not yet supported.

Some example sketches with combinations of several sensors would be greatly appreciated.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: twistedsanity on January 02, 2014, 07:54:11 am
Hopefully no one minds, but here's one I combined.



1x Pulse
4x Relay
1x Humidity
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on January 02, 2014, 08:02:04 am
thanks twistedsanity!

Looks like it is easier than I thought.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on January 02, 2014, 08:09:06 am
Yesterday was a good day!  I got all my sensors working and now I need to order some more! I did have an issue with the distance sensor only showing a 1 or 0 but I need to do some more troubleshooting to find out if maybe the sensor is broken or it's something I messed up. 

One thing I can't figure out is how to get the devices to show imperial units. I had the option selected in the gateway when I created the devices but they still show metric units.  Do I need to do something in the arduino sketch as well?

Thanks.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dagwood08 on January 02, 2014, 12:54:07 pm
Is it possible to use the Arduino based sensors with a Veralite unit and its USB port, or do you need a Vera 3 unit?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 02, 2014, 01:46:26 pm
Is it possible to use the Arduino based sensors with a Veralite unit and its USB port, or do you need a Vera 3 unit?

Yes! You can even run it through a USB-hub if you need more usb-ports.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dagwood08 on January 02, 2014, 01:50:18 pm
Yes! You can even run it through a USB-hub if you need more usb-ports.

Perfect !  Thanks for the quick response.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on January 02, 2014, 07:44:01 pm
I passed on my files for an IP gateway to Hek. Hek was talking about using a ENC28J60 for the IP connection, rather than a WIZnet 5100/5200. This library appears to be the current answer to using the ENC28J60 with the Arduino:

https://github.com/ntruchsess/arduino_uip

So it looks like both could be made use of with minor code fiddling -  hardware wise they seem to use the same pins in both cases. On the code; Hek was talking about using a factory type method, that would allow the user to just set, what's to be printed to.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: JesperJ on January 03, 2014, 06:51:02 am
@hek, I'm having issues similar to petewill. Vera sees the sensor (a BMP085 in my case), creates the node and the sensors, but never receives any measurements after that to be displayed.
Sal

Happy New Year all!

Sal - watch the serial monitor ( on your PC) for the arduino sensor... do you see it periodically sending  payload values?
eg:

Mess crc ok.
Received message: from=4, to=0, childId=0, mtype=1, type=1, crc=236, payload='54.4'
Mess crc ok.

Hi I'm having the same issues with the BMP085 as well.
I don't get any payload values.
Anybody got this working?

From the log...

Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 8
Relaying message back to gateway.
Sending: from=8, to=0, childId=255, mtype=0, type=17, crc=13, '1.2+', sent via 0
Sent successfully
Relaying message back to gateway.
Sending: from=8, to=0, childId=255, mtype=4, type=7, crc=55, '0', sent via 0
Sent successfully
Relaying message back to gateway.
Sending: from=8, to=0, childId=0, mtype=0, type=8, crc=135, '1.2+', sent via 0
Sent successfully
Relaying message back to gateway.
Sending: from=8, to=0, childId=1, mtype=0, type=6, crc=219, '1.2+', sent via 0
Sent successfully
Relaying message back to gateway.
Sending: from=8, to=0, childId=255, mtype=4, type=13, crc=247, '', sent via 0
Sent successfully

/Jesper
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on January 04, 2014, 02:57:30 pm
Hi All,

I was able to get the DHT22 to display temperature in Fahrenheit.  I'm sure there is a better way to do this but I'm very new to Arduino.  So if there is anyone else out there using Fahrenheit instead of Celsius (I wish the US would switch to Metric) here is how to change the code.

I replaced this:
Code: [Select]
float temperature = dht.getTemperature();
with this:
Code: [Select]
float temperature = (dht.getTemperature() * 1.8)+32;
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on January 04, 2014, 03:33:59 pm
Hi All,

I was able to get the DHT22 to display temperature in Fahrenheit.  I'm sure there is a better way to do this but I'm very new to Arduino.  So if there is anyone else out there using Fahrenheit instead of Celsius (I wish the US would switch to Metric) here is how to change the code.

I replaced this:
Code: [Select]
float temperature = dht.getTemperature();
with this:
Code: [Select]
float temperature = (dht.getTemperature() * 1.8)+32;

Your method works.  I am using the included function provided by the library which essentially does the same thing. :-)

Code: [Select]
temperature = dht.getTemperature();  // get temperature from DHT sensor
temperature = dht.toFahrenheit(temperature); // dht library provides conversion from C to F
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on January 04, 2014, 03:58:48 pm
Quote

Hi I'm having the same issues with the BMP085 as well.
I don't get any payload values.
Anybody got this working?


/Jesper

I am successfully using the BMP085 sensor. I had some initial trouble setting up the BMP085, however it's been awhile so don't recall all the details. I ended up modifying Hek's sketch and using Adafruit's latest BMP085 library. There are different versions of the BMP085 - some have on-board regulators which allow you to use a 5v supply. The older versions don't have the regulators and require a 3v supply. I think there may have been other minor differences also.

To troubleshoot your problem, I'd make sure you able to read the data from the BMP085 sensor at the Arduino side first - you can print the BMP data to a serial port and monitor it's values.

Hope that helps some.

Joe

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: MDoc on January 04, 2014, 09:33:47 pm
To troubleshoot your problem, I'd make sure you able to read the data from the BMP085 sensor at the Arduino side first - you can print the BMP data to a serial port and monitor it's values.

Great point Joe,

When getting my stuff going I spent a long night fighting with Vera to read my Nano.  Loaded my Pro minis and played with some sensors while my Nano was being delivered.  Once I got my Nano... loaded it up, loaded the plugin files, got the plugin installed and while Vera was seeing port, it was't reading the Nano (Lib Version blank). 

Finally figured out I hadn't changed the board type in the Arduino IDE before loading it.  It will not error out if you've got a Pro Mini selected  and program the Nano.

Moral of the story,  after loading your sketches, look at the IDE Serial Monitor and verify it got loaded correctly.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: JesperJ on January 05, 2014, 06:58:45 am
Quote

Hi I'm having the same issues with the BMP085 as well.
I don't get any payload values.
Anybody got this working?


/Jesper

I am successfully using the BMP085 sensor. I had some initial trouble setting up the BMP085, however it's been awhile so don't recall all the details. I ended up modifying Hek's sketch and using Adafruit's latest BMP085 library. There are different versions of the BMP085 - some have on-board regulators which allow you to use a 5v supply. The older versions don't have the regulators and require a 3v supply. I think there may have been other minor differences also.

To troubleshoot your problem, I'd make sure you able to read the data from the BMP085 sensor at the Arduino side first - you can print the BMP data to a serial port and monitor it's values.

Hope that helps some.

Joe

Thanks for the reply!

The Adafruit example works fine.
There must be some thing in the sketch that needs to be modifyed.

I'll let you know if i find something.

Jesper
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on January 05, 2014, 09:08:29 am
Hi All,

I was able to get the DHT22 to display temperature in Fahrenheit.  I'm sure there is a better way to do this but I'm very new to Arduino.  So if there is anyone else out there using Fahrenheit instead of Celsius (I wish the US would switch to Metric) here is how to change the code.

I replaced this:
Code: [Select]
float temperature = dht.getTemperature();
with this:
Code: [Select]
float temperature = (dht.getTemperature() * 1.8)+32;

Your method works.  I am using the included function provided by the library which essentially does the same thing. :-)

Code: [Select]
temperature = dht.getTemperature();  // get temperature from DHT sensor
temperature = dht.toFahrenheit(temperature); // dht library provides conversion from C to F

Ha, I guess that works a little better :)  Thanks, that helps me for the future projects I'll be working on.  Remember to check the library...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 05, 2014, 10:52:06 am
Added a new water-meter sensor example (and vera device) developed by kpson.

http://code.mios.com/trac/mios_arduino-sensor/wiki/WaterMeterPulseSensor

(Will soon check in an updated humidity sensor that uses the settings from vera-side to convert temperature)


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on January 05, 2014, 11:03:29 am
@hek just read wiki about water sensor! Cool job!
Planned to do a similar thing but plan to have cold+hot water counters together with tube temperature of both
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: C4Vette on January 05, 2014, 11:05:32 am
Nice addition, but is there anywhere to be found how to attach the optical sensor?
And the WiKi is talking about KWH and watt's  ::)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on January 05, 2014, 11:10:39 am
@C4Vette what kind of optical sensor do your mean?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 05, 2014, 11:14:19 am
Nice addition, but is there anywhere to be found how to attach the optical sensor?
@kpeson might give you a hint here. I have actually not tried this myself yet. But I guess you mound the sensor pointing down through the glass of your water meter (against the turning wheel). Find a location that is triggered each time the wheel turns.

And the WiKi is talking about KWH and watt's  ::)
Sorry, copy-paste error.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on January 05, 2014, 11:14:54 am

(Will soon check in an updated humidity sensor that uses the settings from vera-side to convert temperature)
what about to add a settings that will allow to set the period of reads (SLEEP_TIME)?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 05, 2014, 11:21:10 am

(Will soon check in an updated humidity sensor that uses the settings from vera-side to convert temperature)
what about to add a settings that will allow to set the period of reads (SLEEP_TIME)?

I have no plans for this at the moment (it is pretty sensor type specific). You can always use the VAR1-5 for these kind of individual settings.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on January 05, 2014, 11:22:18 am
@kpeson might give you a hint here.
Do not knew what kpeson uses but my water sensor has a wired output of internal mechanical switch to be used as impulse input. It do not need any optical side.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on January 05, 2014, 11:22:18 am


I have no plans for this at the moment (it is pretty sensor type specific). You can always use the VAR1-5 for these kind of individual settings.
ok. thx!!!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: C4Vette on January 05, 2014, 11:23:01 am
@C4Vette what kind of optical sensor do your mean?
In the wiki Hek linked is the line:
With the following additional parts: 1x ​Water meter pulse sensor
If you follow that link you will end up on ebay: http://www.ebay.com/itm/ws/eBayISAPI.dll?ViewItem&item=330924700585
for a "TCRT5000 IR Barrier Line Track sensor Infrared Reflective Photoelectric Switch"

@Hek: thanks

Ed
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: kpeson on January 05, 2014, 11:45:42 am
I haven't tried out the optical sensor jet.It?s ordered but haven?t arrived.
Of course it?s best if the meter has it?s own wired output.
I use an old IFM laser sensor,but i think a new one is out of budget.

If someone knows how to sense the little red pointers on the meter please let us know.

//Kpeson
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: twistedsanity on January 05, 2014, 12:04:18 pm
I could be wrong but the optical sensor is normally used for meters that have the flashing pulse led (newer meters), as mine are older versions I use hall effect sensors as they output a magnetic pulse one is generated for the purpose of logging and the other meter is an old disc type which outputs a pulse from one point on the disc.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 05, 2014, 01:07:38 pm
kpeson also found this one (not tested either):
http://lowpowerlab.com/shop/index.php?route=product/product&product_id=53

@twistedsanity
Which hall effect sensor would you recommend? I'll add that as well to the wiki.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 05, 2014, 01:24:10 pm
Ok, Just checked in an updated version of the humidity sensor which picks up unit setting from vera and sends in the correct temp-format.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Salmoides on January 05, 2014, 09:58:27 pm

Thanks for the reply!

The Adafruit example works fine.
There must be some thing in the sketch that needs to be modifyed.

I'll let you know if i find something.

Jesper

@Jesper

Comment out the "#define DEBUG" statement in Sensor.h and repush the PressureSensor sketch. See if your values show up in the interface.

Sal
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: blacey on January 06, 2014, 12:23:18 am
Ok, Just checked in an updated version of the humidity sensor which picks up unit setting from vera and sends in the correct temp-format.

Works like a champ!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: JesperJ on January 06, 2014, 10:55:39 am

Thanks for the reply!

The Adafruit example works fine.
There must be some thing in the sketch that needs to be modifyed.

I'll let you know if i find something.

Jesper

@Jesper

Comment out the "#define DEBUG" statement in Sensor.h and repush the PressureSensor sketch. See if your values show up in the interface.

Sal

Now it works perfekt!

Thanks!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: JesperJ on January 06, 2014, 03:08:08 pm
I also have problems with the relay acuator nodes.
The work fine for a while but then they stop responding.
If i look in the logs it seems to be when i get the "Answer ping message."
I don't know if this is the relaying function?

It is node 4 that stops.

Here are two different logs.


"Received: from=5, to=0, childId=1, mtype=1, type=0, crc=166, '26.9'
Message crc ok.
Remove child node from routing table.
Received: from=5, to=255, childId=255, mtype=4, type=9, crc=235, ''
Message crc ok.
Answer ping message.
Answer ping message. 1
Sending: from=4, to=5, childId=255, mtype=4, type=10, crc=185, '1', sent via 5
Sent successfully"


"Received: from=5, to=0, childId=1, mtype=1, type=0, crc=43, '23.5'
Message crc ok.
Remove child node from routing table.
Received: from=5, to=255, childId=255, mtype=4, type=9, crc=235, ''
Message crc ok.
Answer ping message.
Answer ping message. 1
Sending: from=4, to=5, childId=255, mtype=4, type=10, crc=185, '1', sent via 5
Sent successfully
Received: from=6, to=5, childId=255, mtype=4, type=10, crc=67, '1'
Message crc ok.
Remove child node from routing table.
Received: from=3, to=5, childId=255, mtype=4, type=10, crc=211, '1'
Message crc ok.
Remove child node from routing table."

Jesper
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 07, 2014, 03:46:26 am
Was the logs above from the relaying node (that relays messages from another node)?

[Does anyone have a better name for relaying node (that passes messages) and relays that you attach to switch stuff on/off? The similar naming can easily cause some confusion...]

There have been some reports of instability in the gateway. This might also affect relaying nodes.
Axill is currently doing some investigation of using watchdogs to keep things running more stable.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on January 07, 2014, 04:04:45 am
Hi hek, how about "forwarder" or "repeater".

Sent from my Nexus 5 using Tapatalk

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: JesperJ on January 07, 2014, 04:09:53 am
The logs are from a relaying node that uses the sketch "Relay acuator".
No on/off commands has been sent to to Relays, just radio traffic that it picks up.
Yesterday i changed from the relay class to sensor class in the sketch and now if seems to be running ok.

Jesper
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 07, 2014, 04:30:58 am
Hi hek, how about "forwarder" or "repeater".

Thanks. "Repeater" or "RepeaterNode" sounds better.

 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on January 07, 2014, 06:40:56 am
Hi, Hek!
I'm going to test water flow sensor. But I cant understand how it will work in "SLEEP_MODE = True" condition. I mean this code:
Code: [Select]
void onPulse()     
{
  if (!SLEEP_MODE)
  {
    unsigned long newBlink = micros();   
    unsigned long interval = newBlink-lastBlink;
lastPulse = millis();
    if (interval>500000L) {                                          // Sometimes we get interrupt on RISING,  500000 = 0.5sek debounce ( max 120 l/min)
      flow = (60000000.0 /interval) / ppl;
      lastBlink = newBlink;
  //Serial.println(flow, 4);
  pulseCount++;                                                  // PulseCount protected with debonce
    }
  }
}
in this mode nothing will increment the pulseCount value...

Am i wrong?

thx.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 07, 2014, 03:32:18 pm
Am i wrong?

Your right. Should probably look like this:

Code: [Select]
void onPulse()     
{
  if (!SLEEP_MODE) {
    unsigned long newBlink = micros();   
    unsigned long interval = newBlink-lastBlink;
lastPulse = millis();
    if (interval<500000L) {
      // Sometimes we get interrupt on RISING,  500000 = 0.5sek debounce ( max 120 l/min)
      return;   
    }
   
    flow = (60000000.0 /interval) / ppl;
    lastBlink = newBlink;
    //Serial.println(flow, 4);
  }
  pulseCount++;
}
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: kpeson on January 07, 2014, 04:47:56 pm
You are right Mitekdg,..my misstake.I have never tested sleepmode.

I moved the PulseCount++ line to get a little debounce.Some times i got flickering from sensor,and didn?t want pulseCount to increase.
Quick fix is to move it back as hek suggested,but you loose the debounce.
Maybee you can coppy the second if state  and place it before puleCount,to get debounce.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dagwood08 on January 08, 2014, 03:40:57 pm
I noticed in some of the photos of the gateway that there is an antenna mounted.  However, the parts list to build the gateway only lists 2 boards and some jumper cables.  I don't see any mention of an antenna.  Where does the antenna come into playand what does it connect to?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: twistedsanity on January 08, 2014, 03:53:33 pm
Its just a variation on the rf module, you can buy them with an sma connector and anntena for a bit more money. But it isn't necessarily needed unless you are using it over a longer distance.

Sent from my GT-I9300 using Tapatalk

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dagwood08 on January 08, 2014, 05:14:15 pm
Thanks for the explanation.  This is all new to me so there's quite a learning curve.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: twistedsanity on January 08, 2014, 05:27:12 pm
No problem at all, it is a huge learning curve for me too, but enjoying every minute. Also due to not being made of money, and love 'playing' with electronics I get the best of both worlds with this incredible addition to my HA system. Thanks hek  ;D

The only one thing I'm still keeping my fingers crossed for is some sort of security level implemented so that I can start using it for things I'm currently weary of, i.e. valve control and maybe more.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Salmoides on January 09, 2014, 07:01:53 pm
No problem at all, it is a huge learning curve for me too, but enjoying every minute. Also due to not being made of money, and love 'playing' with electronics I get the best of both worlds with this incredible addition to my HA system. Thanks hek  ;D

Me 2. I have no clue what I'm doing. Haven't programmed in years. I've never seen an Arduino until now. I've been enjoying Vera and automation, and now, all because of Hek, I'm having a heck :o of a time playing with all these thing. Learning a lot.

Now back to work - my next challenge, how to make a sensor work at 3.3v for a year on two AA batteries and turn the light on in the closet when I open the door. This is good stuff. Thanks, Hek.
Title: Questions about Sketch files or sharing a sketch
Post by: korttoma on January 10, 2014, 12:01:21 am
If anyone have questions about Arduino sketches or have a nice sketch to share please turn to the following topic, this topic is getting a bit to long:

http://forum.micasaverde.com/index.php/topic,22334.0.html
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gremlin57 on January 11, 2014, 02:53:01 pm
Does this work on Vera 1 with UI4?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 12, 2014, 03:59:26 am
Does this work on Vera 1 with UI4?

Probably not, I have never tested the plugin in UI4 and I thing the josn files need tweaking to work. Someone should probably also test that the Arduino Nano USB is recognized.
 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: sener on January 12, 2014, 08:35:10 pm
Hi Hek,
I congratulate you for this marvelous project. Although I am not Vera user, I ended up here. I have been dealing with a similiar project for a while using Arduino Uno and Arduino Pro mini. I have given a try to your libraries with success. For now, one thing was not ok with me.
It is in the humidity sensor project.

#1. I don't see hum. and temp. reading on the serial monitor.

#2. I don't receive proper reading on either gateway or relay. When it is started, it takes value of "1.2+" and next time "0" and then always "" (empty).

Any idea?

Sample Reading on the serial monitor:

Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 2
Relaying message back to gateway.
Sending: from=2, to=0, childId=255, mtype=0, type=17, crc=52, '1.2+', sent via 0
Sent successfully
Relaying message back to gateway.
Sending: from=2, to=0, childId=255, mtype=4, type=7, crc=14, '0', sent via 0
Sent successfully
Relaying message back to gateway.
Sending: from=2, to=0, childId=0, mtype=0, type=7, crc=65, '1.2+', sent via 0
Sent successfully
Relaying message back to gateway.
Sending: from=2, to=0, childId=1, mtype=0, type=6, crc=226, '1.2+', sent via 0
Sent successfully
Relaying message back to gateway.
Sending: from=2, to=0, childId=255, mtype=4, type=13, crc=206, '', sent via 0
Sent successfully
Relaying message back to gateway.
...
...


Regards,
Sener
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 13, 2014, 03:55:06 am
Any idea?

Double check the wiring of your humidity sensor. Are you feeding it with 3.3 or 5V?
Maybe you could test the sensor separately using examples under /libraries/DHT/examples/DHT_Test/

BR
Henrik
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: JesperJ on January 13, 2014, 04:16:35 am

Any idea?


Comment out the "#define DEBUG" statement in Sensor.h

That worked for me.

Jesper
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 13, 2014, 04:56:13 am
Hmm.. so enabling debug prints is affecting variable sending somehow.. this is definitely a bug that has to be addressed.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: ChrisK on January 13, 2014, 11:56:29 am
I have a question about missed data.  I put together a temperature probe for my refrigerator.  I want to be notified if the temperature goes close to freezing.  Since the temperature shouldn't change that much, it could be a while before the sensor sends data. 

My concern is that it sends data, but the data is not received.  Is there a way to know if transmissions are missed at the gateway side?

Thanks,
Chris
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on January 13, 2014, 12:22:42 pm
I have a question about missed data.  I put together a temperature probe for my refrigerator.  I want to be notified if the temperature goes close to freezing.  Since the temperature shouldn't change that much, it could be a while before the sensor sends data. 

My concern is that it sends data, but the data is not received.  Is there a way to know if transmissions are missed at the gateway side?

Thanks,
Chris

The code is developed that if the incoming data from the sensor is the same as what Vera has, it will not update the sensor. However, if the value is different it will update the variable in Vera. This is to prevent un-needed changes to the device.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 13, 2014, 12:51:17 pm
I actually update LAST_UPDATE of the device even if temp-variable isn't updated. so by looking at this you can determine if communication is ok.
 
@Garrett, is this a ok behavior? Or should LAST_UPDATE-variable only update when temp-variable does?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Peter on January 13, 2014, 01:03:44 pm
Can I use this gateway also to make a connection between de vera and a arduino mega through a ethernet connection?
There is a cool dutch project called nodo http://www.nodo-domotica.nl/nodoinfo.html.
This arduino board can be used for recieving/sending infrared and rf 433mhz devices.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: ChrisK on January 13, 2014, 02:02:02 pm
Quote
I actually update LAST_UPDATE of the device even if temp-variable isn't updated. so by looking at this you can determine if communication is ok.
 

So if I consider this data critical, I am going to have to do something like a heartbeat.  Then I need a mechanism to notify if I am loosing data.  Hmmm, something to think about.

-Chris
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on January 13, 2014, 02:09:13 pm
I actually update LAST_UPDATE of the device even if temp-variable isn't updated. so by looking at this you can determine if communication is ok.
 
@Garrett, is this a ok behavior? Or should LAST_UPDATE-variable only update when temp-variable does?

It is usually preferable to only update LastUpdate if something has changed.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: RichardTSchaefer on January 13, 2014, 02:20:50 pm
It's probably ok in a debug mode.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: MDoc on January 13, 2014, 08:28:48 pm

I actually update LAST_UPDATE of the device even if temp-variable isn't updated. so by looking at this you can determine if communication is ok.

I agree ... normally update time should only be changed when data changes.... But in this case if the time is updated and there is no data I'll know the sensor is faulty but the micro and radio are still ok.  If the update time stops.... I know that there's a problem with the micro or radio.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on January 13, 2014, 10:37:29 pm

I actually update LAST_UPDATE of the device even if temp-variable isn't updated. so by looking at this you can determine if communication is ok.

I agree ... normally update time should only be changed when data changes.... But in this case if the time is updated and there is no data I'll know the sensor is faulty but the micro and radio are still ok.  If the update time stops.... I know that there's a problem with the micro or radio.

I say do this only for the parent of the sensor and not for the child devices.

- Garrett

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: MDoc on January 13, 2014, 11:07:32 pm
That makes sense Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: AndersF on January 14, 2014, 01:47:14 pm
Hi

Today i made an order for a kit of arduinos and stuff. Does anyone have any good references to power supply solutions and enclosures?
I guess in many applications it would be most appropriate to put the electronics behind a wall switch and supply power from  battery and in some cases using a power adapter (switches, etc). In some applications the enclosure will likely be attached to the ceiling or a wall.(Door, temperature and motion sensors, etc.)

I have not decided yet whether i will go for Vera. Currently I'm trialing Openhab. Any ideas about how I can interface the software you are discussing in this thread?

Best regards
Anders 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: sener on January 14, 2014, 05:28:58 pm
Hi @Hek, @JesperJ

Thanks for the prompt reactions.

My sensor DH11 is working ok when I put the same hardware setup (5v feeding from Arduino Uno and 10K pull up) under a standalone sample project. So, this is not the case.

Second thing, removing #define DEBUG didn't help either.

FYI: I am running Arduino Gateway and Arduino Sensor node for my test.

I am just thinking loudly and It is maybe about converting float values within the sensor library, I will try to modify the sensor library for debugging purposes if I can catch something.

Regards,
Sener
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 14, 2014, 05:36:36 pm
I did some basic tests after your report (on the float conversion) but I could not reproduce your problems.  Strange.

But I only own a DHT22.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: sener on January 14, 2014, 05:45:21 pm
Hek,

DHT11 and DHT22 are same in terms of usage and output but accuracy.

It is most likely I overlook something then. I will report back if I can make it work.

Thanks anyway.

Regards,
Sener
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on January 16, 2014, 02:51:44 am
I'm presenting as an example my last released project

It is a clock based on a big Red-Green led matrix 32 x 16 http://www.sureelectronics.net/goods.php?id=1122
http://arduino.ru/sites/default/files/u1135/foto_2.jpg

This example is an example from AVR part of the Arduino Plugin project, it is based on a custom build PCB with atmega128a on board.
Also PCB contains temperature/pressure sensor BMP085, light sensor using photo resistor, RTC based on very precise DS3231.
Clock requires zero maintenance - date and time automatically synchronized with vera using Vera library time sync feature.

It is how clock is presented on vera side:
http://arduino.ru/sites/default/files/u1135/2014-01-16_11.11.02_am.png

Clock is accepting VAR_1 and VAR_5 from vera. VAR_1 can be used to send text string to clock and this text will be displayed. VAR_5 is used to update clock on outside temperature. Currently I use scene running each 10 minutes with the following code:
Code: [Select]
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)
61 - is vera id of my weather plugin current temperature device, 372 is my clock node vera id. In the future I will probably replace it by my own outside sensor etc. this clock is transparent from the outside temperature source, vera can change the source easily. Clock will show outside temperature until it expires - if on some reason vera will stop sending updates clock will take care to not show outdated temperature. It is configured to show 60 minutes fresh temperature.

This is how it is looks like http://www.youtube.com/watch?v=AcGpYOEilqo.
Running text is in Russian, but it easy to recognize - Red text is about outside temperature, Orange about room temperature and Green is about atmosphere pressure.

   
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Salmoides on January 16, 2014, 09:15:31 pm
I've put together the BMP085 and have found that I'm deeply depressed all the time. Not good. So I cobbled together an updated version of the Weather plugin (see attached) to provide the barometric pressure from the Weather Underground site nearby to compare the readings (it just happens to be the US Weather Service about 5 miles away.)  It turns out I'm 27 millibars depressed, which explains why I am always in a thunderstorm even when it's sunny outside.

The question I have is where would be best place be to add in a calibration bias to the measurements provided by the sensors? I've modified the sketch to add in 27 millibars which is an easy way to get the measurements reflected properly, but that's hardwired into the processor and sensor combination. If I change the sensor for whatever reason, I have to recalibrate AND reprogram the sketch. Is there a better way to add in the bias without having to modify the sketch itself?

Sal
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on January 16, 2014, 09:55:44 pm
How high above sea level are you? 745 ft / 227m ?  The BMP085 is meant to be accurate to 2.5hPa (2.5 bar). A solution may be to have the Vera child device allow the local altitude to be set - not sure if this is currently possible. Hek would know.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Salmoides on January 16, 2014, 10:46:34 pm
624ft ?

I don't see an easy way to get the variable out of the child device, thus my question, so I, too, will defer to Zen Master Hek.

Sal
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on January 16, 2014, 11:40:47 pm
624 ft would give a 22.65 bar difference from sea level. The gateway and associated nodes could be considered to be at the one height, so the altitude variable could be held by the gateway.

Any child barometer could ask for the altitude value in the same manner as the isMetric() request is used. The barometer could then return raw and corrected values?

Using a BMP180 may also help.

Another edit: looks like library allows for altitude correction?:
http://learn.adafruit.com/bmp085/using-the-bmp085
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 17, 2014, 01:30:08 am
Use the VAR_1 (-5) for custom settings like calibration. Your sensor can fetch this value from vera at startup.

See examples/TimeAndVariableSensor for an example how to set it. Once created (and vera is realoaded) you can update ut under Advanced-tab of the device and request/read it back from the device.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on January 17, 2014, 01:50:13 am
@Salmoides

I read the datasheet for BMP085 and did not found any reason for you to adjust the calculated pressure. Have you found something in the datasheet I missed?

I can proposed you to double check the calculation of the pressure. First of all it should be a good idea to check the calibration data you are reading from the sensor itself.
You also can try to use more precise calculation from the application note I attached.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on January 18, 2014, 09:22:08 am
I get allot of the following in my vera log, anyone know what it means? Node 3 is a DHT22.

01/18/14 16:17:38.555   ctrl_chr[31;1mluup_log:241: Arduino: 3;255;4;13;ctrl_chr[0m <0x30bbb680>
01   01/18/14 16:17:38.556   ctrl_chr[31;1mluup_log:241: Arduino: Sending command: 3;255;4;13;Mctrl_chr[0m <0x30bbb680>
01   01/18/14 16:17:43.575   ctrl_chr[31;1mluup_log:241: Arduino: 3;255;4;13;ctrl_chr[0m <0x30bbb680>
01   01/18/14 16:17:43.576   ctrl_chr[31;1mluup_log:241: Arduino: Sending command: 3;255;4;13;Mctrl_chr[0m <0x30bbb680>
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: veravance on January 18, 2014, 11:56:55 am
hi,
thank you for this great plugin :-)

when i replace batteries of my arduino, they didnt send the data without a reset of the arduino gateway ....
is it normal ?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on January 18, 2014, 05:33:37 pm
Gateway is designed to work 24x7x365 without any interruption or maintenance.
It is abnormal if you have to reset gateway for battery change

I have one device is running in one of my room only while light is on 
Etc it is switching on and off many times a day
My gateway is tolerant to that
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on January 19, 2014, 08:57:36 am
Is there a way to enable and disable "DEBUG" from within each individual Arduino sketch rather than globally from within Sensor.h library file?

When developing and troubleshooting Arduino sketches it would be little easier to control DEBUG from within the sketch.

From Sensor.h file:
Code: [Select]
#define DEBUG // Turn on/off debug mode by having/removing this define
Thanks,
Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on January 19, 2014, 09:14:59 am
joek,
If you comment it Sensor.h you probably can define it in the sketch somewhere before invluding Sensor.h

I did'nt try this but hopefully it will work
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: waynehead99 on January 19, 2014, 11:27:22 am
Hek and team, I gotta give you a big thanks for all of this and everyone that has put in the work to get it to where it is at today. I have been a member on this forum for a couple of years almost now and this is my first post as everyone is usually pretty detailed in the work they have done. Between RTS PLEG and this, I feel I have a complete system finally that I can add to without the expense I was expecting.

I know very little about coding and never heard of arduino until this, I got my shipment this week and started building. I have even been able to start combining sensors (which is easier than I thought).

One question I do have, I see the question asked a lot, but very little answers (outside of the few that have access to 3D printing), how are people mounting and making things look pretty for their home built sensors? My wife is accepting of my hobby, as long as it fits the decor.

Again a big thanks to everyone that has contributed to this project!!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on January 19, 2014, 02:48:26 pm
joek,
If you comment it Sensor.h you probably can define it in the sketch somewhere before invluding Sensor.h

I did'nt try this but hopefully it will work

Thank you axill. Defining DEBUG before including Sensor.h was something I tried, but didn't work.

Joe
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on January 19, 2014, 04:51:04 pm
Not sure if this relevant - I wanted to turn off debugging completely at one stage and found that I had to disable it in Sensor.h and also in Relay.h

Regardless - as per @joek - it would be good to control debugging actually in the sketch, if at all possible.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Peter on January 20, 2014, 01:32:22 pm
Can I use this gateway also to make a connection between de vera and a arduino mega through a ethernet connection?
There is a cool dutch project called nodo http://www.nodo-domotica.nl/nodoinfo.html.
This arduino board can be used for recieving/sending infrared and rf 433mhz devices.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: veravance on January 20, 2014, 03:00:42 pm
I confirm that when i change batteries of one of my arduino the gateway crash .....
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on January 22, 2014, 03:39:41 pm
just published http://code.mios.com/trac/mios_arduino-sensor/wiki/TipsAndTricks
probably can be helpful to someone

fill free to suggest a new cases

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on January 22, 2014, 03:43:12 pm


Thank you axill. Defining DEBUG before including Sensor.h was something I tried, but didn't work.

Joe
Joe, have you commented out #define DEBUG inside Sensor.h before trying this?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: MDoc on January 23, 2014, 07:08:11 pm
@axill, Great idea.  Would it make sense to split this off on its own thread?

Anyway? Here's a case to achieve longest battery life if you'd like to add it.  This info exists elsewhere but is consolidated in 1 place.
 
Case #3

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 (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 (https://www.sparkfun.com/products/10967)
              http://www.pololu.com/product/798 (http://www.pololu.com/product/798)

4.   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 Hek?s RelayWithButtonActuator.ino)

5.   Disable the BOD (Brow out detection).  Hek does this  in the Sleep Library 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>

6.   Turn of A/D Convertors :  (Again Hek already does this in Sleep Library)
      // disable ADC
      ADCSRA = 0;

7.   Set unused input or output pins to LOW.

8.   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.
        (I've not tried this)

9.   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 (http://forum.micasaverde.com/index.php/topic,20078.0.html)

Comments:

For reference here are some good sights referred to by Hek, axill and myself:
   http://maniacbug.wordpress.com/2011/10/19/sensor-node/ (http://maniacbug.wordpress.com/2011/10/19/sensor-node/)
   http://www.gammon.com.au/forum/?id=11497 (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/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://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.thalin.se/2013/04/arduino-pro-mini-low-power-modification.html)
   http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/ (http://www.rocketscream.com/blog/2011/07/04/lightweight-low-power-arduino-library/)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on January 23, 2014, 11:52:29 pm
@MDoc, thanks!

Case #3 was published
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on January 24, 2014, 07:20:52 am


Thank you axill. Defining DEBUG before including Sensor.h was something I tried, but didn't work.

Joe
Joe, have you commented out #define DEBUG inside Sensor.h before trying this?

@axill - Yes
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: axill on January 25, 2014, 03:20:20 am
@Joek ups..
I mostly use Atmel studio and "Rebuild" works for this.
I'm not sure similar thing exists with arduino giu.
Software switch will definitely work, but it is a bad idea to change pre compilation switch as it is now to a run time switch
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mitekdg on January 26, 2014, 10:04:33 am
@axill
add plz this pic http://forum.micasaverde.com/index.php?action=dlattach;topic=20078.0;attach=13708
to Case#3 in wiki
thx
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: blacey on January 26, 2014, 10:19:11 pm
I finally got around to building a proper gateway this weekend...  Works great...

Thanks to Hek and everyone else who has contributed to making the Arduino plug-in a success.

**UPDATE**

Per request - I have included the BOM that includes the specific parts of interest...
1 Adruino Nano - http://www.ebay.com/itm/130977189883?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649
1 nRF24L01+PA+LNA wireless communication module - http://www.ebay.com/itm/nRF24L01-PA-LNA-wireless-communication-modules-w-antenna-2-4GHz-2Mbps-/191015401054?pt=LH_DefaultDomain_0&hash=item2c7967b65e
1 4cm x 6cm prototype board
1 4.7uf 50v Capacitor - http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItemVersion&item=220961387730&view=all&tid=1302877760012
3 1K resistors
1 10K resistor
1 Push Button Switch - http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=231147569538
1 3mm Red LED
1 3mm Yellow LED
1 3mm Green LED
30 AWG Kylar Wire
4 M2-0.4x5mm brass stand offs
4 M2-0.4x4mm flat head screws
4 M2-0.4x4mm pan head screws
1 Project Box (2.9 x 1.9 x 1.1 inches)  - http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=111263231186
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: C4Vette on January 27, 2014, 02:14:43 am
Looking good! A nice example of how I would like it myself.
What transceiver is that you are using?
And now the 'slaves'! What are you going to connect?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: konradwalsh on January 27, 2014, 03:24:43 am
I finally got around to building a proper gateway this weekend...  Works great...

Thanks to Hek and everyone else who has contributed to making the Arduino plug-in a success.
Would you care to do up a separate thread on this one.. and give BOM list with it.. Would love to copy it just for learning
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: konradwalsh on January 29, 2014, 04:41:10 pm
Sorry but I searched..
How do you set the child device to include mode?
So when I press the start button in Vera it picks it up?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on January 29, 2014, 05:36:04 pm
Sorry but I searched..
How do you set the child device to include mode?
So when I press the start button in Vera it picks it up?

I just pressed start in Vera and it picked up the child devices. I had to have them properly powered with an old cell phone charger, USB on the computer didn't work.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: konradwalsh on January 29, 2014, 05:37:48 pm
Sorry but I searched..
How do you set the child device to include mode?
So when I press the start button in Vera it picks it up?

I just pressed start in Vera and it picked up the child devices. I had to have them properly powered with an old cell phone charger, USB on the computer didn't work.

Ah.. didn't think of that..
thanks!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mrcobra on January 30, 2014, 03:18:48 pm
Hi,

Did anyone have problems with the relay actuator and managed to resolve them? Mine stops responding after 2 hours. Tried to change it from relay to sensor but still problems. I also built another yesterday to rule out any hardware problems, bjt still the same...Powering with a 5v ac adapter.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: imike on January 30, 2014, 03:26:34 pm
Is it possible to use arduino (i.e. nano) as a remote hub?

I am thinking of putting arduino (or raspberry) in the basement and run wires from all sensors to it.
It seems sensor-related code assume that you only have a single sensor connect.

Do you think this is (wired hub) a possible scenario?
Will different sensors work with a single hub (assuming i will modify code)?


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 30, 2014, 06:31:14 pm
I might have tracked down (part?) of the problem. It was related to routing tables. Just need to do some long time testing (over night) before releasing anything.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on January 31, 2014, 01:35:05 pm
I am thinking of putting arduino (or raspberry) in the basement and run wires from all sensors to it.
It seems sensor-related code assume that you only have a single sensor connect.
You can have multiple sensors attached to one Arduino.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dtripple on February 01, 2014, 05:30:18 pm
I have been through most of this thread, and have not see anywhere that I can configure the device to show the last time it was updated.  If I missed it can someone quote it for me.  Thank you in advance.  Again thank you for all your hard work in this project. It works great
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: p3tter on February 02, 2014, 09:10:34 am
has anyone tried to use the luup variable get for the distance sensor?
luup.variable_get("urn:upnp-org:serviceId:DistanceSensor1", "CurrentDistance", device)
im trying to dim my lights using the CurrentDistance variable from the distance sensor, but its not working.
The luup.variable.get dosent get any value from the distance sensor.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 03, 2014, 08:40:13 am
I have been through most of this thread, and have not see anywhere that I can configure the device to show the last time it was updated.  If I missed it can someone quote it for me.  Thank you in advance.  Again thank you for all your hard work in this project. It works great

You'll find the LastUpdate variable under Advanced (number of seconds since Jan 1970).
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 03, 2014, 08:44:49 am
has anyone tried to use the luup variable get for the distance sensor?
luup.variable_get("urn:upnp-org:serviceId:DistanceSensor1", "CurrentDistance", device)
im trying to dim my lights using the CurrentDistance variable from the distance sensor, but its not working.
The luup.variable.get dosent get any value from the distance sensor.


Try with:

"urn:micasaverde-com:serviceId:DistanceSensor1"

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dtripple on February 03, 2014, 11:18:04 am
I have been through most of this thread, and have not see anywhere that I can configure the device to show the last time it was updated.  If I missed it can someone quote it for me.  Thank you in advance.  Again thank you for all your hard work in this project. It works great

You'll find the LastUpdate variable under Advanced (number of seconds since Jan 1970).

Which file should I look at to modify if I want to show this variable on the widget of the device, say just under the tempature? The D_tempature1.xml or the json file, or both?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on February 03, 2014, 12:50:00 pm
It will be D_TemperatureSensor1.json. But to warn you this will affect all of your temperature devices. If you want to modify it, I suggest you make a backup just in case.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: p3tter on February 03, 2014, 03:08:24 pm
has anyone tried to use the luup variable get for the distance sensor?
luup.variable_get("urn:upnp-org:serviceId:DistanceSensor1", "CurrentDistance", device)
im trying to dim my lights using the CurrentDistance variable from the distance sensor, but its not working.
The luup.variable.get dosent get any value from the distance sensor.


Try with:

"urn:micasaverde-com:serviceId:DistanceSensor1"

i have already tried it with no luck. is it something with the arduino code? or the vera?
it cant just get any value from the variable


--EDIT---
got it working now after i reinstalled the plugin and deleted and added the z-wave dimmer again.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dtripple on February 03, 2014, 06:34:23 pm
It will be D_TemperatureSensor1.json. But to warn you this will affect all of your temperature devices. If you want to modify it, I suggest you make a backup just in case.

- Garrett

I figured it would. I have temp sensors in the kids rooms and just need to know that they are up to date.  I will give it a shot, but the conversion from epoch time to human time. May be problematic.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dtripple on February 03, 2014, 08:20:22 pm
It will be D_TemperatureSensor1.json. But to warn you this will affect all of your temperature devices. If you want to modify it, I suggest you make a backup just in case.

- Garrett

I figured it would. I have temp sensors in the kids rooms and just need to know that they are up to date.  I will give it a shot, but the conversion from epoch time to human time. May be problematic.

Also, will the widget automatically update, or will I have to remove it and redetect it?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dagwood08 on February 03, 2014, 08:35:01 pm
I'm trying to install my Arduino nano gateway software.  First I imported all of the libraries into the Arduino IDE location.  I then connected the nano to my computer and tried to upload the Arduino Gateway sketch.  I don't get too far and get the error ""Gateway" does not name a type".  The following line (after the comment line) is indicated as an error:

// Start gateway with include button and led blinking functionality enabled (see documetation)
  Gateway gw(9, 10, INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, 6, 5, 4);

This is all new to me and have no clue what the error is.  Any help would be much appreciated.

Thanks.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on February 03, 2014, 08:48:47 pm
Did you restart the IDE after copying over the libraries?

How did you load the sketch? If you do this via the File/examples/vera ?

Sent from my Nexus 5 using Tapatalk

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dagwood08 on February 03, 2014, 09:56:41 pm
I did restart the IDE after importing the libraries.  I then opened the file ArduinoGateway.ino and tried uploading that to the nano.  That's when I get the error.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on February 04, 2014, 01:33:31 am
It will be D_TemperatureSensor1.json. But to warn you this will affect all of your temperature devices. If you want to modify it, I suggest you make a backup just in case.

- Garrett

I figured it would. I have temp sensors in the kids rooms and just need to know that they are up to date.  I will give it a shot, but the conversion from epoch time to human time. May be problematic.

Also, will the widget automatically update, or will I have to remove it and redetect it?

Upload the modified file and check the restart luup engine after upload checkbox. You may have to clear your browser cache.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on February 04, 2014, 08:20:28 am
Dtripple,

I was thinking about doing something similar to this.  I'd be interested to hear how it works out for you. 

The method I was thinking about doing before I read your post was to see if I could monitor the last update time in PLEG (haven't had time to test/implement yet) and then send an alert if it's outside of a time range.  I was thinking that would be good so then I don't have to worry about modifying json files.  Just thought I'd throw that out there in case it helps.

Pete
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Derek Macias on February 04, 2014, 10:31:01 am
Hi,

Did anyone have problems with the relay actuator and managed to resolve them? Mine stops responding after 2 hours. Tried to change it from relay to sensor but still problems. I also built another yesterday to rule out any hardware problems, bjt still the same...Powering with a 5v ac adapter.
Which arduino are you using and how many amps on the 5v power supply? I would guess it's the power supply. I was playing with the servo and a mini pro and had to used a 5v 4A brick to keep the arduino from resetting or locking up. I have a four relay, temp and LCD screen on a nano powered by a 5v 2A supply that has been up for weeks. I have a 3.3v mini pro with one relay powered by a 5.1v 1A power supply.  The serial monitor showed corrupted data. I think I selected the 5v cpu. A reflash fixed it.  I also had an instance where it would not respond until I pressed the push button I added to active the relay. It would stop working after a while then I had to push the button again to get it to respond from Vera gui. I unplugged the power and it had been fine for a couple weeks now.

Also the 3.3 with relay will only work with the 5.1v 1A and not from 5v usb power. It works as is so I haven't looked into it. But I would guess it has something to due with powering the 3.3v mini and 5v relay and amps.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dtripple on February 04, 2014, 10:50:40 am
Hi,

Did anyone have problems with the relay actuator and managed to resolve them? Mine stops responding after 2 hours. Tried to change it from relay to sensor but still problems. I also built another yesterday to rule out any hardware problems, bjt still the same...Powering with a 5v ac adapter.
Which arduino are you using and how many amps on the 5v power supply? I would guess it's the power supply. I was playing with the servo and a mini pro and had to used a 5v 4A brick to keep the arduino from resetting or locking up. I have a four relay, temp and LCD screen on a nano powered by a 5v 2A supply that has been up for weeks. I have a 3.3v mini pro with one relay powered by a 5.1v 1A power supply.  The serial monitor showed corrupted data. I think I selected the 5v cpu. A reflash fixed it.  I also had an instance where it would not respond until I pressed the push button I added to active the relay. It would stop working after a while then I had to push the button again to get it to respond from Vera gui. I unplugged the power and it had been fine for a couple weeks now.

Also the 3.3 with relay will only work with the 5.1v 1A and not from 5v usb power. It works as is so I haven't looked into it. But I would guess it has something to due with powering the 3.3v mini and 5v relay and amps.


You might want to try putting a 1000uf cap across your incoming power wires to help with drops in incoming voltage.  This has helped mine tremendously.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Derek Macias on February 04, 2014, 03:26:26 pm
Thanks that's a good idea. 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 04, 2014, 06:50:13 pm
Beta 2

http://forum.micasaverde.com/index.php/topic,23012.0.html
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: mrcobra on February 05, 2014, 02:54:55 am
Hi,

Did anyone have problems with the relay actuator and managed to resolve them? Mine stops responding after 2 hours. Tried to change it from relay to sensor but still problems. I also built another yesterday to rule out any hardware problems, bjt still the same...Powering with a 5v ac adapter.
Which arduino are you using and how many amps on the 5v power supply? I would guess it's the power supply. I was playing with the servo and a mini pro and had to used a 5v 4A brick to keep the arduino from resetting or locking up. I have a four relay, temp and LCD screen on a nano powered by a 5v 2A supply that has been up for weeks. I have a 3.3v mini pro with one relay powered by a 5.1v 1A power supply.  The serial monitor showed corrupted data. I think I selected the 5v cpu. A reflash fixed it.  I also had an instance where it would not respond until I pressed the push button I added to active the relay. It would stop working after a while then I had to push the button again to get it to respond from Vera gui. I unplugged the power and it had been fine for a couple weeks now.

Also the 3.3 with relay will only work with the 5.1v 1A and not from 5v usb power. It works as is so I haven't looked into it. But I would guess it has something to due with powering the 3.3v mini and 5v relay and amps.

Thanks for your input.
I am using the pro mini 5v. The power supply is rated 5v, 1A. Unfortunatley I dont have a more powerful supply availible but I ordered some today to test. I vill also test to put a 1000uf cap on my current supply.

I think it can be a combination of the Power issue and the radio issue that HEK has fixed in his new release.   
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 07, 2014, 05:05:07 pm
Ethernet option added:

http://forum.micasaverde.com/index.php/topic,23093.0.html
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clandmeter on February 08, 2014, 08:56:30 am
I'm trying to upload my first Arduino sketch, but im getting the following error:

Code: [Select]
In file included from /home/clandmeter/sketchbook/libraries/MySensors/Relay.h:15:0,
                 from /home/clandmeter/sketchbook/libraries/MySensors/Gateway.h:15,
                 from SerialGateway.ino:29:
/home/clandmeter/sketchbook/libraries/MySensors/Sensor.h:22:25: fatal error: avr/progmem.h: No such file or directory
compilation terminated.

I tried to follow the instructions from wiki and im using Linux with Arduino IDE from mint repo.

Im probably doing something horribly wrong...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: waynehead99 on February 08, 2014, 09:22:24 am
I'm trying to upload my first Arduino sketch, but im getting the following error:

Code: [Select]
In file included from /home/clandmeter/sketchbook/libraries/MySensors/Relay.h:15:0,
                 from /home/clandmeter/sketchbook/libraries/MySensors/Gateway.h:15,
                 from SerialGateway.ino:29:
/home/clandmeter/sketchbook/libraries/MySensors/Sensor.h:22:25: fatal error: avr/progmem.h: No such file or directory
compilation terminated.

I tried to follow the instructions from wiki and im using Linux with Arduino IDE from mint repo.

Im probably doing something horribly wrong...

Did you download the libraries and update IDE with them?


Sent from my iPad using Tapatalk HD
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clandmeter on February 08, 2014, 03:22:37 pm
Yes i copied the libs to the IDE. They are also listed inside the IDE.

Inside the sketch i also see progmem.h included, but when i search my system i cannot find it.
What should provide progmem.h?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clandmeter on February 10, 2014, 06:15:46 pm
I downloaded the latest nightly arduino IDE, and it works as expected.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clandmeter on February 11, 2014, 02:01:10 pm
According to the hardware buying guide (http://code.mios.com/trac/mios_arduino-sensor/#Cablesandothergoodtohavestuff), we should purchase: 3P 20cm Dupont Wire Color Jumper Cable
Buf after trying my first Arduino hacking, i find out its almost impossible to connect the radio module to my arduino board.
It could be im doing something wrong, but to me it looks like its better to add also 1pin dupont wires to the buying guide because these are more flexible to use.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 11, 2014, 02:48:14 pm
According to the hardware buying guide (http://code.mios.com/trac/mios_arduino-sensor/#Cablesandothergoodtohavestuff), we should purchase: 3P 20cm Dupont Wire Color Jumper Cable
Buf after trying my first Arduino hacking, i find out its almost impossible to connect the radio module to my arduino board.
It could be im doing something wrong, but to me it looks like its better to add also 1pin dupont wires to the buying guide because these are more flexible to use.

I don not quite understand the problem. Can you post a picture of what you are trying to connect together and with what?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clandmeter on February 11, 2014, 03:13:39 pm
I don not quite understand the problem. Can you post a picture of what you are trying to connect together and with what?

If you check this picture http://code.mios.com/trac/mios_arduino-sensor/attachment/wiki/ConnectingRadioModule/gw.jpg

You can see multiple 1Pin Dupont cables in this picture.
When you use the 3Pin wires to the wireless module, how can you split the wires at the arduino side?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 11, 2014, 03:26:18 pm
If you check this picture http://code.mios.com/trac/mios_arduino-sensor/attachment/wiki/ConnectingRadioModule/gw.jpg

You can see multiple 1Pin Dupont cables in this picture.
When you use the 3Pin wires to the wireless module, how can you split the wires at the arduino side?

Damn.. I have linked the wrong type on the wiki.. I didn't even know there was a 3p-variant.. Sorry.
I have updated the wiki.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Derek Macias on February 11, 2014, 03:48:35 pm
You can pull  the terminal out of the black casing by lifting the little black tab with something sharp.  Then apply a small piece of heat shrink to the exposed terminal.  I do this with most of the dupont type wires anyway because they fit tighter.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on February 11, 2014, 06:18:43 pm
Anyone found a 10 cm version of these cables. The 20cm ones are a bit on the long side.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Derek Macias on February 12, 2014, 03:21:01 am
I found these in a local store but they are expensive. I used them for connecting all the radios. They are 3" (7.6 cm)  They had some yellow ones that are closer to 10.
 http://www.schmartboard.com/index.asp?page=products_jumpers&id=41  (http://www.schmartboard.com/index.asp?page=products_jumpers&id=41)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 12, 2014, 04:16:11 am
http://www.ebay.com/itm/200pcs-2-54mm-1pin-Female-to-Female-jumper-wire-Dupont-cable-10cm-for-Arduino-/230974563572?pt=LH_DefaultDomain_0&hash=item35c72824f4
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Derek Macias on February 12, 2014, 05:26:18 am
Nice! 200 pieces
Title: Re: [CODE] Arduino Sensor Plugin - Build your own wireless sensors!
Post by: emooney on February 13, 2014, 02:55:06 am
hi, is it possible to send data to sensor from vera OR to request data from vera to sensor?
Cool project )

Check out https://github.com/madsci1016/Arduino-EasyTransfer (https://github.com/madsci1016/Arduino-EasyTransfer). It's a library that allows 2-way communication using I2C. I tested with the nRF24L01 radio module and it works well. The nRF24L01's are very finicky with their power source. Just a heads up.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: emooney on February 15, 2014, 12:46:50 pm
Hello,

Thank you Hek for such great work. I was able to get the distance sensor running, however I'm seeing another device that was created when my distance sensor device was created (see attached image). It's the one called "Arduino Node 8". Should I be seeing this? Just wanted to make sure that I don't have anything mis-configured.

Also, should the Gateway Plugin be in the 'start' position all the time ? (see attached image) Or just when I'm discovering devices? I'm afraid to hit stop. =) It took me a couple days to get the distance sensor up and I don't want it to disappear if I hit 'stop'. I've been trying so many different combinations, I'm not exactly sure what I did to finally get it.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 15, 2014, 01:56:48 pm
Hello,

Thank you Hek for such great work. I was able to get the distance sensor running, however I'm seeing another device that was created when my distance sensor device was created (see attached image). It's the one called "Arduino Node 8". Should I be seeing this? Just wanted to make sure that I don't have anything mis-configured.
The -node (or -relay) device is automatically created for every Arduino in your sensor network.

Also, should the Gateway Plugin be in the 'start' position all the time ? (see attached image) Or just when I'm discovering devices? I'm afraid to hit stop. =) It took me a couple days to get the distance sensor up and I don't want it to disappear if I hit 'stop'. I've been trying so many different combinations, I'm not exactly sure what I did to finally get it.

It is a bit weird that inclusion mode is activated all the time.. By default it's only activated for one minute.
Are you using include button on the arduino-gateway? Which constructor did you choose in the gateway sketch before uploading it to the arduino board? 
Try pressing stop and see hat happens...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: derrij on February 20, 2014, 02:07:17 am
Trying to make gateway from arduino uno on vera lite.
ttyACM0 appears in dev, but can't choose it as serial port in vera lite app settings.
There is nothing it Serial Port configuration in Develop Apps.

Possible to use Arduino UNO as gateway?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on February 20, 2014, 02:49:40 am
Not with out making some manual changes to the arduino plugin and running the ser2porxy command manually. In other words, it requires some additional work to get going.

- Garrett
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Soozook on February 20, 2014, 03:57:40 am
Hi Just starting out on the arduino roller coaster and was wondering if its possible to use a single Arduino to run multiple reed switches similar to how multiple  temperature sensors can be used with a single Arduino or would I need a separate Arduino for each switch?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 20, 2014, 06:04:28 am
Hi Just starting out on the arduino roller coaster and was wondering if its possible to use a single Arduino to run multiple reed switches similar to how multiple  temperature sensors can be used with a single Arduino or would I need a separate Arduino for each switch?

You can have (at least) 16 temperature sensors if you use my Dallas-temperature example (occupies one digital input).
And connect one reed switch per digital/analog input of the Arduino (after radio has been connected there should be 13 inputs left).
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: datammwv on February 23, 2014, 07:30:59 am
Help getting plug working.  I have uploaded the files and they show under Apps - Developed apps - Luup files.  I then choose create device - I enter D_Arduino1.xml in device file name (see pic)  It says created but as the pictures shows I never get the device showing up.  Just a generic device.

running firmware version 1.5.622

I have loaded all Libraries in Arduino and loaded the sketch into my Nano 3.0.   That part worked flawlessly.  I do have it plugged into my Vera Lite. 

But from my understanding the Arduino plugin Device should show up clearly without the Nano 3.0 plugged in. 

Suggestions or ideas ?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on February 23, 2014, 03:02:33 pm
Generally this happens when you have not restarted the Luup engine (and refreshed your browser to match a few times) - a few restarts are generally required for new devices.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: datammwv on February 23, 2014, 08:39:14 pm
I ssh into my Vera lite removed all files and just copied back in without GUI.  Rebooted Vera and works. Just have to connect radio module with Nano 3.0.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: manfaiho on February 26, 2014, 09:13:33 am
Hello everyone,

I've just download the latest version of 1.3 Beta 2 all vera and arduino library for test. I can successfully uploaded all xml then created the device and configuration setting for the port. The plug can normally created and showed me its version 1.2+. I import all Arduino libraries and copy Motion Sensor and Relay sketch into another devices. All have been done normally. When I click "Start" inclusion on the plug-in, it always shows 0 device is found. I didn't use inclusion button and LED and ensure uncomment gwstartup for button inclusion. I don't know why 0 device is found always. Anyone can point me the way to shoot on this problem? Appreciate in advance. Thanks.

Best regards,
Fai
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 26, 2014, 01:51:07 pm
Hello everyone,

I've just download the latest version of 1.3 Beta 2 all vera and arduino library for test. I can successfully uploaded all xml then created the device and configuration setting for the port. The plug can normally created and showed me its version 1.2+. I import all Arduino libraries and copy Motion Sensor and Relay sketch into another devices. All have been done normally. When I click "Start" inclusion on the plug-in, it always shows 0 device is found. I didn't use inclusion button and LED and ensure uncomment gwstartup for button inclusion. I don't know why 0 device is found always. Anyone can point me the way to shoot on this problem? Appreciate in advance. Thanks.

Best regards,
Fai

Have you tried restarting your sensor right after inclusion mode has been initiated? The sensors only send their presentation during startup.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: manfaiho on February 26, 2014, 04:45:20 pm
I thin when I click start the inclusion, I should have around 1 min for this process. At that time, I restart the sensor several times to check but no luck :-( any clue? Thanks.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on February 26, 2014, 06:22:39 pm
Try leaving the sensor powered up for the full minute. Mine can take 30 seconds or so to add. The first couple of times I tried I gave up too early. You may be unplugging it too early too. So it would look like this:
1. Press start inclusion from vera webpage
2. Power up sensor
3. Wait 1 minute
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 27, 2014, 01:19:17 am
Also check serial output for both sensor and gateway to determine if they actually can speak to each other.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: manfaiho on February 27, 2014, 02:58:41 am
Thanks your advice. I did the steps for inclusion process as your advised (wait 1 mins but nothing). Yes, I want to check if any communication between gateway and sensor via NRF24L01 (because no any LED on NRF24L01 for check) but I don't know how to trace it. I open the serial monitor under Arduino IDE from sensor side but no data there. I also don't know how to trace it on gateway side with Vera. Should I enable some kind DEBUG mode for these tracing? Can you help me? Thanks.

Best regards,
Fai
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on February 27, 2014, 03:29:01 pm
@Fai

I am by no means an expert but this sounds similar to a problem I had when I was first starting.  It ended up being that I didn't have enough power on the sensor side pro mini.  I was trying to power it from the usb to serial adapter.  When I powered it from a 5v 1A usb phone charger it worked.  How are you powering your pro mini?

I would be interested to hear how other people are monitoring things.  The way I have done it so far is to unplug the gateway from the vera then plug it into my computer and use the serial monitor.  I haven't been able to figure out how to use the serial monitor on the pro mini.

Pete
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on February 27, 2014, 03:34:59 pm
Hi Fai, try adding a decoupling capacitor across the 3.3v supply to the radio. Its mentioned in the wiki and earlier in this thread.
I use nano's and so far all but one have require it.
Failing that, try another radio. I had a faulty one which frustrated me for a while!


Sent from my Nexus 5 using Tapatalk

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: RichardTSchaefer on February 27, 2014, 04:03:54 pm
I was thinking of doing multiple Current Transformer inputs to monitor Load currents.
So I could have a multi-sensor power monitor.
Anyone start something like this yet ?
 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on February 27, 2014, 04:15:28 pm
Great Idea Richard!
I have some AC712 sensors awaiting a use, although as I'm sure you are thinking about installation into a fuse box you would probably be better off (safer) with CT sensors as you suggested.
Off to eBay I go!

Edit: some work on this already here:
http://openenergymonitor.org/emon/buildingblocks/ct-sensors-introduction

Sent from my Nexus 5 using Tapatalk
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: datammwv on February 28, 2014, 01:19:48 pm
Can someone answer Manfaiho question?  I believe a lot of us could use this knowledge as of how to trouble shoot The Vera Gateway communicating with a Sensor.
I too have a Vera Gateway seen by my Veralite perfectly fine. But when try to add a motion sensor plugged into a Arduino Nano 3.0, powered by USB power outlet I can never get it to include the sensor.   Letting us know where to look to trouble shoot more is greatly needed.
 

Quote
Thanks your advice. I did the steps for inclusion process as your advised (wait 1 mins but nothing). Yes, I want to check if any communication between gateway and sensor via NRF24L01 (because no any LED on NRF24L01 for check) but I don't know how to trace it. I open the serial monitor under Arduino IDE from sensor side but no data there. I also don't know how to trace it on gateway side with Vera. Should I enable some kind DEBUG mode for these tracing? Can you help me? Thanks.

Best regards,
Fai

Thanks to all.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 28, 2014, 01:31:16 pm
For debug prints you have a few options:

For gateway debug prints you you can either keep it plugged in to the vera and with ssh access do a:

Quote
>grep Arduino /var/log/cmh/LuaUPnP.log

Or unplug the gateway from vera and watch the serial log in the Arduino IDE.

When a new sensor starts it should send presentation data which should show up in the log on the gateway side.

You can also watch the serial log on the sensor itself. There is a ack status (which says if the message arrived to destination) of all messages transmitted. 


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on February 28, 2014, 01:37:49 pm
I have a spare gateway nano hocked up to the computer serial monitor to check if it can receive anything. And I  give all sensors an ID instead of using the AUTO.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: datammwv on February 28, 2014, 01:50:38 pm
This is what I am seeing  is the following.... Anyone have and idea?
Code: [Select]
6 02/28/14 13:43:36.054 Device_Variable::m_szValue_set device: 62 service: urn:micasaverde-com:serviceId:SecuritySensor1 variable: LastTrip was: 1393613009 now: 1393613016 #hooks: 0 upnp: 0 v:0xffbc58/NONE duplicate:0 <0x2b78d680>
08 02/28/14 13:43:37.232 JobHandler_LuaUPnP::HandleActionRequest device: 94 service: urn:upnp-arduino-cc:serviceId:arduino1 action: StartInclusion <0x2fdce680>
08 02/28/14 13:43:37.233 JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=94 <0x2fdce680>
08 02/28/14 13:43:37.233 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:upnp-arduino-cc:serviceId:arduino1 <0x2fdce680>
08 02/28/14 13:43:37.233 JobHandler_LuaUPnP::HandleActionRequest argument action=StartInclusion <0x2fdce680>
08 02/28/14 13:43:37.233 JobHandler_LuaUPnP::HandleActionRequest argument rand=0.22225338876312506 <0x2fdce680>
50 02/28/14 13:43:37.234 luup_log:94: Arduino: Sending: 0;0;4;6;1 <0x2fdce680>
50 02/28/14 13:43:37.242 luup_log:94: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,InclusionMode, 1, 94 <0x2f9ce680>
06 02/28/14 13:43:37.243 Device_Variable::m_szValue_set device: 94 service: urn:upnp-arduino-cc:serviceId:arduino1 variable: InclusionMode was: 0 now: 1 #hooks: 0 upnp: 0 v:0x1143e08/NONE duplicate:0 <0x2f9ce680>
50 02/28/14 13:43:37.243 luup_log:94: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,InclusionFoundCountHR, 0 devices found, 94 <0x2f9ce680>
06 02/28/14 13:43:37.244 Device_Variable::m_szValue_set device: 94 service: urn:upnp-arduino-cc:serviceId:arduino1 variable: InclusionFoundCountHR was:  now: 0 devices found #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2f9ce680>
08 02/28/14 13:43:42.108 JobHandler_LuaUPnP::HandleActionRequest device: 94 service: urn:upnp-arduino-cc:serviceId:arduino1 action: StartInclusion <0x2edce680>
08 02/28/14 13:43:42.109 JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=94 <0x2edce680>
08 02/28/14 13:43:42.109 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:upnp-arduino-cc:serviceId:arduino1 <0x2edce680>
08 02/28/14 13:43:42.109 JobHandler_LuaUPnP::HandleActionRequest argument action=StartInclusion <0x2edce680>
08 02/28/14 13:43:42.109 JobHandler_LuaUPnP::HandleActionRequest argument rand=0.35347422808008044 <0x2edce680>
50 02/28/14 13:43:42.110 luup_log:94: Arduino: Sending: 0;0;4;6;1 <0x2edce680>
50 02/28/14 13:43:42.123 luup_log:94: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,InclusionMode, 1, 94 <0x2f9ce680>
50 02/28/14 13:43:42.123 luup_log:94: Arduino: urn:upnp-arduino-cc:serviceId:arduino1,InclusionFoundCountHR, 0 devices found, 94 <0x2f9ce680>
06 02/28/14 13:43:44.512 Device_Variable::m_szValue_set device: 23 service: urn:micasaverde-com:serviceId:ZWaveDevice1 variable: LastWakeup was: 1393611115 now: 1393613024 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2b78d680>
02 02/28/14 13:43:44.513 ZWaveNode::Wakeup did a poll for 15 7626 seconds interval 10800 existing (nil) heal (nil) <0x2b78d680>

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: datammwv on February 28, 2014, 01:59:07 pm
I believe there is a mistake back on this URL
http://code.mios.com/trac/mios_arduino-sensor/wiki/ConnectingRadioModule (http://code.mios.com/trac/mios_arduino-sensor/wiki/ConnectingRadioModule)
In your table you state Arduino is

You list CE = 9
You list CSN = 10

They should be CE  10
and CSN = 9

With those corrected on my Arduino Nano 3.0.  It includes fine!



Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on February 28, 2014, 02:08:53 pm
I believe there is a mistake back on this URL
http://code.mios.com/trac/mios_arduino-sensor/wiki/ConnectingRadioModule (http://code.mios.com/trac/mios_arduino-sensor/wiki/ConnectingRadioModule)
In your table you state Arduino is

You list CE = 9
You list CSN = 10

They should be CE  10
and CSN = 9

With those corrected on my Arduino Nano 3.0.  It includes fine!

Strange. Quite a few people have followed the wiki connection guide successfully (including me). Are you really sure you look at the picture the right way (bottom view).
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: datammwv on February 28, 2014, 02:31:32 pm
my bad.  Yellow is my 10 now. Wasn't prior 9 is orange now...

Now the question lies When you add another Sensor on an existing Arduino Nano 3.0 how does it pull a new id and re-register.  Do you have any example code that is like on one Arduino Nano 3.0 running a stepper & motion.  or motion(hc-sc501)  & Presure/temp/forcast (BMP085)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jny on February 28, 2014, 03:24:38 pm
Richard and gregl:

I'm also planning to do this and so far I have ordered six 30A transformers from eBay and two arduino shields from openenergymonitor.com. Got the shields already but still awaiting the transformers. Would be good to share experiences on this once I get started.

Sent from my GT-I9300 using Tapatalk

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on February 28, 2014, 04:53:50 pm
You can also watch the serial log on the sensor itself. There is a ack status (which says if the message arrived to destination) of all messages transmitted.

@HEK
How would I do this for this project with a pro mini?  I have tried plugging it into the usb to serial adapter but I never see anything in the serial monitor when I'm using the NRF24L01+ and the additional sensors.  It works fine with the pro mini if I just have some simple code and something like a push button.  I have searched google but haven't been able to figure it out...

Thanks,

Pete
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on March 01, 2014, 03:00:35 am
Now the question lies When you add another Sensor on an existing Arduino Nano 3.0 how does it pull a new id and re-register.  Do you have any example code that is like on one Arduino Nano 3.0 running a stepper & motion.  or motion(hc-sc501)  & Presure/temp/forcast (BMP085)

Sorry, I don't understand  :)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on March 01, 2014, 03:03:06 am
@HEK
How would I do this for this project with a pro mini?  I have tried plugging it into the usb to serial adapter but I never see anything in the serial monitor when I'm using the NRF24L01+ and the additional sensors.  It works fine with the pro mini if I just have some simple code and something like a push button.  I have searched google but haven't been able to figure it out...

So your not getting any serial output from any of the provided examples on a pro mini using serial adapter?

I see output... Anyone else having this problem?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: datammwv on March 01, 2014, 07:00:39 am
Quote
Sorry, I don't understand  :)

You have the sketch for the motion sensor HC-SR501

Code: [Select]
#include <Sleep_n0m1.h>
#include <SPI.h>
#include <EEPROM.h>
#include <RF24.h>
#include <Sensor.h>

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

#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
#define CHILD_ID 0 // Id of the sensor child

Sensor gw(9,10);

Sleep sleep;


void setup()
{
  Serial.begin(BAUD_RATE); // Used to type in characters
  gw.begin(RADIO_ID);
  pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input
  // Register all sensors to gw (they will be created as child devices)
  gw.sendSensorPresentation(CHILD_ID, S_MOTION);
}

void loop()
{
  gw.powerUp(); // Power up radio
  // Read digital motion value
  boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
       
  Serial.println(tripped);
  gw.sendVariable(CHILD_ID, V_TRIPPED, tripped?"1":"0"); // Send tripped value to gw
 
  // Power down the radio. Note that the radio will get powered back up
  // on the next write() call.
  delay(200); //delay to allow serial to fully print before sleep
  gw.powerDown();
  sleep.pwrDownMode(); //set sleep mode
  sleep.sleepInterrupt(INTERRUPT,CHANGE);
}

You have the sketch for the Presure Temperature weather BMP085

Code: [Select]
#include <Sleep_n0m1.h>
#include <SPI.h>
#include <EEPROM.h>
#include <RF24.h>
#include <Sensor.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>

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

#define LIGHT_SENSOR_ANALOG_PIN 0

unsigned long SLEEP_TIME = 60; // Sleep time between reads (in seconds)

Adafruit_BMP085 bmp = Adafruit_BMP085(); // Digital Pressure Sensor
Sensor gw(9, 10);

float lastPressure = -1;
float lastTemp = -1;
int lastForecast = -1;
Sleep sleep;
char *weather[] = {"stable","sunny","cloudy","unstable","thunderstorm","unknown"};
int minutes;
float pressureSamples[180];
int minuteCount = 0;
bool firstRound = true;
float pressureAvg[7];
float dP_dt;
boolean metric;

void setup() {
  Serial.begin(BAUD_RATE); // Used to type in characters
  gw.begin(RADIO_ID);
  if (!bmp.begin()) {
    Serial.println("Could not find a valid BMP085 sensor, check wiring!");
    while (1) { }
  }

  // Register sensors to gw (they will be created as child devices)
  gw.sendSensorPresentation(0, S_BARO);
  gw.sendSensorPresentation(1, S_TEMP);
  metric = gw.isMetricSystem();

}


void loop() {
  gw.powerUp(); // Power up radio

  float pressure = bmp.readPressure();
  float temperature = bmp.readTemperature();
 
  if (!metric) {
    // Convert to fahrenheit
    temperature = temperature * 9.0 / 5.0 + 32.0;
  }
 
  int forecast = sample(pressure);

  Serial.print("Temperature = ");
  Serial.print(temperature);
  Serial.println(metric?" *C":" *F");
  Serial.print("Pressure = ");
  Serial.print(pressure);
  Serial.println(" Pa");
  Serial.println(weather[forecast]);


  if (temperature != lastTemp) {
    gw.sendVariable(1, V_TEMP, temperature,1);
    lastTemp = temperature;
  }

  if (pressure != lastPressure) {
    gw.sendVariable(0, V_PRESSURE, pressure, 0);
    lastPressure = pressure;
  }

  if (forecast != lastForecast) {
    gw.sendVariable(0, V_FORECAST, weather[forecast]);
    lastForecast = forecast;
  }
 
  /*
DP/Dt explanation

0 = "Stable Weather Pattern"
1 = "Slowly rising Good Weather", "Clear/Sunny "
2 = "Slowly falling L-Pressure ", "Cloudy/Rain "
3 = "Quickly rising H-Press", "Not Stable"
4 = "Quickly falling L-Press", "Thunderstorm"
5 = "Unknown (More Time needed)
*/

  // Power down the radio. Note that the radio will get powered back up
  // on the next write() call.
  delay(1000); //delay to allow serial to fully print before sleep
  gw.powerDown();
  sleep.pwrDownMode(); //set sleep mode
  sleep.sleepDelay(SLEEP_TIME * 1000); // sleep to conserve power
}

int sample(float pressure) {
// Algorithm found here
// http://www.freescale.com/files/sensors/doc/app_note/AN3914.pdf
if (minuteCount > 180)
minuteCount = 6;

pressureSamples[minuteCount] = pressure;
minuteCount++;

if (minuteCount == 5) {
// Avg pressure in first 5 min, value averaged from 0 to 5 min.
pressureAvg[0] = ((pressureSamples[1] + pressureSamples[2]
+ pressureSamples[3] + pressureSamples[4] + pressureSamples[5])
/ 5);
} else if (minuteCount == 35) {
// Avg pressure in 30 min, value averaged from 0 to 5 min.
pressureAvg[1] = ((pressureSamples[30] + pressureSamples[31]
+ pressureSamples[32] + pressureSamples[33]
+ pressureSamples[34]) / 5);
float change = (pressureAvg[1] - pressureAvg[0]);
if (firstRound) // first time initial 3 hour
dP_dt = ((65.0 / 1023.0) * 2 * change); // note this is for t = 0.5hour
else
dP_dt = (((65.0 / 1023.0) * change) / 1.5); // divide by 1.5 as this is the difference in time from 0 value.
} else if (minuteCount == 60) {
// Avg pressure at end of the hour, value averaged from 0 to 5 min.
pressureAvg[2] = ((pressureSamples[55] + pressureSamples[56]
+ pressureSamples[57] + pressureSamples[58]
+ pressureSamples[59]) / 5);
float change = (pressureAvg[2] - pressureAvg[0]);
if (firstRound) //first time initial 3 hour
dP_dt = ((65.0 / 1023.0) * change); //note this is for t = 1 hour
else
dP_dt = (((65.0 / 1023.0) * change) / 2); //divide by 2 as this is the difference in time from 0 value
} else if (minuteCount == 95) {
// Avg pressure at end of the hour, value averaged from 0 to 5 min.
pressureAvg[3] = ((pressureSamples[90] + pressureSamples[91]
+ pressureSamples[92] + pressureSamples[93]
+ pressureSamples[94]) / 5);
float change = (pressureAvg[3] - pressureAvg[0]);
if (firstRound) // first time initial 3 hour
dP_dt = (((65.0 / 1023.0) * change) / 1.5); // note this is for t = 1.5 hour
else
dP_dt = (((65.0 / 1023.0) * change) / 2.5); // divide by 2.5 as this is the difference in time from 0 value
} else if (minuteCount == 120) {
// Avg pressure at end of the hour, value averaged from 0 to 5 min.
pressureAvg[4] = ((pressureSamples[115] + pressureSamples[116]
+ pressureSamples[117] + pressureSamples[118]
+ pressureSamples[119]) / 5);
float change = (pressureAvg[4] - pressureAvg[0]);
if (firstRound) // first time initial 3 hour
dP_dt = (((65.0 / 1023.0) * change) / 2); // note this is for t = 2 hour
else
dP_dt = (((65.0 / 1023.0) * change) / 3); // divide by 3 as this is the difference in time from 0 value
} else if (minuteCount == 155) {
// Avg pressure at end of the hour, value averaged from 0 to 5 min.
pressureAvg[5] = ((pressureSamples[150] + pressureSamples[151]
+ pressureSamples[152] + pressureSamples[153]
+ pressureSamples[154]) / 5);
float change = (pressureAvg[5] - pressureAvg[0]);
if (firstRound) // first time initial 3 hour
dP_dt = (((65.0 / 1023.0) * change) / 2.5); // note this is for t = 2.5 hour
else
dP_dt = (((65.0 / 1023.0) * change) / 3.5); // divide by 3.5 as this is the difference in time from 0 value
} else if (minuteCount == 180) {
// Avg pressure at end of the hour, value averaged from 0 to 5 min.
pressureAvg[6] = ((pressureSamples[175] + pressureSamples[176]
+ pressureSamples[177] + pressureSamples[178]
+ pressureSamples[179]) / 5);
float change = (pressureAvg[6] - pressureAvg[0]);
if (firstRound) // first time initial 3 hour
dP_dt = (((65.0 / 1023.0) * change) / 3); // note this is for t = 3 hour
else
dP_dt = (((65.0 / 1023.0) * change) / 4); // divide by 4 as this is the difference in time from 0 value
pressureAvg[0] = pressureAvg[5]; // Equating the pressure at 0 to the pressure at 2 hour after 3 hours have past.
firstRound = false; // flag to let you know that this is on the past 3 hour mark. Initialized to 0 outside main loop.
}

if (minuteCount < 35 && firstRound) //if time is less than 35 min on the first 3 hour interval.
return 5; // Unknown, more time needed
else if (dP_dt < (-0.25))
return 4; // Quickly falling LP, Thunderstorm, not stable
else if (dP_dt > 0.25)
return 3; // Quickly rising HP, not stable weather
else if ((dP_dt > (-0.25)) && (dP_dt < (-0.05)))
return 2; // Slowly falling Low Pressure System, stable rainy weather
else if ((dP_dt > 0.05) && (dP_dt < 0.25))
return 1; // Slowly rising HP stable good weather
else if ((dP_dt > (-0.05)) && (dP_dt < 0.05))
return 0; // Stable weather
else
return 5; // Unknown
}

So you so kindly supplies both sets of sketches for each sensor; how would you combine the sketches to utilize 1 Arduino Nano 3.0 to be able to run both of these sensor.  It was my understanding you could run multiple sensors from one Arduino 3.0 and that is what I am planning on doing.   Because in this example of temp & motion I plan on putting in our Barn and then will know if someone has entered and can be notified along with have space heaters by liquid supplies that come on when temp inside of barn falls below 34 to make sure gear doesn't freeze.


Then my other example on this thread
http://forum.micasaverde.com/index.php/topic,23517.0.html (http://forum.micasaverde.com/index.php/topic,23517.0.html)

I am utilizing my Arduino Nano 3.0 with the above thread sketch and a zfm-80.  I would like to add the motion sensor to the sketch in other thread along with removing the ZFM-80.

Let me know if this makes more since?[/code]
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on March 01, 2014, 08:59:56 am
Yes, you can combine sketches.  A motion sensor only uses one of the spare digital inputs.

How is a different story. First you'll need to familiar yourself with Arduino and programming in general.

In the setup section you will have to send presentation for all senors Vera should be aware of.

In the loop section you send in your sensor data either at some interval or by interrupt (digital input triggered). To make things a bit easier you could skip all code that handles sleeping.
 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: datammwv on March 01, 2014, 09:32:13 am
Ok so you can have it have two sensors connected.  On the Arduino sketch code what item for the radio needs to be changed so that it recognizes the 2nd sensor is my question.  I am new in Arduino so I am assuming you must combine the two sketchs Motion/weather into one larger sketch.

do I just drop this code into the weather code sketch under void loop
Code: [Select]
{
  gw.powerUp(); // Power up radio
  // Read digital motion value
  boolean tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
       
  Serial.println(tripped);
  gw.sendVariable(CHILD_ID, V_TRIPPED, tripped?"1":"0"); // Send tripped value to gw
 
  // Power down the radio. Note that the radio will get powered back up
  // on the next write() call.
  delay(200); //delay to allow serial to fully print before sleep
  gw.powerDown();
  sleep.pwrDownMode(); //set sleep mode
  sleep.sleepInterrupt(INTERRUPT,CHANGE);
}


do I just drop this in void setup in the weather code sketch?
Code: [Select]
{
  Serial.begin(BAUD_RATE); // Used to type in characters
  gw.begin(RADIO_ID);
  pinMode(DIGITAL_INPUT_SENSOR, INPUT); // sets the motion sensor digital pin as input
  // Register all sensors to gw (they will be created as child devices)
  gw.sendSensorPresentation(CHILD_ID, S_MOTION);
}

Then at the top of the Weather sketch I would need to enter these but change them to different interupts?
Code: [Select]
#define DIGITAL_INPUT_SENSOR 3 // The digital input you attached your motion sensor. (Only 2 and 3 generates interrupt!)
#define INTERRUPT DIGITAL_INPUT_SENSOR-2 // Usually the interrupt = pin -2 (on uno/nano anyway)
#define CHILD_ID 0 // Id of the sensor child

You mention in you code that only 2 and 3 generate interrupts but it looks like the motion (HC-SR501) sensor needs 1 interrupt and the weather (BMP085) needs 2?

Then what didn't come across clear when I first asked it, how does it know to create a second node id when starting inclusion for the second time.  Or do I need to remove the motions sensor that is already registered by itself and add them once together?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: petewill on March 01, 2014, 07:44:12 pm
@HEK
How would I do this for this project with a pro mini?  I have tried plugging it into the usb to serial adapter but I never see anything in the serial monitor when I'm using the NRF24L01+ and the additional sensors.  It works fine with the pro mini if I just have some simple code and something like a push button.  I have searched google but haven't been able to figure it out...

So your not getting any serial output from any of the provided examples on a pro mini using serial adapter?

I see output... Anyone else having this problem?

@HEK
I was wrong.  I just tried one of the new Pro Mini boards that I ordered and that one is working fine.  It might have been the batch of bad ones I got that was giving me problems.  Sorry for the false alarm.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Derek Macias on March 02, 2014, 02:39:08 am
@HEK
How would I do this for this project with a pro mini?  I have tried plugging it into the usb to serial adapter but I never see anything in the serial monitor when I'm using the NRF24L01+ and the additional sensors.  It works fine with the pro mini if I just have some simple code and something like a push button.  I have searched google but haven't been able to figure it out...

So your not getting any serial output from any of the provided examples on a pro mini using serial adapter?

I see output... Anyone else having this problem?
I think what he means is that when he had all the sensors and radio connected there is not enough power from the usb port for it to work and monitor serial data.

I have diavolino kit which I disabled power through the serial connection. I power the board separately that way I can monitor serial communication and all sensors and radio work.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: skr25 on March 02, 2014, 04:51:25 pm
Is there a way to handle both interrupt and time based output from Nano? I am able to combine motion sensor and DHT sketches. Ideally, I would like to have humidity and temperature shown after every 30 sec/ 1 min and trip value only when interrupt on pin 3 gets HIGH.
The workaround solution which I did, was to shorter the delay period to 5 sec and send new trip value. I believe,I can use attachinterrupt  to other pin (other than 2 and 3) on change with a routine call which can power on radio and send the message for the sensor connected on pin (other than 2 and 3). Please let me know your thoughts how to handle interrupts with non interrupt pin for nano.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on March 05, 2014, 04:58:59 am
A new simple binary switch example that can be uses  for window/door sensors or trigger buttons (like a doorbell).

The example takes advantage of  the internal pull up resistor of the Arduino board (no need for external pull-up resistor) when connecting a button or reed switch.

Debounce library is also used to minimize debounce problems.

https://github.com/mysensors/Arduino/tree/master/libraries/MySensors/examples/BinarySwitchSensor
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Bmlsx on March 05, 2014, 12:31:32 pm
hi all

thank you or the amazing work

one prbly stupid question

in my sensor (ex humdity) which is pretty straight forward

it never goes to the loop (or it goes and nothing gets printed on the serial)

any ideas will be much appreciated

thanx
G
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: joek on March 08, 2014, 09:29:31 am
hi all

thank you or the amazing work

one prbly stupid question

in my sensor (ex humdity) which is pretty straight forward

it never goes to the loop (or it goes and nothing gets printed on the serial)

any ideas will be much appreciated

thanx
G

Most likely there's a line in your setup() code before your loop() that's blocking/waiting for a response. In the case of the humidity sensor example I'd guess it's probably the sensor not initializing, so ensure it's connected correctly and correct data pin configured in the sketch. You can always comment out lines to see which is causing the problem.

From the humidity sketch example:
Code: [Select]
void setup() 
{
  Serial.begin(BAUD_RATE);  // Used to type in characters
  gw.begin(RADIO_ID);
  dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);    <=== my guess your code is waiting here
        . . . . . . .
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: coachclass on March 09, 2014, 03:56:05 am

Possible to use Arduino UNO as gateway?

The Uno has a different USB interface chip than the Nano. 

Quote
The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip.

The Nano uses the FTDI USB-serial chip.  I believe that's important since the driver used by the Vera depends on this chip.  But I'm a newbie, so others can chime in?

Is there an FAQ for this topic?  It's extremely useful, but this thread is super long with a mix of FAQ type questions and specific use case questions.

Is the Vera3 the only Vera that can be used?  Can you use the Veralite with the Arduino Nano gateway?



Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on March 09, 2014, 04:32:30 am
It is OK to connect the Arduino GW to a VeraLite. If you already have something connected to the USB port of your VeraLite you can use a powered USB hub to get access to more USB ports.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clandmeter on March 17, 2014, 07:38:44 pm
Just when I thought about getting some sensors going, my *voltage regulator* start smoking....
Seems the ebay seller send me LM335Z instead of L33ACZ and they dont like 5v on its pins :-)
Ill to wait another few weeks until I get the proper ones, probably better to pick up a few from a local shop.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: DeltaNu1142 on March 20, 2014, 09:46:43 am
Per request - I have included the BOM that includes the specific parts of interest...
I just ordered EVERYTHING from your BOM...  hopefully I'm not getting in over my head! The most expensive part of this project will be buying a soldering pen that doesn't suck.

I'm going this route to get the temperature of my kegerator into Vera, but there are obviously a TON of other cool things I can get done with Arduino. Thanks for your work on this, as well as to everyone else that pushed it this far.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: DeltaNu1142 on March 20, 2014, 02:38:41 pm
Has anyone used a sensor with a 240V (coil voltage) relay to monitor the operational status of a whole-house generator? That's the first thing that came to mind, after the beer temp, of course...

I am not a programmer, by any stretch of the imagination, so when these parts arrive I'll be pulling what information I can together on how to use a digital input channel to show that relay's status.

EDIT: I'm editing to keep the multiple posts down.
I don't see where anyone has developed a temperature sensor with a display. That would be handy. I've just registered on the Arduino forums and will see if I can find anything helpful there.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: rosskinard on March 20, 2014, 06:43:29 pm
Has anyone used a sensor with a 240V (coil voltage) relay to monitor the operational status of a whole-house generator? That's the first thing that came to mind, after the beer temp, of course...

I am not a programmer, by any stretch of the imagination, so when these parts arrive I'll be pulling what information I can together on how to use a digital input channel to show that relay's status.

EDIT: I'm editing to keep the multiple posts down.
I don't see where anyone has developed a temperature sensor with a display. That would be handy. I've just registered on the Arduino forums and will see if I can find anything helpful there.

You could get an OLED serial device maybe? Keep in mind the memory limits of the device though. Just loading the basic libraries for a sensor uses about 50% of the available memory on the boards...like 16K of 30K. Not sure what adding additional display libraries might do. I'm gonna guess it'll be ok, but something to keep in mind.

Not sure if it would be possible to build a node that isn't a sensor, but an interface...like a touchscreen LCD that can report information or control scenes/devices. I've been thinking about a Mega board and a 4" or 5" touchscreen that can be programmed for control and data display.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on March 20, 2014, 07:17:17 pm

You could get an OLED serial device maybe? Keep in mind the memory limits of the device though. Just loading the basic libraries for a sensor uses about 50% of the available memory on the boards...like 16K of 30K. Not sure what adding additional display libraries might do. I'm gonna guess it'll be ok, but something to keep in mind.

Not sure if it would be possible to build a node that isn't a sensor, but an interface...like a touchscreen LCD that can report information or control scenes/devices. I've been thinking about a Mega board and a 4" or 5" touchscreen that can be programmed for control and data display.

The LiquidCrystal library has a small footprint. Shouldn't be any problem.

A touchscreen sensor would make a nice addition to the examples. Anyone found one that I could try out?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: rosskinard on March 20, 2014, 07:25:26 pm

You could get an OLED serial device maybe? Keep in mind the memory limits of the device though. Just loading the basic libraries for a sensor uses about 50% of the available memory on the boards...like 16K of 30K. Not sure what adding additional display libraries might do. I'm gonna guess it'll be ok, but something to keep in mind.

Not sure if it would be possible to build a node that isn't a sensor, but an interface...like a touchscreen LCD that can report information or control scenes/devices. I've been thinking about a Mega board and a 4" or 5" touchscreen that can be programmed for control and data display.

The LiquidCrystal library has a small footprint. Shouldn't be any problem.

A touchscreen sensor would make a nice addition to the examples. Anyone found one that I could try out?

I was thinking about ordering something similar to this...the Mega simply because the touchscreen needs memory, power and I/O that might be pushing it for the smaller boards.

http://www.ebay.com/itm/SainSmart-Mega2560-3-2-TFT-LCD-Shield-Touch-Screen-SD-Reader-for-Arduino-2560-/271019848784

Just a touch screen:

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

The SparkFun has links to libraries and all so you can see some of what is needed to interface and run it.

To me, it would make a great status indicator and multi-scene controller.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: rosskinard on March 20, 2014, 07:29:04 pm
My desire on the touchscreen interface comes from the fact that the GE scene controller is a piece of crap (not even reliable enough for triggers) and the Leviton ones are way expensive for what they do.

Replace a light switch with a relay + power adapter + Arduino/radio + touchscreen and make it do a lot more than any scene controller could.

Just an idea I've had...gotta get employed again before I start dropping $ on more gadgets to play with.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on March 21, 2014, 01:29:59 am
Has anyone used a sensor with a 240V (coil voltage) relay to monitor the operational status of a whole-house generator? That's the first thing that came to mind, after the beer temp, of course...

I'm using the following relay to monitor the pump from my solar heaters.
order code: HF115F-A-230-1ZS1AF-555   
producer: http://www.hongfa.com/pro/HF115F-A_I_en.html

You can probably find something similar from your local supplier then you just connect +5v or GND via the relay to your binary input depending on if you want a low signal when it is on or a high signal. Then you also might need a pull-up or pull-down resistor if you don't make use of the arduinos own internal pull-up capabilities digitalWrite(INPUT_PIN,HIGH).
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: RichardTSchaefer on March 21, 2014, 08:35:41 am
I am working on a current sensor ... using a wrap around (any power wire) sensor.

I intend to measure power ... but you can use it as on/off sensor.
 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on March 21, 2014, 09:07:17 am
I am working on a current sensor ... using a wrap around (any power wire) sensor.

I intend to measure power ... but you can use it as on/off sensor.

Looking forward to your findings.

Guess you've seen the openenegymonitor project?
http://openenergymonitor.org/emon/node/58

/H
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: DeltaNu1142 on March 21, 2014, 09:17:36 am
I'm using the following relay to monitor the pump from my solar heaters.
order code: HF115F-A-230-1ZS1AF-555   
producer: http://www.hongfa.com/pro/HF115F-A_I_en.html
You can probably find something similar from your local supplier then you just connect +5v or GND via the relay to your binary input depending on if you want a low signal when it is on or a high signal. Then you also might need a pull-up or pull-down resistor if you don't make use of the arduinos own internal pull-up capabilities digitalWrite(INPUT_PIN,HIGH).
Outstanding!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: OutdoorITguy on March 22, 2014, 07:34:44 pm

You could get an OLED serial device maybe? Keep in mind the memory limits of the device though. Just loading the basic libraries for a sensor uses about 50% of the available memory on the boards...like 16K of 30K. Not sure what adding additional display libraries might do. I'm gonna guess it'll be ok, but something to keep in mind.

Not sure if it would be possible to build a node that isn't a sensor, but an interface...like a touchscreen LCD that can report information or control scenes/devices. I've been thinking about a Mega board and a 4" or 5" touchscreen that can be programmed for control and data display.

The LiquidCrystal library has a small footprint. Shouldn't be any problem.

A touchscreen sensor would make a nice addition to the examples. Anyone found one that I could try out?

I was thinking about ordering something similar to this...the Mega simply because the touchscreen needs memory, power and I/O that might be pushing it for the smaller boards.

http://www.ebay.com/itm/SainSmart-Mega2560-3-2-TFT-LCD-Shield-Touch-Screen-SD-Reader-for-Arduino-2560-/271019848784

Just a touch screen:

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

The SparkFun has links to libraries and all so you can see some of what is needed to interface and run it.

To me, it would make a great status indicator and multi-scene controller.

I just ordered the Kit from Amazon (Prime).  I'm going to try and make a touchscreen interface in every room and have it communicate back to my Vera to trigger scenes and turn devices on and off.   I was also looking at adding the voice kit in the future so I could give voice commands and it would process them locally and send the command over the link to the Vera.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: lasso on March 22, 2014, 09:30:18 pm
Hi everyone,
first of all I would like to very thank hek and rest of the people for your very helpful job. I'm looking forward to MySensors.org project.
@hek I have a question: what do You think about implement functionality for more then one Ethernet gateway in one MySensors network? IMO it would be useful for people who have in their house many Ethernet sockets.
Secondly I think that good idea would be add feature for Ethernet gateways, so that devices would read data from sensors which would connected directly to this gateways.
ps. There is any ETA for MySensors.org?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on March 24, 2014, 05:09:50 am
Hi everyone,
first of all I would like to very thank hek and rest of the people for your very helpful job. I'm looking forward to MySensors.org project.
@hek I have a question: what do You think about implement functionality for more then one Ethernet gateway in one MySensors network? IMO it would be useful for people who have in their house many Ethernet sockets.
Secondly I think that good idea would be add feature for Ethernet gateways, so that devices would read data from sensors which would connected directly to this gateways.
ps. There is any ETA for MySensors.org?

Hi,
http://www.mysensors.org launched yesterday! I probably should have made an announcement in this thread also ;)

If you plan to use more than one Ethernet gateway make sure to run them on a different frequencies (update Config.h) before building/uploading sketch. All sensors "connected" to it should also use the same frequency.

We currently don't support attaching sensors directly to the gateway.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: coachclass on March 28, 2014, 01:56:04 pm
Hi,
http://www.mysensors.org launched yesterday! I probably should have made an announcement in this thread also ;)


Awesome work Hek!

Does the Vera collect historical data (temperature graph)?  Can you use Xively or something similar to push temperature data?

Maybe the Raspberry Pi version of the gateway could push data to Xively?  I'm a newbie with Linux and Raspberry Pi.  I looked at the github for RPi gateway...but I don't know how to compile :(
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: pentium on March 28, 2014, 02:51:56 pm
Yes, a very nice site.  Thanks to you my wife is going to be even lonelier once all that stuff I ordered from china arrives. 

I have done all of the prep work that I can do without the Nano (which i ordered from amazon to speed things up) and that brings me to a questions.  Since I don't have an Arduino connected to my vera, it says that the serial port is not selected.  I went in to change the settings by selecting the arduino device and it accepted it but then my alarm serial port on the ad2usb says it is not set correctly.  Once I plug the arduino into the usb hub that currently has the ad2usb and a flash drive for the logs, will be able to have both devices connected at the same time?

I ordered the ethernet component today just in case the answer is no. 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on March 28, 2014, 03:21:34 pm
Hi,
http://www.mysensors.org launched yesterday! I probably should have made an announcement in this thread also ;)


Awesome work Hek!

Does the Vera collect historical data (temperature graph)?  Can you use Xively or something similar to push temperature data?

Maybe the Raspberry Pi version of the gateway could push data to Xively?  I'm a newbie with Linux and Raspberry Pi.  I looked at the github for RPi gateway...but I don't know how to compile :(

You should probably wait a bit before trying to run the RPI controller. It rpi-github code is not working properly at the moment.
Our short term plan: We need to finish setting up  the infrastructure and make some modifications of the RPI code before any sensor data can be sent to the MySensors cloud service. This is a completely standalone solution for home build sensors, no Vera needed. The RPI is powerful enough to encrypt traffic to the cloud.

The mid-term plan is to also allow logging of z-wave device sensor data (from MySensors vera plugin) to the cloud as well. Replace all dataMine/USB failures once and for all. But I can't promise this yet because of potential limitations of the Vera.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Salmoides on March 31, 2014, 07:33:03 pm
This is new. Downloaded latest as of 22 March. Seeing this in the log on my test box:

01   03/31/14 18:23:33.066   LuaInterface::CallFunction-2 lu_incoming failed [string "module("L_Arduino", package.seeall)..."]:377: attempt to concatenate local 'nodeDevice' (a nil value) <0x2e18c680>

Only two devices on talking to the SerialGateway, a HumiditySensor (DHT22) and a MotionSensor (DYP-ME003DD, the low voltage version, perfect for the 3.3v Pro Mini). This is coming from the MotionSensor.

I did notice that when I included this sensor (the first new one since downloading on 22 March), the primary "node" wasn't created, just the sensor.

What does that log error mean? TIA

Sal
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: blacey on April 01, 2014, 01:00:47 am
This is new. Downloaded latest as of 22 March. Seeing this in the log on my test box:

I did notice that when I included this sensor (the first new one since downloading on 22 March), the primary "node" wasn't created, just the sensor.

We implemented some important messaging changes after March 22nd, that fully resolve the parent nodes not being created.  The error you saw was probably due to the fact that the plugin was trying to set the last update on a parent node that doesn't exist.

You should download the latest GitHub version, reflash your gateway and your sensors and upload the latest Vera Plugin files to your Vera.  If any parent nodes are missing after upgrading, just run Include on the Plugin device and power cycle your sensors within 60 seconds...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Derek Macias on April 01, 2014, 11:54:00 am
I don't see where anyone has developed a temperature sensor with a display. That would be handy. I've just registered on the Arduino forums and will see if I can find anything helpful there.
I have one I've been using for a few months. It's for a Hitachi 44780 4 line by 20 character display and multiple temp sensors. It should work with any of the Hitachi lcds.  You can change the lines and character sizes. I'll put it up when I get a chance.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dagwood08 on April 05, 2014, 06:19:51 pm
Finally got my serial gateway up and running and got it to recognize my first sensor (humidity).  I went through a lot of trial and error without any success so it's nice to finally make some progress.  The gateway has been hooked up for a while but until now I couldn't get it to recognize any of the sensors I had tried.

The sensor seems to be transmitting OK and the gateway seems to receive the data, however within Vera UI5 there is nothing reported as far as humidity or temperature goes.  I have attached a picture of the only device that shows up for the sensor.

Listed below is a partial copy of the debug log for the sensor:

Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 1
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=0,ty=17,cr=179: 1.2+
Ack: received OK
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=7,cr=137: 0
Ac?Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 1
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=0,ty=17,cr=179: 1.2+
Ack: received OK
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=7,cr=137: 0
Ac?Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 1
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=0,ty=17,cr=179: 1.2+
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=7,cr=137: 0
Ac?Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 1
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=0,ty=17,cr=179: 1.2+
Ack: received OK
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=7,cr=137: 0
Ac?Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 1
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=0,ty=17,cr=179: 1.2+
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=7,cr=137: 0
Ac?Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 1
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=0,ty=17,cr=179: 1.2+
Ack: received OK
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=7,cr=137: 0
Ac?Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 1
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=0,ty=17,cr=179: 1.2+
Ack: received OK
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=7,cr=137: 0
Ack?Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 1
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=0,ty=17,cr=179: 1.2+
Ack: received OK
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=7,cr=137: 0
Ack?Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 1
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=0,ty=17,cr=179: 1.2+
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=7,cr=137: 0
Ac?Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 1

Hoping someone might be able to assist.  Thanks.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: blacey on April 05, 2014, 10:54:02 pm
Finally got my serial gateway up and running and got it to recognize my first sensor (humidity).  I went through a lot of trial and error without any success so it's nice to finally make some progress.  The gateway has been hooked up for a while but until now I couldn't get it to recognize any of the sensors I had tried.

The sensor seems to be transmitting OK and the gateway seems to receive the data, however within Vera UI5 there is nothing reported as far as humidity or temperature goes.  I have attached a picture of the only device that shows up for the sensor.

...snip, snip, snip...

Hoping someone might be able to assist.  Thanks.

You are looking at the Arduino node, not the child nodes that report the temperature and humidity levels.  Look for devices (child nodes) labeled Arduino:Humidity 1:0 and Arduino:Temp 1:1.

See attached...

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dagwood08 on April 05, 2014, 11:05:53 pm
I don't have any child nodes. That's my issue.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: rosskinard on April 05, 2014, 11:13:47 pm
I don't have any child nodes. That's my issue.

Dumb question, but did you click Reload in the UI?

Sometimes the nodes on my system don't appear in the UI without doing this...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dagwood08 on April 06, 2014, 09:32:56 am
I've reloaded the UI many times and the child nodes still don't appear.  Also, in the parent node for the sensor the "Last Updated" field is blank so perhaps there's still something wrong.  I don't know how to troubleshoot at this point as it appears the sensor is sending information, and the gateway recognizes the humidity sensor on the network.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: BulldogLowell on April 06, 2014, 10:14:50 am
forgive me if you have done they 10 times already, but did you check to see if

a) the humidity sensor worked in the basic sketch
b) it is connected to the right pins

the ID's on the pins are so small, I often get them messed up...

and if the sensor isn't displaying, that's what is usually wrong.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: blacey on April 06, 2014, 10:22:22 am
Dagwood08,

Ok, the node is trying to send the presentation message to the gateway but it is failing for some reason due to ack timeouts that indicate some sort of communication problem.  The Vera plugin will display the child sensor nodes if and only if it receives the presentation message and that looks not to be the case.

To troubleshoot, please try the following:

Please try the following:

1. Triple check the radio wiring connections on your node and gateway to ensure they are connected to the correct pins and that the connections are solid
2.  Make sure you have a decoupling capacitor attached across ground and VCC on both your node and your gateway
3.  Ensure that you are running the identical version of the Sensor library on your gateway and node.  If you are up for it, I suggest that you pull the latest version from the git repo on https://github.com/mysensors
4.  Change libraries/MySensors/Config.h to enable debug.
5.  If you are using an amplified NRF24L01+ on the gateway, try adjusting the power level in libraries/MySensors/Config.h
6.  Consider changing Config.h to use a different channel than the default 76

Additional resources:  http://www.mysensors.org/build/debug and http://forum.mysensors.org/category/5/troubleshooting

There has to be something simple going on here like mis-wiring/loose connection, 3.3V "clean" power to the radio, software mismatch, etc. so keep the faith!  We will help you figure it out.

Best,
Bruce

P.S.  For reference, with debug enabled you should see the following messaging pattern from your Humidity sensor console once it is working correctly.

Code: [Select]
Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 2
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=255,mt=0,ty=17,cr=52: 1.2+
Ack: received OK
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=255,mt=4,ty=7,cr=14: 0
Ack: received OK
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=255,mt=4,ty=14,cr=82: Humidity
Ack: received OK
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=255,mt=4,ty=15,cr=133: 1.0
Ack: received OK
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=0,mt=0,ty=7,cr=65: 1.2+
Ack: received OK
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=1,mt=0,ty=6,cr=226: 1.2+
Ack: received OK
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=255,mt=4,ty=13,cr=206:
Ack: received OK
Message available on pipe 1
Sent ack msg to 0
Rx: fr=0,to=2,la=0,ci=255,mt=4,t=13,cr=177(ok): I
Message addressed for this node.
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=1,mt=1,ty=0,cr=128: 70.2
Ack: received OK
T: 70.16
Relaying message back to gateway.
Tx: fr=2,to=0,la=2,ne=0,ci=0,mt=1,ty=1,cr=192: 48.7
Ack: received OK
H: 48.70
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: BulldogLowell on April 06, 2014, 10:27:28 am
Bruce,

I have a question.

I tried adding the distance sensor and it 'crashed' the MySensors plugin (image attached).  I verified the device worked in a sketch, checked the pinout connections and even rewired it with a DHT22 temperature sensor to make sure I had everything right.  The sensor works, the Nano is good, the radio is good...

Has anyone else experienced difficulty with the Distance sketch disrupting the entire MySensors plugin?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: rosskinard on April 06, 2014, 11:01:09 am
Bruce,

I have a question.

I tried adding the distance sensor and it 'crashed' the MySensors plugin (image attached).  I verified the device worked in a sketch, checked the pinout connections and even rewired it with a DHT22 temperature sensor to make sure I had everything right.  The sensor works, the Nano is good, the radio is good...

Has anyone else experienced difficulty with the Distance sketch disrupting the entire MySensors plugin?

I didn't have any problems running the distance sensor sketch with a HC-SR04 module connected. I did modify the following lines from the sketch to change it from metric:

Code: [Select]
  metric = gw.isMetricSystem();changed to
Code: [Select]
  // metric = gw.isMetricSystem();
and

Code: [Select]
  int dist = metric?sonar.ping_cm():sonar.ping_in();changed to
Code: [Select]
  int dist = sonar.ping_in();
also

Code: [Select]
  Serial.println(metric?" cm":" in");changed to
Code: [Select]
  Serial.println(" in");
Everything worked in the Vera...I could trigger stuff depending on the distance read.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: BulldogLowell on April 06, 2014, 11:19:04 am
hmmm.

I used the same radio/Nano pair and it worked fine with a DHT22.

I'll try again, it is good to know the code works and the problem is me.

thanks.


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: blacey on April 07, 2014, 02:14:10 am
To help troubleshoot gateway and sensor version-mismatch issues, we have modified the system to report a unique version identifier for both the gateway and sensor nodes that is based upon the GIT tag and commit id.  You can see an example from my network below...

Note that the unique lib version matches on the sensor nodes and the plugin/gateway node.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: datammwv on April 07, 2014, 08:17:25 am
For those of you that wish to update to the unique version Identifier which is great for troubleshooting I have narrowed down the steps to the following.

1. On your Vera Upload D_Arduino1.json to the cmh_ludl directory
2. On you local pc upload the Mysenors directory to you <driveletter>arduino\library  directory.
3. reload your either serial or Ethernet gateway sketch; so reads new config.*, relay.*, sensor.*, gateway.*, version.*
4. on your Senors reload sketch so reads new; so reads new config.*, relay.*, sensor.*, gateway.*, version.*

Might have to reload a few times but will start showing unique id which is a great trouble shooting piece.  Thanks guys!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dagwood08 on April 07, 2014, 09:15:09 pm
Blacey and Bulldoglowell,

Thanks for you help and tips on where to look for getting my humidity sensor working.  I added caps to the radios on the gateway and sensor.  Also found one of my pins on the sensor wasn't hooked up correctly to the VCC.  After I made those changes I got a little further but was then receiving the message in the serial monitor for the sensor that the temperature and humidity weren't being read.  I checked my connections over and over and couldn't figure out what was wrong.  There are only 3 connections at the DHT sensor so it's pretty tough to get it wrong.  Probably spent at least an hour fretting over that.  Turns out my pullup resistor value was way off.  I ordered a bunch of 4.7K resistors off eBay and assumed they sent me the right ones.  Discovered the ones they sent were 4.7 ohms - way off.  Once I put a proper resistor in there everything's working fine.  Finally SUCCESS!!!  At least now I know my gateway works and I can move on to making other types of sensors without having to debug everything and wonder if it's the gateway, sensor, or both if I have problems.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: blacey on April 08, 2014, 12:02:24 am
Blacey and Bulldoglowell,

Thanks for you help and tips on where to look for getting my humidity sensor working. 

Once I put a proper resistor in there everything's working fine.  Finally SUCCESS!!! 

At least now I know my gateway works and I can move on to making other types of sensors without having to debug everything and wonder if it's the gateway, sensor, or both if I have problems.

Awesome!  Glad to hear it and look forward to what you will create next ;)

Cheers,
Bruce
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: BulldogLowell on April 08, 2014, 12:17:31 am
Thanks...

Great to see you worked it out.  I'm a MySensors noobie and appreciate the strong support here.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Ruetech on April 08, 2014, 08:27:10 pm
 Ok I've got my plugin installed and my Vera is configured but as i try to upload the sketch to my arduino I run into an IP address not defined error. I believe this is do to my lack of webserver.h in my library. Does anyone now how to add this to my library? Aside from that I'm more interested in hardwiring my n/c sensors to my arduino instead of wireless but I Dont fully understand the arduino sketch so I'm not really sure how to modify the sketch for this. If some could point me in the right direction on either of these issues it would be much appreciated.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on April 09, 2014, 03:26:50 am
Ok I've got my plugin installed and my Vera is configured but as i try to upload the sketch to my arduino I run into an IP address not defined error. I believe this is do to my lack of webserver.h in my library. Does anyone now how to add this to my library? Aside from that I'm more interested in hardwiring my n/c sensors to my arduino instead of wireless but I Dont fully understand the arduino sketch so I'm not really sure how to modify the sketch for this. If some could point me in the right direction on either of these issues it would be much appreciated.

This plugin and library is build for wireless communication using the NRF-radio. You could emulate the serial protocol from an attached arduino. Look here:
http://mysensors.org/build/sensor_api#the-serial-protocol

To fix your library problems follow the instructions here:
http://mysensors.org/build/arduino

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Ruetech on April 09, 2014, 10:50:05 am
I'll check it out thanks
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dvbit on April 16, 2014, 03:49:52 am
I finally got around to building a proper gateway this weekend...  Works great...

Thanks to Hek and everyone else who has contributed to making the Arduino plug-in a success.

**UPDATE**

Per request - I have included the BOM that includes the specific parts of interest...
1 Adruino Nano - http://www.ebay.com/itm/130977189883?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649
1 nRF24L01+PA+LNA wireless communication module - http://www.ebay.com/itm/nRF24L01-PA-LNA-wireless-communication-modules-w-antenna-2-4GHz-2Mbps-/191015401054?pt=LH_DefaultDomain_0&hash=item2c7967b65e
1 4cm x 6cm prototype board
1 4.7uf 50v Capacitor - http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItemVersion&item=220961387730&view=all&tid=1302877760012
3 1K resistors
1 10K resistor
1 Push Button Switch - http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=231147569538
1 3mm Red LED
1 3mm Yellow LED
1 3mm Green LED
30 AWG Kylar Wire
4 M2-0.4x5mm brass stand offs
4 M2-0.4x4mm flat head screws
4 M2-0.4x4mm pan head screws
1 Project Box (2.9 x 1.9 x 1.1 inches)  - http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=111263231186

Hello I might have lost it in the mega thread but I have not been able to find the detailed wiring for your gateway implementation . I read the "standard one" on mysensors but although I AMA. Newbie I would like to implement it following the same very nice design you have  done.
Could you point me to the post where it is?

Thanks for all the fantastic work
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on April 16, 2014, 04:19:18 am
@Dvbit

http://www.mysensors.org/build/vera#advanced-build-options
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dvbit on April 16, 2014, 05:35:33 am
oops... I did not realize that the building instruction on the site included all ...
time to buy some stuff.


BTW : I post here in attacchment an Excel that I menttioned on a post on the mysensro site (I do not know how to attacch it there).

If you find it useful. publish it there.
TX for the good work.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on April 16, 2014, 06:30:07 am
oops... I did not realize that the building instruction on the site included all ...
time to buy some stuff.


BTW : I post here in attacchment an Excel that I menttioned on a post on the mysensro site (I do not know how to attacch it there).

If you find it useful. publish it there.
TX for the good work.

Just drag'n'drop file or use the little upload icon when posting on mysensors fourum.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Dvbit on April 16, 2014, 08:31:28 am
yep... nodebb is gorgeous... but I am not familiar yet
Title: Humidity sensor DHT22. No temperature showing. Both libraries are in sync
Post by: jpaulwhite on May 05, 2014, 12:24:11 pm
Hello All,

Please see the below screenshots. My DHT22 is not giving me any temperature or humidity. Am I doing something wrong? The gateway and node libraries are listed as 1.3b3 (18848a2) Help...

http://108.51.175.78:8069/shelli-rae/pictures/misc/Capture1.PNG
http://108.51.175.78:8069/shelli-rae/pictures/misc/Capture2.JPG
http://108.51.175.78:8069/shelli-rae/pictures/misc/Capture3.JPG
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: BulldogLowell on May 05, 2014, 01:04:43 pm
you have probably done this a million times but check:

Sensor output is on correct pin on your arduino?
Do you actually have a voltage at the sensor?  Test the outboard leads for a voltage  Should be 3.3V or 5V depending on what power pin you attached.  Those leads are thin and have difficulty connecting with anything but a breadboard.

Perhaps upload a quick photo of the breadboard..

Were you able to get it to work on its own, without the MySensors sketch, just the basic sketch?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 05, 2014, 08:21:27 pm
Thanks for the reply!

I uploaded the test DHT sketch and that worked fine. I was able to do Serial Monitor and see Humidity and Temperature numbers. So it looks like the DHT works.

Let me check to make sure there is nothing I need to edit in the Humidity Sketch then re upload that and see what happens

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 05, 2014, 08:35:52 pm
Ok I reuploaded the Humidity sketch and still no dice. Screen still looks the same as the screenshots.

Looks like it can read the radio but for whatever reason the temp isnt reading...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: BulldogLowell on May 05, 2014, 08:42:00 pm
I know this sounds silly, but I have one that I have been working with that gives me a problem when I compile/upload.

I then manually reset the arduino board (with Power from a 5v wall wart) and it works.  I cannot explain it but it reads false until I use the arduino's reset button.

you are using Hek's unedited sketch, yeah?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on May 05, 2014, 10:37:02 pm
That sounds like there may not be enough power getting to the arduino. Ive had similar issues which resolved by using a better USB cable or a different USB port!


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 06, 2014, 07:33:46 am
I checked the voltage at the DHT22. Its exactly 3.3. I was surprised too lol

And yes I used the unedited Humidity sketch, connected it on PIN 3. Here's some pics of my wireless wiring

http://108.51.175.78:8069/shelli-rae/pictures/misc/14050006.jpg
http://108.51.175.78:8069/shelli-rae/pictures/misc/14050007.jpg
http://108.51.175.78:8069/shelli-rae/pictures/misc/14050008.jpg

Here's a video as well
http://youtu.be/MtRyPmiEszk

At this point I am thinking my next move would be to turn on debugging?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 06, 2014, 08:00:58 am
Maybe it's something on my Arduino Node 1 configuration? I don't think its something in the code, gotta be something in my setup thats different...but since the radio synced up (It sent the version info, etc) you would think it would send the data too. I looked at the sketch and it is fairly simple. If it doesn't read the data then it throws an error. But in my case it didn't throw an error which leads me to believe something else
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: BulldogLowell on May 06, 2014, 08:39:19 am
Maybe it's something on my Arduino Node 1 configuration? I don't think its something in the code, gotta be something in my setup thats different...but since the radio synced up (It sent the version info, etc) you would think it would send the data too. I looked at the sketch and it is fairly simple. If it doesn't read the data then it throws an error. But in my case it didn't throw an error which leads me to believe something else

try some more debug printing:

Code: [Select]
#include <Sleep_n0m1.h>
#include <SPI.h>
#include <EEPROM.h> 
#include <RF24.h>
#include <Sensor.h> 
#include <DHT.h> 

#define CHILD_ID_HUM 0
#define CHILD_ID_TEMP 1
#define HUMIDITY_SENSOR_DIGITAL_PIN 3
unsigned long SLEEP_TIME = 30; // Sleep time between reads (in seconds)

Sensor gw;
DHT dht;
Sleep sleep;
float lastTemp;
float lastHum;
boolean metric = true;

void setup() 
{
  gw.begin();
  dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN);

  // Send the Sketch Version Information to the Gateway
  gw.sendSketchInfo("Humidity", "1.0");
  Serial.println("Sketch information sent");
  // Register all sensors to gw (they will be created as child devices)
  gw.sendSensorPresentation(CHILD_ID_HUM, S_HUM);
  gw.sendSensorPresentation(CHILD_ID_TEMP, S_TEMP);
  Serial.println("sensors registered with gateway");
 
  metric = gw.isMetricSystem();
}

void loop()     

  Serial.println("in the loop");
  delay(dht.getMinimumSamplingPeriod());
  Serial.println("delay completed");
  float temperature = dht.getTemperature();
  Serial.println(temperature);
  if (isnan(temperature)) {
      Serial.println("Failed reading temperature from DHT");
  } else if (temperature != lastTemp) {
    lastTemp = temperature;
    if (!metric) {
      temperature = dht.toFahrenheit(temperature);
    }
    gw.sendVariable(CHILD_ID_TEMP, V_TEMP, temperature, 1);
      Serial.print("T: ");
      Serial.println(temperature);
  }
 
  float humidity = dht.getHumidity();
  if (isnan(humidity)) {
      Serial.println("Failed reading humidity from DHT");
  } else if (humidity != lastHum) {
      lastHum = humidity;
      gw.sendVariable(CHILD_ID_HUM, V_HUM, humidity, 1);
      Serial.print("H: ");
      Serial.println(humidity);
  }

  // Power down the radio.  Note that the radio will get powered back up
  // on the next write() call.
  delay(1000); //delay to allow serial to fully print before sleep
  gw.powerDown();
  sleep.pwrDownMode(); //set sleep mode
  sleep.sleepDelay(SLEEP_TIME * 1000); //sleep for: sleepTime
}

and see where the sketch stalls

you may want to flash the EEPROM.  It will erase your radio ID's but you will start fresh.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 06, 2014, 09:11:36 am
Thanks for the help Bulldog!

When I uploaded and ran your code the Serial Monitor (On 115200 Baud rate) gives:

Sketch information sent
sensors registered with gateway

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: BulldogLowell on May 06, 2014, 09:19:33 am
hmmm 
you may want to flash the EEPROM.  use the ClearEepromConfig.ino sketch

first delete the devices that vera created when you first included it.

It will rebuild them.  You will have to perform the inclusion process again...

Also, can you verify that the polarity of the capacitor is correct
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 06, 2014, 09:22:38 am
I just thought about something. When I first got the plugin installed, I went to the MySensors plugin, clicked the Wrench, and changed the Unit from Metric to Imperial

I just noticed the code appears to stop at the Metric conversion.

Think this may be the problem? Can I remove or modify that conversion?

I changed the Unit back to Metric but still am not getting any readings. Let me reboot my Veralite and see (UI5)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: BulldogLowell on May 06, 2014, 09:25:11 am
great,  that is exactly where the sketch stalled!

you could try to comment out the line and see what happens



Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 06, 2014, 09:37:24 am
Ok I commented out the line. Now serial monitor gives me this:

sensors registered with gateway
in the loop
delay completed
30.40
T: 30.40
H: 29.30

But...my sensors still are not giving me any numbers. I tried changing the Unit on the MySensors plugin back to Metric, reloaded, still no dice. Changed it back to Imperial, reloaded still no dice.

I am thinking that maybe that variable is what returns the number and since I commented it out it isn't returning anything?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: BulldogLowell on May 06, 2014, 09:45:34 am
flash the eeprom, delete the devices and re-include.  you gotta get that mistake to clear out.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on May 06, 2014, 09:54:31 am
Ok I commented out the line. Now serial monitor gives me this:

sensors registered with gateway
in the loop
delay completed
30.40
T: 30.40
H: 29.30

But...my sensors still are not giving me any numbers. I tried changing the Unit on the MySensors plugin back to Metric, reloaded, still no dice. Changed it back to Imperial, reloaded still no dice.

I am thinking that maybe that variable is what returns the number and since I commented it out it isn't returning anything?


Turn on debugging in config.h to see what is actually transmitted from your sensor.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 06, 2014, 09:57:44 am
How do I get to config.h though?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on May 06, 2014, 10:01:57 am
http://www.mysensors.org/build/debug
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 06, 2014, 10:46:08 am
Ok I edited the config.h
I then recompiled and uploaded the Humidity Sensor.ino file

Not getting debug messages

Do I have to include config.h along with the other libraries at the top of the Humidity ino file too?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 06, 2014, 11:03:40 am
Dont worry I think I know what happened. Gimme 1 sec...
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on May 06, 2014, 07:09:22 pm
Restart the ide..

Sent from my Nexus 5 using Tapatalk

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 07, 2014, 02:11:19 pm
Hello,

First off... Thank you all for assisting. I have the debug messages coming up now.

I was running the IDE as root so when I imported the libraries it copied them to the {installdir}/libraries directory which was under root because that is what I was running the iDE as. But I downloaded and installed the iDE under a different account on my Linux box. So when I was editing Config.h under my regular profile, the IDE was pulling the Config.h saved under the the {installdir}/libraries directory.

Once I edited the correct Config.h the DEBUG messages started coming up. Yayyyyy! I have posted them below.

I get about twenty of these:
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=0,ty=7,cr=56: 1.3b3 (960efcd)
Ack: receive timeout

Then I started getting these:
Tx: fr=1,to=255,la=1,ne=255,ci=255,mt=4,ty=9,cr=6:
No relay nodes was found. Trying again in 10 seconds.

Any suggs at this point? I'm running the stock Humidity sketch, NO edits at all

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 07, 2014, 02:19:18 pm
Do I need to check my Gateway? The devices are 2 feet from each other
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 07, 2014, 02:54:11 pm
After commenting out the metric part as before im getting this but still nothing in MIOS:

?Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=14,cr=213: Humidity
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=15,cr=2: 1.0
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=0,ty=7,cr=56: 1.3b3 (960efcd)
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=1,mt=0,ty=6,cr=155: 1.3b3 (960efcd)
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=1,mt=1,ty=0,cr=130: 26.3
Ack: receive timeout
T: 26.30
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=1,ty=1,cr=174: 36.6
Ack: receive timeout
H: 36.60
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=1,mt=1,ty=0,cr=16: 26.2
Ack: receive timeout
T: 26.20
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=1,ty=1,cr=1: 36.5
Ack: receive timeout
H: 36.50
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=1,mt=1,ty=0,cr=130: 26.3
Ack: receive timeout
T: 26.30
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=1,ty=1,cr=174: 36.6
Ack: receive timeout
H: 36.60
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=1,ty=1,cr=29: 36.8
Ack: receive timeout
H: 36.80
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: hek on May 07, 2014, 03:57:21 pm
You got com problem.


1. Check wiring,
2. Put a capacitor on radio
3. Switch power source
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 07, 2014, 04:04:48 pm
Hmmmm,

I have a 4.7uf on the radio already
I am powering it from my Linux box
Guess I can check the wiring again once I get home
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on May 07, 2014, 07:13:35 pm
Have the gateway and the slave both just been built? - if so the problem could be at either end. But it's a comms problem. The gw.isMetricSystem() code being commented out just lets the code run a bit further, until you reach the next comms error.

I might have a look at writing a bit of code that establishes if the radio is actually correctly connected and operational. See next post.

On a side point - the radio IRQ line is not used by the code, so it doesn't need to be connected to the arduino.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on May 07, 2014, 10:31:59 pm
Try this code (it's untested) - place immediately after gw.begin(); in the sensor code. It checks to see if one of the registers in the radio can be changed or not.

Code: [Select]
bool radioConnected = true;

// must be a "Plus" version of the radio IC and must be able to set the speed bits to 1,0
if (!gw.RF24::setDataRate(RF24_250KBPS)) radioConnected = false;

// must be able to set the speed bits to 0,1
if (!gw.RF24::setDataRate(RF24_2MBPS)) radioConnected = false;

// restore the data rate as defined in config.h
gw.RF24::setDataRate(RF24_DATARATE);

if (radioConnected)
   Serial.println("Radio is probably connected OK");
else
   Serial.println("Radio is not connected correctly");

This may also do the trick:

Code: [Select]
if (gw.RF24::isPVariant())
   Serial.println("Radio is probably connected OK");
else
   Serial.println("Radio is not connected correctly");
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 08, 2014, 06:40:58 am
Thanks a-lurker!

Ill run this later today and post some results.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 08, 2014, 07:00:51 am
A-lurker and all,

Here's the results. I ran the first bit of code.

Started sensor.
Relay=0, distance=1
Radio id stored in EEPROM was: 1
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=0,ty=17,cr=77: 1.3b3 (960efcd)
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=7,cr=137: 0
Ack: receive timeout
Radio is not connected correctly
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=14,cr=213: Humidity
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=255,mt=4,ty=15,cr=2: 1.0
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=0,ty=7,cr=56: 1.3b3 (960efcd)
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=1,mt=0,ty=6,cr=155: 1.3b3 (960efcd)
Ack: receive timeout
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=1,mt=1,ty=0,cr=117: 19.8
Ack: receive timeout
T: 19.80
Relaying message back to gateway.
Tx: fr=1,to=0,la=1,ne=0,ci=0,mt=1,ty=1,cr=143: 62.7
Ack: receive timeout
H: 62.70
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clippermiami on May 08, 2014, 09:30:41 am
Try this code (it's untested) - place immediately after gw.begin(); in the sensor code. It checks to see if one of the registers in the radio can be changed or not.

Code: [Select]
bool radioConnected = true;

// must be a "Plus" version of the radio IC and must be able to set the speed bits to 1,0
if (!gw.RF24::setDataRate(RF24_250KBPS)) radioConnected = false;

// must be able to set the speed bits to 0,1
if (!gw.RF24::setDataRate(RF24_2MBPS)) radioConnected = false;

// restore the data rate as defined in config.h
gw.RF24::setDataRate(RF24_DATARATE);

if (radioConnected)
   Serial.println("Radio is probably connected OK");
else
   Serial.println("Radio is not connected correctly");

This may also do the trick:

Code: [Select]
if (gw.RF24::isPVariant())
   Serial.println("Radio is probably connected OK");
else
   Serial.println("Radio is not connected correctly");

I've been having nothing but problems getting this stuff to work so I tried your little patch in the Light Sensor sketch and there was no new output. After working with @hek for several days I did resolve a problem with the Sensor and this is what I get now:
Code: [Select]
Started sensor.
Open ping reading pipe: 255
Tx: fr=255,to=255,la=255,ne=255,ci=255,mt=4,ty=9,cr=184:
No relay nodes was found. Trying again in 10 seconds.
But there is no message regarding the radio attached correct/not. This sensor uses the vanilla radio so maybe it isn't a "plus" version and the patch won't work anyway.

Back to the drawing board.

At this point I suspect the Vera Gateway all I get on that end is is
Code: [Select]
"0;0;4;11 Arduino startup complete"
so far I've replaced the Arduino, the radio, recompiled, rewired. all that's left is the power supply but i have to sort out how to do that and keep the serial monitor as well. I've powered the Gateway from both ny laptop USB and from the Vera 3 USB and nothing seems to work.

UPDATE:

I used your patch on my Gateway and got
Code: [Select]
0;0;4;11 Arduino startup complete
Radio is not connected correctly

But I was certain it was. That lead me to go back to the build instructions and i found at least part of the my problem and i'm more confused now than before. In the mysensors.org site under building the Vera Gateway it describes how to build the USB-Serial Gateway and says that you must use a Arduino Nano which I did. There is a link to "connecting the radio" and following that link leads to a wiring diagram for the Arduino Pro Mini used in the Sensors. The wiring I used came from the wiring diagram for the Ethernet Gateway because it correctly depicts a Arduino Nano but it didn't work for me either.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: a-lurker on May 08, 2014, 06:11:55 pm
Quote
Try this code (it's untested)
NOTE the UNTESTED - someone who has a working system may want to verify it. I will once I get some time to do so (could be awhile) but it should work (famous last words!).

@jpaulwhite
Keeping in mind the above and assuming my code works then - your radio is not connected or it's non functional.

@clippermiami
Quote
there is no message regarding the radio attached correct/not.
Then the code is not being executed.

Quote
wiring I used came from the wiring diagram for the Ethernet Gateway
If it's USB attached, use that wiring - if it's Ethernet attached, use the Ethernet wiring. In both cases the corresponding gateway code should be used.

Always make sure the radio is using 3.3 Volts not 5V.

As for Plus versions of the IC. I suspect all the radio hardware being sold these days uses the Plus version of the IC. This will be mandatory for Hek's latest software. I would have to check but it's probably mandatory for the current software as well but don't take my word for it.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 12, 2014, 10:18:57 am
All,

I tested the wiring from my radio to the jumper pins. Everything checked out. Continuity on all. I did NOT text the wiring on my Gateway but should I assume that's ok since the sensors showed up in MIOS?

If I assume the gateways ok then I need to see where I connected stuff on this breadboard. Here's some more pics:

http://108.51.175.78:8069/shelli-rae/pictures/misc/14050018.jpg
http://108.51.175.78:8069/shelli-rae/pictures/misc/14050019.jpg
http://108.51.175.78:8069/shelli-rae/pictures/misc/14050020.jpg
http://108.51.175.78:8069/shelli-rae/pictures/misc/14050021.jpg

Does the breadboard wiring look ok?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clippermiami on May 12, 2014, 11:19:11 am
Having reworked my Gateway several times, from scratch to no avail I finally received my Ross Kinard PCBs from OSHPark and assembled it yesterday and it worked first time. Leads me to think that some of the "Dupont" wires used in the "scramble wire" version are defective.

Anyway the Gateway is now working and I was able to connect to my first Light Sensor and include it in my Vera (interestingly its also "scramble wired" but its working  ??? ).
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: BulldogLowell on May 12, 2014, 12:32:01 pm
Having reworked my Gateway several times, from scratch to no avail I finally received my Ross Kinard PCBs from OSHPark and assembled it yesterday and it worked first time. Leads me to think that some of the "Dupont" wires used in the "scramble wire" version are defective.

Anyway the Gateway is now working and I was able to connect to my first Light Sensor and include it in my Vera (interestingly its also "scramble wired" but its working  ??? ).

Great, success!

now the fun part starts.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clippermiami on May 12, 2014, 01:08:59 pm
Having reworked my Gateway several times, from scratch to no avail I finally received my Ross Kinard PCBs from OSHPark and assembled it yesterday and it worked first time. Leads me to think that some of the "Dupont" wires used in the "scramble wire" version are defective.

Anyway the Gateway is now working and I was able to connect to my first Light Sensor and include it in my Vera (interestingly its also "scramble wired" but its working  ??? ).

Great, success!

now the fun part starts.

Yeah, it's satisfying to have something working, encourage you to keep going
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clippermiami on May 17, 2014, 10:16:11 am
i'm not certain this is a "wireless sensor" situation or a more generalized Bridged-Veras situation but I'll put it here for now.

I moved my test Arduino MySensor subsystem from my Primary Vera3 to a Secondary VeraLite in bridge mode. When I set up the Bridge Mode the Primary does import the secondary and its associated MySensor Plugin, Node and Sensors. The Primary does eventually get the Humidity and Temperature updates from the Secondary but it does not get any other information. The "Node" block is empty and does not reflect the information on the Secondary (Sketch Name, versions, Last Update time, etc) (attached)

Is this normal or do I have something else wrong?

John
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 27, 2014, 10:35:32 am
Success!!!!

Thank you all for the assistance. I also posted in the Vera forums. I had SEVERAL problems. Most of which I should readily recognize and know how to correct, if they happen again. I'll go in the order of the ones I corrected first.

#1 Configuration problem????

Over and over I was told, it was a wiring issue. But initially, the gateway AND both devices showed up ( See screenshot http://108.51.175.78:8069/shelli-rae/pictures/misc/Capture1.PNG ) But there were no Temperature or Humidity numbers showing up. Another thing you can see is the Last Updated Time. That's a very important field, because if it is not updating you know something is going on (At a glance)

So initially, even though signs pointed to a wiring issue the fact that both sensors showed up led me to believe it was something else. So I checked all the wiring connections on the sensor device and everything had continuity. I then checked all the wiring connections on my gateway device and they were fine. I was PISSED! lol. I then noticed that the status window at the top of Vera had some Lua error and the Gateway device had a red status bar going across the bottom. I knew that meant something was going on with the Gateway device but I had already spent a lot of time troubleshooting so I ignored it for two weeks.

I came back from vacation yesterday and decide to give it another go. I notice the error at the top of the Vera status said it couldn't communicate with the I/O port. I go to Apps|Develop Apps|Serial Port Configuration and notice it is not detecting the USB device.

What in tarnation! I don't know if it's been like this the whole time, but I unplugged and replugged in the Gateway device, reload the Vera, and now the Vera is detecting the USB device. I then pull up the Gateway device (In my case it is named MySensors Plugin) and configure it per the instructions 8 data, 1 stop bit, and No parity. 115200 baud. I hit Reload and Voila! I error messages about Serial I/O are gone, the Lua Startup (What does THAT error mean in general?) error is gone, and the red status bar across the bottom of my Gateway device is gone.

#2 I did not have the correct DHT library loaded, and I did not have the MySensors library (Sensor.h) loaded properly.

I turn to the Humidity sensor device. Since it showed up initially, and the wiring was fine I am thinking it should work. However, I can't get the libraries loaded to get the sample code to compile. After checking the libraries and making sure I had the correct DHT library loaded (There's one library that works with plx-daq, and a DIFFERENT one that works with the MySensors code) the sample sketch would not compile. I then turned on verbose logging in my IDE (Arduino 1.0.5) and noticed that it was not finding Sensor.h I then found that was in the MySensors folder which was in my libraries folder. I then created a folder named Sensor.h in my libraries folder and put Sensor.h and Sensor.cpp in there. I compiled and now it said the version and ummmm config.h was missing. So I copied those into the folder as well and now it compiled. I then uploaded it immediately and Reloaded my Vera (Now I know you don't have to do that. As soon as you upload a sketch to your sensor device it normally connects to the Gateway device and Vera and begins working) and now I have numbers reporting for the Humidity and Temperature.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 27, 2014, 10:38:19 am
After moving my Humidity sensor several times, it stopped working again.

Arrrrghgghhhhhhhhhh. Has to be a wiring problem. I got it flashed find and it was working fine, it stopped working after I moved it the 5th or 6th time.

Any suggs? At this point I'll try the troubleshooting code above and post up what I get
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: jpaulwhite on May 27, 2014, 03:59:18 pm
Hello,

Working again. The wire connection for MOSI was loose. I had a jumper pin connecting the Female end of a jumper wire to my breadboard. The inside of the jumper wire is extremely loose. Put a MALE header PIN on my breadboard, eliminated the jumper pin, and connected a new jumper wire directly from the rf424 to my Breadboard. All is well now.

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: persimmonx on May 28, 2014, 01:25:23 am
This is a similar project to what you guys are doing:

http://ninjablocks.com/collections/ninja-blocks/products/ninja-blocks-kit

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: steets250 on June 03, 2014, 06:04:47 pm
After discovering that I could create an IR device using MySensors, I wondered if I would use this as a substitute to SQ Blaster, iTACH, or USB-UIRT, which all cost around $100.

I tossed together an Arduino Nano, the NRF24L01, and an IR LED. However, MySensors currently does not have any implementation of an IR blaster device.

I tried to create my own Arduino program using S_IR as the device presentation, but I later discovered that the S_IR device has not yet been added to the MySensors plugin, so it doesn't work.

I was wondering if anybody here is able to create some sort of add-on plugin that allows MySensors to create an IR blaster device?

Thanks for your help,
Steven
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: gregl on June 03, 2014, 06:12:18 pm
Hi Stephen, if I understand you correctly it sounds like the bits missing is the additional info needed in the mysensors vera plugin. I needed to do the same when I tried to use the heater device type.
You can see what I did by looking at my submission on github.. I'm mgf909 . let me know if you can't find  it and I'll get a link.



Sent from my Nexus 5 using Tapatalk

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: steets250 on June 03, 2014, 06:22:24 pm
Thanks! I am looking over it now.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Jasonejc on June 03, 2014, 08:57:02 pm
I just got my MySensor gateway and first child device working today.. AWESOME!  what great brain food this is.  I'm not exactly sure where I'm going with it but I bought a ton of parts, Nanos, sensors, capacitors, regulators, breadboards, etc., etc.

Can't believe how simple it was.. I have never played with Arduino before.. started from scratch.. got it working in a few hours.

Well done Hek, Bruce and others.

Thank you!!
 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: steets250 on June 03, 2014, 08:58:59 pm
Jasonejc - Good to hear! Let us know what you make!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: zedrally on June 18, 2014, 01:09:09 am
Has anyone built a relay yet?
I'm interested in switching and have noticed that relay boards are available, they seem ideal for light circuits and  a inexpensive solution.

One problem I noticed that there are no 240v AC to 3.3v DC converters in the MySensor store, (I know that this should probably be posted on their forum, forgive me, I started reading the first 12 pages of this thread and literally ran out of time to read the remaining 35+!).

Is this because no one has built any or there are to many hurdles to overcome?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on June 18, 2014, 03:07:45 am
I guess there are many including me that have relay attached to an arduino it is nothing special.

I use the 5v version of the arduino pro mini so I just use cheap 230v to 5v USB chargers like these -> http://www.ebay.com/itm/New-USB-EU-Plug-Power-Home-Wall-Charger-Adapter-for-iPhone-4-3G-3GS-4G-4S-/171181728995?pt=LH_DefaultDomain_15&hash=item27db39e4e3

If you use the a arduino that needs 3.3v you van use these -> http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=2&pub=5575069610&toolid=10001&campid=5337433187&customid=&icep_item=261172232237&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg

Or just connect the 5v to the "RAW" (3.35 -12 V) pin.

you should see the "hurdles" as an challenge and learning possibility.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: zedrally on June 18, 2014, 03:17:05 am
^^^
Thanks, that was the start I needed.
Hopefully it's easy to break down into discrete components.
Next step ordering the rest of the "bits & pieces"
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clippermiami on June 28, 2014, 02:47:35 pm
Sent the first pass at my sensor PCB off to OSHPark for a trial run. This version will need tweaking, it's larger than it needs to be but I'm still learning with Eagle. I created some custom libraries for the battery holder, the Up-Regulator (0.8v=>3.0v), the NRF24L01, etc., so that slowed things down a bit. The board has gone to fab and should be here in a week so.

This sensor board has: CR-123A 3v Lithium Battery; 3v Boost/Regulator; 2 Digital, 2 Analog, 1 L2C ports; battery level monitoring. Mine uses miniature screw terminal blocks for the I/O connection rather than plugs or pin-headers.

Keeping my fingers crossed, my first project with Eagle :-)
 
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Jasonejc on June 29, 2014, 02:55:24 pm
Can you share a screen shot of the layout?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: clippermiami on June 29, 2014, 04:45:14 pm
Can you share a screen shot of the layout?

Herewith version 1.0.

This is a 3v battery powered sensor for Arduino Pro Mini using the MySensors Plug In. It supports 2@ Digital, 2@ Analog and 1@ L2C interface and will use miniature screw terminals for sensor connections. Power is from a CR123A 3v Lithium Battery and it has one of the 0.8v=>3v boost/regulator modules onboard to suck as much life out of the battery as possible. The battery monitor voltage divider is contained in a cutout in the battery holder to save some space. Each of the sensor terminal blocks provides +3v and GND on the outside terminals and the sensor input on the inside pair of screws. I'm thinking about adding a 3v=>5v boost/regulator to power 5V sensors but that may be in the version 2.0 board.

This was done before I created the Eagle Libraries for the "CR-123 Battery Holder", the "NRFL01" and the "0.8v
=>3v Boost/Regulator" and everything was done with pads and spacing so there is no silkscreen outline of those devices in this first cut.

This is my first project with Eagle and PCB fabrication so I'm sure it could be better, tighter, etc. Right now everything is spaced out so the board is larger than need be. Once I get the boards I'll be able to adjust for physical spacing and do a version 2.0 (assuming its wired right :) to begin with. )

I've started working on a 5V external power version right now while I wait for these PCBs.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: zogg on June 30, 2014, 02:55:31 pm
I seem to be stuck in the starting blocks so I have a few questions:

1. When I uploaded all the files to Vera and created the device, I got "MySensors Plugin" but not an Arduino Gateway Plugin with the Arduino picture. Are these the same?

2. The MySensors Plugin is red and says "Lua Failure". I tried adding the IP:PORT to the Advanced tab of my Ethernet Gateway device but it doesn't work. I've rebooted Vera several times trying to get it to work.

3. I read earlier that the Arduino UNO can't be used as a gateway, even though the info on MySensors.org says you can use "almost any model". Is this my problem, using a UNO?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: C4Vette on June 30, 2014, 04:15:41 pm
A UNO with ethernet is ok. If you want to connect via USB your only option is a Nano. Then you have to set the right serial speed. All info is on mysensors.org explaining this.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: zogg on June 30, 2014, 05:35:50 pm
So it's not a Nano/UNO issue.

This is what I see in the Dashboard, the plugin is red and says Lua Failure. At the top, it says" MySensors plugin - Cannot send command - communications error". When I click "Start" a popup says "Device communication failure".

Is it showing Lua Failure because there is an actual error starting the code, or because it can't communicate with the Ethernet Gateway?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: C4Vette on July 01, 2014, 01:25:51 am
What Vera UI-version are you running and what type Vera do you have?
On a VeraLite or Vera-3 it may not be higher than UI5, so if you upgraded to UI6 you should go back.
What are you using for Arduino? A UNO with ethernet? Then you should edit the EthernetGateway.ino for a static IP-address, connect it to a router/hub/switch and check if you can ping the device.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: zogg on July 01, 2014, 09:41:47 am
What Vera UI-version are you running and what type Vera do you have?
On a VeraLite or Vera-3 it may not be higher than UI5, so if you upgraded to UI6 you should go back.
What are you using for Arduino? A UNO with ethernet? Then you should edit the EthernetGateway.ino for a static IP-address, connect it to a router/hub/switch and check if you can ping the device.

I have a Vera 3 running UI5. I have not upgraded to UI6.

For the gateway I am trying to use my Arduino UNO. I wired it up with the Ethernet ENC28J60 and the wireless module per the instructions. I also edited EthernetGateway.ino per the instructions and put in the static IP. I have double checked my wiring and all appears to be correct.

Still getting the "Lua Failure". The log just says communication error.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: C4Vette on July 01, 2014, 04:42:03 pm
Is the static IP in the same subnet as the Vera and your PC? I don't have an Ethernet module myself so I don't know if you should be able to ping it. You could connect the Uno's USB to your PC and look at the serial output for the debug messages.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: zogg on July 01, 2014, 05:01:37 pm
Do you need an active client module before this works? I was trying to get the gateway up and working first, then get my first sensor client working, but maybe I need the client to be active.

And yes, static IP in the same subnet. I tried to ping it but it didn't work. And the ethernet gateway sketch only echoes messages it receives from the client to the serial port. I suppose I can add some debug statements though.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: C4Vette on July 02, 2014, 04:32:08 am
It is not needed to have a working/active sensor.
You wrote: "the ethernet gateway sketch only echoes messages it receives from the client", but does this mean you see nothing at all from the serial port? The USB-version shows a message like "gateway started" or something like that.
And you are sure the "EthernetGateway.ino" is correctly edited, saved, compiled and uploaded? Then I'm out of ideas, sorry. Maybe search for a sketch to check the correct working of the ENC28J60 shield.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Zooz on July 02, 2014, 06:32:09 am
I had similar problems when plugging the GW to Vera3. Solved it by connecting to the main router instead. And yes, changed the IP's in both cases to match the ones allocated by either VERA or the router.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: zogg on July 02, 2014, 09:43:35 am
It is not needed to have a working/active sensor.
You wrote: "the ethernet gateway sketch only echoes messages it receives from the client", but does this mean you see nothing at all from the serial port? The USB-version shows a message like "gateway started" or something like that.
And you are sure the "EthernetGateway.ino" is correctly edited, saved, compiled and uploaded? Then I'm out of ideas, sorry. Maybe search for a sketch to check the correct working of the ENC28J60 shield.

Sorry, yes, it does say "Arduino startup complete". I was looking in the sketch and the only Serial.print is to echo incoming client messages, which is what I was referring to.

I think your idea to try another ethernet sketch is the next thing to try. As Zooz suggested, I did connect it to the same switch as Vera but that didn't help either. So I need to make sure the ethernet is working.

I do appreciate the suggestions, thanks much!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: zogg on July 02, 2014, 11:41:45 am
SUCCESS!!!

I had a bad wire on one of the control pins to the Ethernet shield. When the basic EchoServer sketch wouldn't work either, I then started checking everything until it ran.

Lessons learned:

1. MySensors.org has old pictures. The MySensors Plugin device that shows up in the Vera dashboard, MySensors Plugin, looks totally different and has a different picture from the one shown on MySensors.org (Arduino Gateway Plugin). For a newbie this is very confusing.

2. The Ethernet Gateway WILL respond to pings, which is helpful.

3. When it says "Communication failure", it means it. And since Vera will try to communicate as soon as you create the device (in the Installing Vera Plugin section), it's better to have your Gateway on and ready to go before creating the Device.

Great work all and thanks for the help!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: C4Vette on July 03, 2014, 03:49:10 am
Congratulations  8)
Now built those sensors!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: ServiceXp on July 10, 2014, 12:31:18 pm
Reading over much of this information...., its a little overwhelming for those who have no electronics background... 

Is there a "starter Kit" (includes everything needed) that can be purchased for Battery powered Temp/Humidity setup?


Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: waynehead99 on July 10, 2014, 12:33:29 pm
Have you looked at the mysensors.org site? Might find what your looking for there. There isn't any kits really but it's broken down really well on what you need to buy, where to get it, and how to build it.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: pentium on July 23, 2014, 09:33:28 am
I am suffering much like servicexp appears to be.  I have a box of stuff that i ordered and a few attempts at building the gateway, radio, etc.  I'm afraid that I am also going to have to find a working model to get me started.  At least if I had something that I knew worked, I could gain the confidence to build more sensors.  I will check the forum at my sensors and see if anyone wants to create built starter kits.  Or failing that, but a box of chinese parts.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: zogg on July 24, 2014, 10:54:36 am
Take it a step at a time. First download the Arduino software development stuff, plug your board in, and try out some of the simple examples like Blink. Change the LED blink times to make sure you understand how to edit and download code. If you are using the ethernet module, then hook it up too and try the simple EchoServer or other sketch to make sure it's working.

Once you are familiar with playing with the Arduino itself, then start playing with the Vera part. Download and install the Vera plugin files, then install the gateway sketch on the Arduino, and get the gateway talking to Vera.

The last thing you should do is build a sensor and try to get it talking to the gateway. At this point it should be easier for you, and a lot of the sensors are easier to wire up and get working.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: ServiceXp on July 24, 2014, 11:46:46 am
This is exactly how my approach is going to be. I've ordered everything necessary to complete my objectives (with extras in case I damage something), but plan to take it step_by_step.  In the end, If I can pull this off, then ANYONE can..  :P
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: integlikewhoa on October 06, 2014, 02:30:22 am
I have the EnergyMeterPulseSensor setup and running. VERA doesn't seem to be updating the "WATTS" I see the KWH keeps climbing every few seconds (around 13 secs), but the watts just sit at one number and never moves no matter if I have everything on or off in the house.

How is this supposed to work? Does the KWH reset so often or just keep climbing?

How is the "watts" calculated and where is it done?

I have tried resetting and refreshing everything but still same any other ideas?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: integlikewhoa on October 06, 2014, 02:26:28 pm
10 hour plus update.

Watts does change but ever so slowly. This morning I has reading like 800, few hours later now reading 1191.

KWH is still climbing the next day at 30.85 and doing so every 13 seconds pretty regularly.

I flick on the A/C and watch for 10 min or more and the watts haven't changed.

Looking at dataMine graph looks as if the updates are more then an hour apart and in no setup order. In the middle of the night there was a 4 hour gap between points.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: DeltaNu1142 on October 06, 2014, 02:45:49 pm
I came back to this last week, because I finally upgraded to a Vera 3. I was able to get my serial gateway plugin to respond (I can click to add devices). However, my test temperature sensor with the radio module attached didn't get picked up by the plugin. When I'm motivated to try again, I'll probably post more details.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: ServiceXp on October 06, 2014, 07:07:08 pm
I came back to this last week, because I finally upgraded to a Vera 3. I was able to get my serial gateway plugin to respond (I can click to add devices). However, my test temperature sensor with the radio module attached didn't get picked up by the plugin. When I'm motivated to try again, I'll probably post more details.

What was the serial monitor output on the sensor?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: DeltaNu1142 on October 07, 2014, 07:53:35 am
What was the serial monitor output on the sensor?
I didn't even check. I'll have a look after I get through some other issues (setting up another IP camera, etc.).
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: macrho on October 31, 2014, 08:41:52 am
I have my gateway working and a temperature/humidity sensor in my garage.
In the advanced tab of the sensor, there is a variable section which has LastUpdate
The value is currently: 1414706296

It does not appear to be a date, perhaps it's the number of seconds from some specific starting point?
It appears it is: Thu, 30 Oct 2014 21:58:16 GMT  (epoch)

Couple of questions:

1) Can the LastUpdate show the actually date time formatted for local culture?

2) It appears my Temperature/Humidity sensor has stopped working, if my assumptions above are correct. What's the best way to troubleshoot?

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 31, 2014, 09:01:37 am
It would be best to maintain compatibility not to change the format of the time stamp for LastUpdate. Using epoch time is a common practice in the computer industry especially when it comes to software.

- Garrett

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: macrho on October 31, 2014, 09:42:13 am
I'm not sure I understand a resistance to formatting a date time field? It certainly seems useful to be able to open the advanced tab and be able to read the info without having to go to a website to format it for me. Perhaps you are part machine and can read it  8)
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: ServiceXp on October 31, 2014, 10:27:20 am

2) It appears my Temperature/Humidity sensor has stopped working, if my assumptions above are correct. What's the best way to troubleshoot?

 1) Make sure it's powered up..  ;D
 2) Power cycle it to see if it comes back on-line.
 3) Connect the Sensor to the Serial Monitor to see whats going on with it.
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: garrettwp on October 31, 2014, 07:48:37 pm
I'm not sure I understand a resistance to formatting a date time field? It certainly seems useful to be able to open the advanced tab and be able to read the info without having to go to a website to format it for me. Perhaps you are part machine and can read it  8)

It makes it easier to use the value when using it for other things like in lua code, graphing, and so on.

- Garrett

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: macrho on October 31, 2014, 07:59:23 pm
So my other thought would be to put the last updated info on the Control tab or perhaps in the actual display of the device (kind of like netatmo though that's for the master control) -- perhaps it's not a big deal.  Anyway, Happy Halloween, be safe out there!
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: Brighters on February 17, 2016, 01:45:15 pm
It's a bit quiet down here... Anything still going on?
I'm waiting for my 2.4 GHz radio to arrive in the mail, then I will try this out. But, I use UI7.... Has it been tested with UI7?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: akbooer on February 17, 2016, 01:47:33 pm
Yes, lots going on...

...but, unlike Vera, it doesn't go wrong!

There's a UI7 branch on GitHub, I believe, for the gateway plugin, which should work.  Are you using ethernet or serial bridge?
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: 4Crawler on March 14, 2016, 12:38:26 am
It's a bit quiet down here... Anything still going on?
I'm waiting for my 2.4 GHz radio to arrive in the mail, then I will try this out. But, I use UI7.... Has it been tested with UI7?

I just built a serial gateway and temp/humidity sensor w/ the 1.5 build and its working fine.  A few gotchas to get it all sorted out but nothing major.  I posted a couple of videos on my YouTube channel, first one below:
https://youtu.be/rtsa-pN_R9M?list=PLpY2FP1a9tiurSiQTwhalz4KBxg_7db65
Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: korttoma on March 14, 2016, 08:42:57 am
The reason it is quiet here is that everyone has moved the MySensors discussions to -> http://forum.mysensors.org/ and there is allot going on!!  :D

Title: Re: Arduino Sensor Plugin - Build your own wireless sensors!
Post by: 4Crawler on April 09, 2016, 12:45:09 pm
I added a "self-powered" USB hub to my VeaLite to support a memory stick and the MySensors serial gateway.  It lets the hub run off the same 12VDC power that the Vea does, so no need for a separate power brick and the additional cables.  Video on the setup below:
https://youtu.be/K_hlMJ0q1Ok

This in itself saves a few watts of power that would have been used by the separate wall wart for the hub (about 20KWH/year savings!).  Ultimate goal for my Vera is to place it on my solar battery bank running off 12VDC power.