connection Error MQTT. What is it I'm missing?

Hello People…

I’m running a program connecting an Arduino UNO with a Fona808 GPS/GPRS chip to create a tracking device.
I struggled somewhat but things are starting to work as expected.

At least up to the part where the Fona needs to make a connection with the MQTT server to parse data into my account. (ready for the next chapter to continue my project with.)

This is my first MQTT related program and I try to figure out what it is that prevents things from connecting.

If I’m correct, a connection is set up properly, but it is some kind of restriction.

Connected to Cellular!
	---> AT+CIPSHUT
	<--- SHUT OK
	---> AT+CIPMUX=0
	<--- OK
	---> AT+CIPRXGET=1
	<--- OK
AT+CIPSTART="TCP","","1883"
	<--- +CME ERROR: operation not allowed
Connection failed
MQTT connection failed, resetting...

Is it the SIM card which might have restrictions? It is my son’s card and he uses it for whatsapp, so I guess a blocked internet connection is not the problem(?)

Little update...
I contacted the internet provider and the SIM card is valid.

Could it be a setting which I've got wrong?
For instance, I do not see an IP adress or something.
But that might be common I guess...

AT+CIPSTART="TCP","","1883"

This looks like you forgot to specify the server to connect to. Post your code if you need help!

Tx Pylon.
I did not want to bother you with a whole heap of code, where such a small fragment would be relevant.

I got the code from the Adafruit website about Geofencing.
I only adjusted the servername and I added my IO credentials for that specific page.
In the code below I left out that credentials as you can understand.

[edit] the code is to long.
I’ll add it as a .txt

Tx for all your effort, by the way… :slight_smile:

code GEO fencing met tracking.txt (11.6 KB)

const char MQTT_SERVER[] PROGMEM    = AIO_SERVER;
const char MQTT_USERNAME[] PROGMEM  = AIO_USERNAME;
const char MQTT_PASSWORD[] PROGMEM  = AIO_KEY;

// Setup the FONA MQTT class by passing in the FONA class and MQTT server and login details.
Adafruit_MQTT_FONA mqtt(&fona, MQTT_SERVER, AIO_SERVERPORT, MQTT_USERNAME, MQTT_PASSWORD);

Where did you read that you can store the MQTT parameters in flash? I cannot see any support for this in the library.

Tx for your reply, Pylon.

I'm not that into Arduino yet and still learning.
This code, I got from the Adafruit Webpage, was copy/pasted to my project with just changes in the login name and key's, etc.

To be honest, I was planning to turn stuff around. Getting a program code (which should be proven successful) from a website and analyzing it afterward for educational purposes.

I'm afraid I do not understand your comment completely.
Do I get it right to state that the code claims some memory space from the UNU which is not possible with that type of Arduino?

I hope you do not mind me mentioning your comments on that Adafruit website?

Thanks very much for helping me out on this!

FTMZ

I'm afraid I do not understand your comment completely.
Do I get it right to state that the code claims some memory space from the UNU which is not possible with that type of Arduino?

No, it's not related to the type of Arduino but to the library used. That library knows to handle only standard C-type strings (character arrays) but it doesn't know how to get that information from flash. By adding the keyword PROGMEM to your constant definition you're saying the compiler to store that information only in flash but not moving it into RAM at the start of the sketch. Try to simply remove that keyword and compile your sketch again.

This code, I got from the Adafruit Webpage, was copy/pasted to my project with just changes in the login name and key's, etc.

If you mention the website you should provide a link to that page.
The examples of the library include more or less the same code but don't use the PROGMEM keyword at all.

I think I'm starting to understand.

The links, By the way, were:

The Adafruit article about Geofencing and linking it to the Adafruit.IO server:
Adafruit

In that article, several parts of the code are explained and eventually there is a link to github.com where I found the complete code:
Github link

I'll look into your solution and keep you informed!

[Update]
The connection is working!
Thanks for the advice pylon!

Of course, I ran into other issues, but not concerning the connection so far! :slight_smile: