bportaluri / WiFiEsp

Arduino WiFi library for ESP8266 modules
GNU General Public License v3.0
548 stars 210 forks source link

HW serials (MEGA, DUE) fail to receive subscriptions from mqtt broker using PubSubClient lib #195

Open plop510 opened 4 years ago

plop510 commented 4 years ago

I try to use the library with an Arduino DUE (with the changes to avoid the conflict with Ringbuffer class) and I found that hw serials don´t work for subscription receiving using PubSubClient library. I found that also in MEGA, if you use HW serials the same issue happens. I make it work like a charm with any board that admit SoftwareSerial lib (Leonardo, Mega, etc) but DUE has a different architecture than avr and doesn´t admit that library. By the way, I was testing with hw serials on MEGA and the behaviour is the same as in DUE but in that case, the workaround is using SoftSerial in MEGA. To detail a bit more the problem:

JAndrassy commented 4 years ago

use 9600 baud. the library is optimized for it. or use my WiFiEspAT library with 500000 baud if you want

plop510 commented 4 years ago

Thanks for your fast answer. I´ve tested with 9600 baud, over a MEGA Serial1 (hardware port) and the result is the same: can publish OK but NOT receive any suscription packet at all. I swap to softserial pins, recompile and ALL suscription packets are received back by the callback function. It seems that most of people use softserial but for DUE is not possible. Regards.