-->
Page 8 of 26

Re: Native MQTT client library for ESP8266

PostPosted: Wed Jan 07, 2015 12:27 pm
by alonewolfx2
ho can i send data to the broker? i didn't find wiki.
the code is not working
Code: Select allchar dataBuf[64];
   memcpy(dataBuf,"esptest",strlen("esptest"));
   int data_len=strlen(dataBuf);
   MQTT_Publish(&mqttClient, "/test/", dataBuf, data_len, 1, 1);

Re: Native MQTT client library for ESP8266

PostPosted: Wed Jan 07, 2015 3:43 pm
by rvbcrs
Ok cool, I get everything working now!
I have connected a DHT11 temperature sensor, can you please tell me how I can publish the temperature every now and then so a mqtt subscriber can receive it?

Thanks!

Re: Native MQTT client library for ESP8266

PostPosted: Thu Jan 08, 2015 1:29 am
by mharizanov
@tuanpm If I call MQTT_Publish twice one after another, only the second publish gets through; I think you don't queue them, notice that the

#define MAX_PUBLISH_QUEUE 5

is not used anywhere.

Cheers

Re: Native MQTT client library for ESP8266

PostPosted: Thu Jan 08, 2015 11:35 am
by jimbo
Thanks for the library tuanpm! I managed to compile and upload it successfully (I'm new to all this), and see in my serial monitor that it connects succesfully to my AP, the internet and the (cloud) MQTT broker. I didn't alter anything other than the necessary credentials.

However, I've got a few other subscribers/publishers that listened/posted to the sample 2 topics, but I don't see any messages on the serial monitor or on my other pub/sub applications. Is this standard behaviour?

Code: Select allMQTT: Connected to xxx.cloudmqtt.com:xxxx
MQTT: Connected
MQTT: subscribe, topic"/test/topic" at broker xxx.cloudmqtt.com:xxxx
MQTT: subscribe, topic"/test2/topic" at broker xxx.cloudmqtt.com:xxxx
TCP: Sent
TCP: data received
MQTT: Subscribe successful
[*snip*, and repeated every now and then:]
MQTT: Send keepalive packet to xxx.cloudmqtt.com:xxxx!
TCP: Sent
MQTT: Published
TCP: data received