[SOLVED] Serial Binding OH2

Your item should be fine, what are you sending the serial port? Do you see anything in userdate/logs/events.log when you send data to the port?

The Arduino is sendeing the message “Toggle Light”. And i can not see anything about it in the events.log
I tried to get the message to see on a serial monitor (works fine, so the port is fine)
Do you know that i am useing openhab2?
Do I first have to make a thing and give the item then the channel of the thing?

Right, your not going to see anything about Toggle Light in the logs, its just text in the String Arduino. I wanted to know if you see anything about Arduino in the event.og.

The serial binding is for openHAB 1, so you don’t need to worry about channels or things.

1 Like

There is not anything about the Arduino String.

Not sure what to say, do you see any errors? I am still on openHAB 1.8.3 so I may not be able to help more.

You could try DEBUG, and also could try adding the following to userdata/etc/org.ops4j.pax.logging.cfg

# serial logger
log4j.logger.org.openhab.binding.serial = DEBUG, serial, osgi:*
log4j.appender.serial=org.apache.log4j.RollingFileAppender
log4j.appender.serial.layout=org.apache.log4j.PatternLayout
log4j.appender.serial.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-26.26c{1}] - %m%n
log4j.appender.serial.file=${openhab.logdir}/serial.log
log4j.appender.serial.append=true
log4j.appender.serial.maxFileSize=100MB
log4j.appender.serial.maxBackupIndex=10

I do not get any errors. Maybe i have found something. In the wiki it says "If you are using non standard serial ports you have to
adapt start.sh to have the serial port included. the java command line
should then include the following parameters:

-Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0

So maybe openhab is not useing the Port because of that. (is it possible?)

Yes, its possible, in openHAB 2 you can do that via an environment variable.

Try:
export EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0"
./start_debug.sh

Should i just execute this command in the unix command line in the /usr/shared/openhab2 folder?

yep

I have found something in the log :

Binding configuration of type ‘serial’ of item ‘Arduino’ could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: Could not open serial port /dev/ttyACM0: Serial port ‘/dev/ttyACM0’ could not be found. Available ports are:

But nothing is listed after that. Maybe that would help us to find the solution. (the Arduino is definetly on /dev/ttyACM0)

Yep, you need to tell Java that it can use that port.

export EXTRA_JAVA_OPTS=“-Dgnu.io.rxtx.SerialPorts=/dev/ttyACM0”
./start_debug.sh

<>
nathan stratton

1 Like

That does not change anything. :disappointed:

Now that is odd, I am not a debian fan so I don’t use the .deb package, but I thought that setting the env var would work. Your starting with ./start_debug.sh after export right? Or are you trying to start with system scripts?

1 Like

I have been starting with system scripts (systemctl start openhab2.service)

Ya, that would not use the env var, can you try manually?

1 Like

Ohh now it is coming in. Good job man. Thank you. I’m really happy now. Have a nice day. <3

Hello to everyone, sorry if this old post is wrong, but I have the same problem, I put in the java options
"-Dgnu.io.rxtx.SerialPorts = / dev / ttymxc3" if I start with the script start.sh works perfectly, if I start up as a service does not work, is there a way to fix it?

Thank you

P.S. this is an on-line translation

This is now documented at: https://www.openhab.org/docs/administration/serial.html

My OpenHAB 1.8.3 install running on Ubuntu 16.04 LTS (GNU/Linux 4.4.0-47-generic i686) has this -Dgnui.io.rxtx… java arg in ~/openhab/bin/start.sh:. When the system restarts OpenHAB picks up the -Dgnu.io.rxtx.SerialPorts java argument so that the serial port is activated automatically.

JAVA_ARGS_DEFAULT="-Dosgi.clean=true \
 -Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB0 \
 -Declipse.ignoreApp=true \
 -Duser.timezone=America/Los_Angeles \
 -Dosgi.noShutdown=true \

… (remainder omitted)

YMMV depending on which version & form of OpenHAB you’re using.