adafruit / Adafruit_MQTT_Library

Arduino library for MQTT support
MIT License
572 stars 291 forks source link

mqtt_ethernet.ino example code not working #84

Open marcoracer opened 7 years ago

marcoracer commented 7 years ago

When using the code available in the example, modifying the required fields, Arduino Uno with ethernet shield always return "Connection failed".

tapiralec commented 7 years ago

Hi marcoracer,

Which fields did you modify?

marcoracer commented 7 years ago

lines 35 and 36 for AIO_USERNAME and AIO_KEY respectively, of course. I did not change the feed name because I know that it will create one if it does not exists .

tapiralec commented 7 years ago

Can you double check that you put in your username and key correctly?

If it's in there correctly, try manually assigning an ip address and dns server by doing the following:

  1. uncomment lines 25 and 27
  2. (change the IP address in line 25 to a valid one for your subnet if necessary)
  3. change line 68 from "Ethernet.begin(mac);" to "Ethernet.begin(mac, iotIP, dnsIP);"

If you're still having trouble, double check your connection, and if the WebClient example (under Examples for any board -> Ethernet) doesn't successfully connect to google.com, then you've got an issue with maybe your network or hardware.

marcoracer commented 7 years ago

Yes, username and keys are correct and working on a NodeMCU. I'm sure that the dhcp is working because I can ping the Arduino+EtherShield. I'm sure that Arduino+EtherShield has a Internet connection because, in another debug version, I add DNS and HTML get method verifications! I also tried in two different hardwares (a second arduino and a second shield) to exclude the possibility of hardware problems! Right now I'm I'm confident that there is a problem with the library, maybe regarding Adafruit_MQTT_Client and EthernetClient.

njh commented 6 years ago

I am also having trouble getting Arduino Uno + Ethernet Shield working.

In the tutorial, it describes storing the server name, username, password etc as flash strings (PROGMEM): https://learn.adafruit.com/mqtt-adafruit-io-and-you/intro-to-adafruit-mqtt

However in commit 7886b724, it switches from strcpy_P to strcpy - so the server name is no-longer expected to be a flash string.

Elsewhere there are still references to pgm_read_byte.

ghost commented 5 years ago

I have this same problem, and it cannot be fixed by working back to an older version of the library, Anyone ever come up with a solution? I'm using a Feather 32u4 with the associated Ethernet add-on.