Usb serial connection between OH2 and Arduino

I have connected a relay and a keypad to a arduino. I want my openhab to send switch on and off commands to arduino hand receive key strokes from arduino. Can please any one tell how i can achieve that.
And where do i have to add this line
EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyS2:/dev/ttyACM0:/dev/ttyAMA0"
I couldn’t find /etc/default/openhab2. I have /etc/openhab2, but there is no script to put it.

One method is to use MQTT and publish/subscribe the info there. Then with the MQTT Binding you can achieve what you want with openHAB2.

It all depends on your sketch code (to configure it to pub and sub to MQTT).

How did you install OH2 and on which operating system?
Why do you want to modify the SerialPorts setting for Java?

If you are trying to have a direct USB connection from your OH2 host to the Arduino to control and read its peripherals (relay and keypad): I can’t help you… I don’t know if it is possible… maybe yes :slight_smile:

Mqtt is for online i want usb or Rx Tx serial communication

Look at Mysensors ( www.mysensors.org) serial gateway
all bassed on arduino with sketches

and use the mysensors binding

Thanx for the suggestion mate i look into it. But i knw how to make serial connection between arduino and pi. But how to do it in openhab. How to configure openhab to use it

you have to have a binding to openhab and the usb.
like serial.binding or mysensors.binding
take a look here

Yes i have added serial binding but where do i have to add EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0:/dev/ttyS0:/dev/ttyS2:/dev/ttyACM0:/dev/ttyAMA0"
In oh1 it was added in start.sh
But in oh2 the start.sh dosnt have any code only 2 line of somethin

put it in things file

like this
Bridge mysensors:bridge-ser:gateway [ serialPort="/dev/ttyUSB0", sendDelay=200, baudrate=115200, skipStartupCheck=true ] {
}

/etc/openhab2/

Thanx mate i will definitely try that