SOLVED: MQTT connection fails once I add the 12th client.subscribe statement

Hi All,

I have a setup with a pi running openhab and mosquitto. My Arduino communicates with openhab via MQTT. Everything was working fine with 11 client.subscribe() statements. Once I add the 12th client.subscribe(), I get a MQTT connection failure after an initial successful connection. When I comment out the 12th client.subscribe, everything works fine.

I'm using a JBtek Ethernet Shield W5100 with AtMega2560.

Am I reaching some buffer limitation? I've converted all my Serial.print statements to F() syntax to try to relieve some space in RAM. This did not help.

I'm grasping at straws and my project is at a standstill until I figure this out. Any help would be appreciated.

Thank you.

-T

UPDATE: mosquitto log says:

Client has exceeded timeout, disconnecting.
Socket error on client, disconnecting.

also, I tried commenting out other client.subscribe lines. Interestingly I still get the error. It's only that last line.

It's only that last line.

The last line in code you didn't post? Well, don't do that. Whatever it is you are doing.

Update: Problem is solved. I was barking up the wrong tree. For fun, I commented out the section that does the work when a MQTT messages arrives on that channel. Everything worked fine. However, nothing was being done if I changds a fan speed in the Openhab GUI. I left the analogWrite command commented out and everything still worked properly. When I un-commented the analogWrite line, I had the MQTT connections failures again.

Humm? For Fun I changed the pin to 11 from 10. Like magic, now everything works as expected. I have no idea why pin 11 would work and pin 10 causes the issue. I guess I really don't care as long as its working. I have nothing connected to those pins at them moment. So, that's not the problem either.

Humm? For Fun I changed the pin to 11 from 10. Like magic, now everything works as expected. I have no idea why pin 11 would work and pin 10 causes the issue.

Pin 10 needs to be an OUTPUT pin, in order to make the Arduino a master (so it can communicate with the Ethernet shield).

The Ethernet shield designates pin 10 as the slave select pin.

You can't use that pin for PWM and as a slave select pin, too. The slave would go crazy with all the state toggling on that pin.

Well, there you go! Thanks for the info.

-T