Go Down

Topic: Need some help with openhab + mosquitto + rpi2 and arduino nano (Read 286 times) previous topic - next topic

highrollerNO

Hello, i have some issues with my setup.

I run OpenHAB and mosqitto on Raspberry PI 2 with OSMC (debian).

I try to controll a 4 channel relay that is connected to Aarduino Nano.

I use nrf24l01 tranceivers on the RPI2 and Nano.

I have got the 2 units to talk to eachother with a ping-pong tutorial.
I have also made the relay switch on every channel so the problem is not with the hardware (not from MQTT command but with a "local" sketch uploaded to the Nano).

In openHab i have made a binding so that it sends MQTT commands to the Mosquitto broker and i can see that the commands is getting to the broker.

But now im stuck, does anyone have a link or tips on how to set up the sketch on the Nano to receive and execute commands from the broker?
Do i need anything else on the RPi or is the broker (and openHAB) everything?

rw950431

The most recommended MQTT arduino client appears to be http://pubsubclient.knolleary.net/ but this doesnt support TCP/IP over nrf24 radio. There is some information on running TCP/IP over nrf24 radio at https://forum.arduino.cc/index.php?topic=294434.0 but I've no experience with the code.

It will likely be easier to control your arduino via serial commands rather than trying to implement mqtt directly on the arduino.   An obvious way would be to run a separate mqtt client on your RPi that subscribes to the relevant channel(s) and transmits serial commands via the nrf24 radio link.

 



emzeperx

Hi,

I am working on a wifi control for a heater. I have mosquito and openhab running on a rpi2 (jessey). Cabled clients work with it without any issues.

For the wifi enabled controller I use an Arduino nano, an esp8266 and a relay module. esp and the relay module have their own power supply. Esp is connected to the Arduino using software serial (to have usb serial). For the mqtt connection I use mqtt, not pubsubclient. I have tested both and mqtt seems to be more stable, pubsub client tends to miss messages.

The whole thing works fine while I just read mqtt messages with this wifi enabled controller. As soon as I want to publish anything (room temperature and power consumption), the connection to the mosquito server is lost. The wifi connection is ok, ping shows no packet drops. The mosquito log tells: timeout exceeded, disconnecting. What timeout?

Mosquitto is the latest version (1.4.9), just like the mqtt client (0.16.1, according to Arduino IDE). I get the very same result with pubsubclient, too.

What do you recommend to check/test/change?

Thanks in advance,
Zoltan

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy