Quantcast
Channel: ThingSpeak IoT Community - All Forums
Viewing all articles
Browse latest Browse all 1833

RobO on MQTT connection to ThingSpeak from local Mosquitto broker - Not authorized

$
0
0

JasonW,

You may be correct. I probably didnt explain my setup well enough. I use an Adafruit Huzzah ESP8266 to send the mqtt messages to home assistant.   Which sends fine.   Then when I call the ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey); function within my program, it kills the mqtt connection to my home assistant broker.   I do not use the ThingSpeak component of home assistant.   I tried that first and could not get it to work.  So, I saw that there is an arduino library and went that route.  When I tried to add the ThingSpeak component, I kept getting errors and I couldnt figure it out. 

I figured this out because I get notifications when it drops the connection to the mqtt broker at the home assistant address.  It should not fall off for at least 5 minutes because that is the keep alive time.  If I comment out that line ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);...  the program works fine and does not drop the mqtt connection.    If I leave it in there and compile it and upload the program, it works fine, it just drops the mqtt connection to home assistant and reconnects at the top of the program again.  So, based on my trial and error, when I call the ThingSpeak.writeFields function, it apparently forces the lastwill message to be sent to home assistant broker.   I immediately get an "OFFLINE" message, which is what I have it set to do.   Then right away I get an "ONLINE" reconnect message.  It wont do it if I comment out that ThingSpeak.writeFields function or remove it.

When I read that it was a mqtt connection to thingspeak, I figured this was some sort of conflict between the mqtt client setup to send messages to home assistant and the mqtt client setup to send messages to thingspeak.   I dont know enough about it other than there is something going on when I try doing them both.

I kind of figured there was a way to declare two different mqtt setups on the same micro and it work.   I may try to set one up and do some tests.

 

Thanks for Replying......


Viewing all articles
Browse latest Browse all 1833

Trending Articles