0

I am using ESP8266 and Arduino with SoftwareSerial. My requirement is to use MQTT protocol with it. So I am using an MQTT library named pubSubClient but the problem is it doesn't support SoftwareSerial. Could anyone tell me how can I use MQTT protocol with it?

#include 
#include 
SoftwareSerial esp(2, 3); // RX, TX 
PubSubClient client(esp); 

The error I get is: no matching function for call to 'PubSubClient::PubSubClient(SoftwareSerial&)

  • Are you using pubsubclient.knolleary.net – sa_leinad Apr 27 '16 at 14:11
  • Could you please edit your question with the following information: * Why can't you use softwareSerial? What error do you get? * Why cant you use the main UART (serial) port? * What daughter board are you using for the ethernet? – sa_leinad Apr 27 '16 at 14:15
  • You are asking the wrong question. PubSubClient has nothing at all to do with serial in any form whatsoever. It interfaces with the standard Arduino Client class. What you should be looking for (and maybe asking about) is an ESP8266 library that supports SoftwareSerial and presents the standard Arduino Client interface. – Majenko Apr 27 '16 at 16:22
  • #include #include SoftwareSerial esp(2, 3);// RX, TX PubSubClient client(esp); Error is:no matching function for call to 'PubSubClient::PubSubClient(SoftwareSerial&)' – shadab May 2 '16 at 7:12
  • As @Majenko says, you need an Arduino PubSubClient that supports SoftwareSerial - you are trying to pass in a SoftwareSerial object which is not a PubSubClient. A brief google failed to find any SoftwareSerial clients but there is a ESP8266 PubSubClient here : github.com/knolleary/pubsubclient – KennetRunner Jul 27 '16 at 16:57
1

In order to use the ESP8266 WiFi module with pubSubCient, you need a library that interfaces with the module with the usual AT commands, while presenting an Arduino Client interface on the surface. A while back, I found this library after a great deal of searching. It supports SoftwareSerial as well as HardwareSerial objects. Its ESP8266 interface provides the standard Client methods of write(), read(), connected(), etc. There are some issues, of course, but its the best I've found so far. You can pass the created Client object to the pubSubClient constructor and you're good to go.

0

Not sure what you're trying to do - but thought I would offer this since I just spend some time on getting my esp8266 to act as a wifi shield for my arduino. Basically I wanted to subscribe to an mqtt channel and send the payload to my arduino. So the esp8266 connected to a broker, upon reading a message, it would simply write it via serial to the arduino (I used software serial on the arduino side so I could use the standard serial for debugging). If it helps, check out http://mganis.blogspot.com for the details

--Matt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.