Arduino + Ethernet + MQTT + OH

Hi everyone,

I turn to you because I’m struggling a little to manage my arduino cards from OpenHAB. Would anyone here know how to point me?

I have two arduino mega 2560 cards that I would like to manage since OH. One corresponds to all my inputs (54 inputs) and the other to all my outputs (54 outputs). I installed MQTT and each arduino card has an ethernet shield. It’s after that I’m confused. How to receive all my inputs / outputs on OH? Surely you have to upload a sketch on the arduino to ask all this but I am a little lost. I found this topic that help me to setup MQTT in the sketch but I don’t know what is useful in my case.

Can someone help me configure all of this correctly?

An infinite thanks!

Platform information:
Hardware: amd64 / 2Go Ram / Realtek soundcard
OS: Win7 Pro
Java Runtime Environment: Java JRE 8 + JDK 8
openHAB version: 2.2.0

For arduino, you will need the pubsubclient library, available to download from the arduino IDE
Follow this link for examples

For OH, you will need the MQTT binding

1 Like

Yes, I downloaded the arduino library and added the MQTT binding to OpenHAB but I’m lost in the configuration of my arduino sketch. How do I get the status of my entry pin 1 from OH? Or, how do I send a pin out state from OH? …
I had uploaded the sketch “basic” (content in the library) but it does not help me too much.
It’s probably very simple and I may be a little silly but impossible to understand how to send or receive a pin state.

The basic sketch is self explanatory. Read it line by line and understand it.

See the mqtt bindings docs for openHAB for item configurations to received and send mqtt messages

Have you installed an MQTT broker? That’s the first requirement

Then READ THE DOCS
Read the pubsubclient docs
Read the OH docs
Read them again
Write your code
Come back when your code doesn’t work

OK ! I will re-study this line by line and doc by doc. Thank you !