Problems connecting Arduino MEGA + Ethernet Shield + MQTT + Raspberry Pi 3 B+

  • Platform information:
    • Hardware: Raspberry Pi 3 B/ 1GB RAM / 16 GB SD
    • OS: Raspbian (last version)
    • Java Runtime Environment: (last version)
    • openHAB version: (last version)

Good morning,

Could someone tell which are the steps to config MQTT with openhab to connect with an Arduino MEGA.

I have the Arduino code ok connecting to the 1883 broker to the server of the Raspberry.
Then, on the Raspberry I’ve installed MQTT, Samba to see the files on my Windows, the SSH and VNC connection, and then I have created the mqtt config file on the openhab2 config folder. But probably I have to install something more and I’ll not have to create that files, because probably I am missing some steps.

Probably there’s a guide?

Thank you very much,

Best,

Josep

If I understood you correctly, you got your mosquitto MQTT server working on your raspberry pi and you want to know how to interact with it from openhab?

First, you should install the MQTT Binding. Go to you PaperUI -> AddOns -> Bindings.
Then read the Documentation and maybe search the Forum. There should be plenty examples how you can connect Items to the binding and how the communication between OpenHAB and the MQTT server works.

As a first impression, it should look something like this.

mqtt.things file:

Bridge mqtt:broker:mosquitto "Mosquitto" [ host="localhost", port=1883, secure=false, username="", password="", clientID="openHAB" ]
{    
    
// Sonoffs
    Thing mqtt:topic:sonoff1 "Sonoff1"{
    Channels:
        Type switch : power  "Power" [ stateTopic="stat/sonoff1/POWER", commandTopic="cmnd/sonoff1/POWER" ]
    }
}

Items file:

Switch Sonoff_1     "Sonoff 1[]"     { channel="mqtt:topic:sonoff1:power" }

Thank you very much,

Will try and tell you,

Best regards,

Josep Mencion