You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm very very new at this topic to start with. I have for the past two days tried to get this thing working on my Arduino UNO/mega and two different w5100 shields.
One of the shield seems to not work at all since i don't get an IP from it, when i run the code
The other shield got an IP from the code above and it seems to work. I have been able to ping the IP and with an example found online able to get data from telnet to the ip and successfully connecting to the "webClient" in arduino basic library.
I have tried both of the basic examples located in the pubsubclient "auth(code example below) and basic". Where noone seems to work for me. The basic example are giving me the "-2 can't connect" error, and the auth are just failing.
The gateway dns and subnet are taken from my laptop with the cmd : /sbin/ifconfig. I'm not 100% that is the correct way to do it, maybe it could be my problem?
My computer are running a mosquitto 1.4.9 "server" on the correct port, I am able to connect to this server from my node js application and sub/publish data. I'm running out of options on what the problem could be, and would appreciate any help!
small edit: i saw that my gateway was wrong. It's now fixed, but still wont work.
Trying to see that my dns is correct aswell.
Edit 2: can't find it, but i found this at the arduino website: dns: the IP address of the DNS server (array of 4 bytes). optional: defaults to the device IP address with the last octet set to 1
which means that i should have <192.168.0.1> ? (if i could connect to the test mosquitto, does that mean that i got the correct dns, and gateway?)
Either way, did not make any difference.
Edit 3: picture of the setup, nothing special i guess.
Edit 4: tried a ton of different ways to code the IP of the server, including:
IPAddress server(192,168,0,15);
byte server[] = {192,168,0,15};
const char*[] = {192,168,0,15};
char server[] = "192.168.0.15";
char server[] ="mqtt:/192.168.0.15"; <-- this is the exact address that i use when connecting with my node app.
edit 5: tried to connect to 85,119,83,194 (test.mosquitto.com) which works.
can't connect to my public IP though.. the ports are correct , i think... And they are open in the router. Could the problem be that my computer which are running the mosquitto server are on the wifi while the arduino is on a wired connection?
edit 6: still not able to connect, dump of my (mosquitto cfg) below:
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
listener 1883
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
The text was updated successfully, but these errors were encountered:
I'm very very new at this topic to start with. I have for the past two days tried to get this thing working on my Arduino UNO/mega and two different w5100 shields.
One of the shield seems to not work at all since i don't get an IP from it, when i run the code
The other shield got an IP from the code above and it seems to work. I have been able to ping the IP and with an example found online able to get data from telnet to the ip and successfully connecting to the "webClient" in arduino basic library.
I have tried both of the basic examples located in the pubsubclient "auth(code example below) and basic". Where noone seems to work for me. The basic example are giving me the "-2 can't connect" error, and the auth are just failing.
The gateway dns and subnet are taken from my laptop with the cmd : /sbin/ifconfig. I'm not 100% that is the correct way to do it, maybe it could be my problem?
My computer are running a mosquitto 1.4.9 "server" on the correct port, I am able to connect to this server from my node js application and sub/publish data. I'm running out of options on what the problem could be, and would appreciate any help!
/Eddie
small edit: i saw that my gateway was wrong. It's now fixed, but still wont work.
Trying to see that my dns is correct aswell.
Edit 2: can't find it, but i found this at the arduino website: dns: the IP address of the DNS server (array of 4 bytes). optional: defaults to the device IP address with the last octet set to 1
which means that i should have <192.168.0.1> ? (if i could connect to the test mosquitto, does that mean that i got the correct dns, and gateway?)
Either way, did not make any difference.
Edit 3: picture of the setup, nothing special i guess.

Edit 4: tried a ton of different ways to code the IP of the server, including:
IPAddress server(192,168,0,15);
byte server[] = {192,168,0,15};
const char*[] = {192,168,0,15};
char server[] = "192.168.0.15";
char server[] ="mqtt:/192.168.0.15"; <-- this is the exact address that i use when connecting with my node app.
edit 5: tried to connect to 85,119,83,194 (test.mosquitto.com) which works.
can't connect to my public IP though.. the ports are correct , i think... And they are open in the router. Could the problem be that my computer which are running the mosquitto server are on the wifi while the arduino is on a wired connection?
edit 6: still not able to connect, dump of my (mosquitto cfg) below:
The text was updated successfully, but these errors were encountered: