Setting up items/rules with arduino serial gateway

Hallo all,

I am new to openhab and I am having some issues with setting up the rules and items. I do have my arduino’s installed with the right sketches. The serial gateway is working but I am having trouble with adding them to my openhab rules. It would be amazing if someone could explain it to me!

Thanks in advance!


We are going to need a ton more information to even begin to help.

What technology/protocol does the gateway use? For example, does it talk HTTP with a REST API, does it pub/sub MQTT messages, do you talk to it directly via a socket, does it use Souliss, etc?

That will help figure out how to set up your Items.

What information do these arduinos produce or expect? What do you want to do with this information? What additional information do you need to achieve what you want (e.g. do you need to know about time, sunset , sunrise, weather conditions, temperature, etc.)?

At this point I have a DHT22 sensor sending temperature and humidity over the serial gateway and I have connected a 4relay board which sends its state and listens to new commands.

My setup is simple for now:
A Raspberry pi 2B running openhab, an Arduino Nano connected to the raspberry by usb with the mysensors serialgateway sketch on it and an Arduino Nano with a DHT22 sensor and a 4relay board.
I use the NRF24L01+ radios to link the Arduino’s.

Ah, another mysensors migrant. You probably want to look at the Serial binding then.

Spend some time on the wiki. It tells you how openHAB works and how everything links together (i.e. how Items interact with Rules interact with Persistence, etc.). It also has tons of examples and documentation for all of the bindings.

Good luck! There have been many non-technical people or people whose understanding of these technologies extend only so far as copying and pasting examples from the web (usually mysensors) who quickly discover you must have a good understanding of the technologies involved along with some coding, systems administration, and the ability to debug and research to be successful in home automation. Several have pushed through and learned the systems successfully, several gave up. I just want to make you realize up front that only copying and pasting examples from the web is not going to get you very far. You are in for a lot of frustration, trial and error, and experimentation.

I do not say this to scare you away. But just realize that these custom arduino based sensors and such are particularly difficult to help you with. They operate at a really low level and without having physical access to the devices it is exceptionally difficult if not impossible to debug problems on the forum. So you are a bit on your own when it comes to that.

Personally, I would recommend interacting with the gateway externally from openHAB through a Python script (or your language of choice). This eliminates a bunch of the quirks of openHAB that might trip you up, and it lets you move the communication to a higher level protocol that is far easier for openHAB to deal with.

A popular approach is to publish and subscribe for updates on an MQTT broker that openHAB subscribes to using the MQTT binding. If you plan on expanding your setup in the future this will give you the most flexibility and ease your growing pains. You can use the paho library to interact with MQTT in your script or program in most languages.

In fact, if you put a WiFi or Ethernet shield on your gateway arduino you can load an MQTT sketch on it and have the arduino talk to MQTT directly.