This page last changed on May 25, 2013 by lawrie.

Would adding a generic serial protocol be a good idea? I am thinking mainly of the case of integrating with Arduino-based controllers and possibly sensors. The parameters for such a protocol would be something like, com port, data rate and message in hex.

I have several Arduino based controllers that this would work for, using USB connections. For example I have one that sends IR codes. I have code for this in my HouseControl project and code easily contribute it.

I am not sure how sensors would work as they would need some decoding of incoming data and triggering of the relevant OR sensor.

Yes would be happy to see this as a contribution.

Posted by juha at May 25, 2013 16:32

This would at once be a proper solution for a Velbus-integration!

Posted by helsenbe at Jun 18, 2013 21:40

Hi Juha,

Can you add this XML to the staging designer for this protocol, please:

<?xml version="1.0" encoding="UTF-8"?>

<!--

 OpenRemote, the Home of the Digital Home.
 Copyright 2008-2013, OpenRemote Inc.

 See the contributors.txt file in the distribution for a
 full listing of individual contributors.

 This is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as
 published by the Free Software Foundation; either version 3.0 of
 the License, or (at your option) any later version.

 This software is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 You should have received a copy of the GNU General Public
 License along with this software; if not, write to the Free
 Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 02110-1301 USA, or see the FSF site: http://www.fsf.org.

-->

<!--
 |  Generic serial protocol configuration for OpenRemote Designer.
 |
 |  Author: Lawrie Griffiths
 +-->
<openremote xmlns="http://www.openremote.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.openremote.org protocol.xsd">
	<protocol displayName="Serial" tagName="serial">
		<attr name="port" label="COM port">
			<validations>
				<allowBlank>false</allowBlank>
			</validations>
		</attr>
		<attr name="rate" label="Data rate (bps)">
			<validations>
				<allowBlank>false</allowBlank>
				<regex message="Data rate must be an integer">\d+</regex>
			</validations>
		</attr>
		<attr name="command" label="Command">
			<validations>
				<allowBlank>false</allowBlank>
			</validations>
		</attr>
	</protocol>
</openremote>
Posted by lawrie at Jul 03, 2013 09:52

Done!

Posted by juha at Jul 03, 2013 10:27

I have committed a first version of this to my workspace in SVN.

Here is an example Arduino sketch, which uses this protocol and my library (available on Github) to control LightwaveRF devices with an Arduino and a cheap RF 434Mhz transmitter:

#include <LightwaveRF.h>
                     
byte myid[] = {0x6F,0xEB,0xBE,0xED,0xB7,0x7B};

void setup() {
  lw_setup();
  Serial.begin(9600);
}

void loop() {
  if (Serial.available()) {
    char c1 = Serial.read();
    while(!Serial.available());
    char c2 = Serial.read();
   
    if (c2 >= '0' && c2 <= '9') { // device number
      byte d = c2 - '0';
      if (c1 =='1') {
        Serial.println("Switch device on");
        lw_cmd(0,d,LW_ON,myid);
      } else if (c1 == '0') {
        Serial.println("Switch device off");
        lw_cmd(0,d,LW_OFF,myid);
      }
    }
  }
}

The implementation of the protocol is similar to the existing TCP/IP socket protocol, except that it keeps the serial connections open. It handles sensors by polling for the data, rather than using an event listener. I am not sure if an event listener implementation would be better.

And here is an example of a sensor getting the power reading from an OpenEnergyMonitor emonTx using a Jeelink or similar device that runs Jeelib:

#include <JeeLib.h>
#include <avr/eeprom.h>
#include <util/crc16.h>

#define SERIAL_BAUD 57600
#define COLLECT 0x20 // collect mode, i.e. pass incoming without sending acks

#define EMONTX_NODE 10
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// RF12 configuration setup code

typedef struct {
    byte nodeId;
    byte group;
    char msg[RF12_EEPROM_SIZE-4];
    word crc;
} RF12Config;

static RF12Config config;
static int power;

void setup() {
    Serial.begin(SERIAL_BAUD);

    if (rf12_config(0)) {
        config.nodeId = eeprom_read_byte(RF12_EEPROM_ADDR);
        config.group = eeprom_read_byte(RF12_EEPROM_ADDR + 1);
    } else {
        Serial.print("No configuration");
    }
}

void loop() {   
    if (Serial.available()) {
      if (Serial.read() == 'p') { 
        Serial.println(power);
      }
    }
    
    if (rf12_recvDone()) {
        byte n = rf12_len;
        if (rf12_crc == 0) {    
            byte node = (rf12_hdr & 0x1f);
            if (node == EMONTX_NODE) { 
              power = (rf12_data[0] + (rf12_data[1] << 8));;
            }
            if (RF12_WANTS_ACK && (config.nodeId & COLLECT) == 0) {
                rf12_sendStart(RF12_ACK_REPLY, 0, 0);
            }
        } 
    }
}
Posted by lawrie at Jul 05, 2013 09:38

Hi

I'm new to OpenRemote and would really appreciate some help.

I import and support the whole Velbus range of home automation modules and would really like to offer some of my clients a more flexible remote interface that supports additional protocols, like the iTach modules.

Is there anywhere I can go to read up on how to get the Velbus system working with OpenRemote.

Many thanks

Stuart

www.mdar.co.uk

UK importer of Velbus modules.
www.velbus.eu/products

Posted by mdar at Nov 18, 2014 17:50

hello

I have tested the UART (Serial) communication, with FTDI device, between arduino uno and openremote on windows but it doesn't work.
The led, on arduino board, don't flash when I send data from OR to Arduino UNO that is why I think I have a problem with OR.
Does anyone have an idea to resolve it ?

Thanks

Posted by lionel81 at Dec 05, 2014 17:33

Hi

You might be interested to know that the Full Velbus protocol is being integrated into OpenRemote

I've just got some 'proving out' of the 61 core commands to do first.

The plan is to add full functionality to the Demo OpenRemote composer, but limit the amount of modules it will work with to 5.
At the same time to add unlimited functionally to OpenRemote Pro.

We'll make a public announcement very soon

Cheers

Stuart

Posted by mdar at Jul 10, 2015 15:27

Not sure but I guess OR will open/close serial comm once the command is triggered. In this case it will reset the Arduino. Confirm this please.

Anyway, Try to use a Serial/IP bridge, make one yourself in Python. Java is a PITA for Serial.
I only use Arduino MEGA with Ethernet Shield talking with OR via UDP. Somethings I even don't send direct to OR, The Arduino stream UDP to a Phyton server to process and then send to OR through UDP too.
Works like a charm, fast and reliable.

Posted by rberg at Sep 22, 2015 01:48
Document generated by Confluence on Jun 05, 2016 09:30