Usually, USB sticks attached to Raspberry Pi will get assigned ports in an increasing manner such as /dev/ttyACM0, /dev/ttyACM1, etc. This may become a problem whenever you reattach your USB devices to a different port, you add new devices, or you simply reboot your RPi. The reason is that one specified device may be recognized earlier than another while booting the RPi. You could make these ports permanent via so called symlinks and give them more telling names in contrast to ttyACM0.
- SSH into your RPi
- Take a look at the current recognized USB devices (and make a screenshot):
lsusb
- Now, unplug all your USD devices and issue the
lsusb
command again. Now you know how your disconnected devices have been named. - Plugin the the USB device one after another and find their IDs. Issue the
lsusb
command after each reattachment of a single USB device.
For example, an Aeotec Z-Stick 5G may look like this:
Bus 001 Device 005: ID 0658:0200 Sigma Designs, Inc.
A 433Mhz busware CUL may look like this:
Bus 001 Device 004: ID 03eb:204b Atmel Corp. LUFA USB to Serial Adapter Project
- Create a UDEV Rule:
sudo nano /etc/udev/rules.d/99-usb-serial.rules
SUBSYSTEM=="tty", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200",
SYMLINK+="ttyUSB-ZStick", GROUP="dialout", MODE="0666"
SUBSYSTEM=="tty", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="204b",
SYMLINK+="ttyUSB-CUL", GROUP="dialout", MODE="0666"
- Add openhab user to the right groups:
sudo adduser openhab dialout
sudo adduser openhab tty
- Reboot and test if symlink was created:
ls /dev/tty*
- Add symlink to PATH in Java:
sudo nano /etc/default/openhab2
Search the following line and modify accordingly:
EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB-ZStick:/dev/ttyUSB-CUL"
- Change the ports of your devices in your existing configuration files.
For example, for a Z-Wave stick change the properties in HABMIN accordingly.
For a 433Mhz CUL that is bound to openHAB via Homegear, change the port accordingly in /etc/homegear/families/intertechno.conf
- Reboot your Raspberry Pi