We are trying to implement MQTT in PIC18F4620 Hitech C compiler. using SIM 800 GSM module.
After initializing all the AT commands,for TCP connection,if i send the connection packet ,the connection is getting closed immediately after 2 secs.i have also changed the keepalive time as 3000,but still getting the same problem. i have attached the image please do have a check.
I have refereed the link below. and wrote the same coding for my requirement.Please give some suggestions.
My observation is when using CloudMQTT.com the protocol name field that is accepted is MQIsdp and for io.adafruit.com server its MQTT. So you need to look into the code to understand what exactly you are putting out on the TCP connection.
The reason for connection closure is malformed Connect packet which is not accepted by the broker.
So analyse each byte according to the video i had shown here
P.S.: I moved your question here. Please post in appropriate category in future.
Thanks for your response Ravi.
But my question is that,Is it possible to implement MQTT with PIC controller to make the Switch ON Or OFF by using GSM SIM800?
Please give me some idea.I am trying A lot for this. But not getting result.
Yes its definitely possible. You are doing it right already. Just correct the packet format and you should be good to go.
Look at my Arduino MQTT tutorial, the same code can be modified for PIC too. Its simple enough.
As i mentioned above. Go into your library and modify the string from MQTT to MQIsdp. It should work.
I tried same as you told to do. But getting same error,getting junk values in last command and TCP connection getting disconnect imediately.
And one more thing is that,I don’t have exact MQTT header files which we need for coding. in PIC. Please give me some suggestion.
There are no header files needed. You have already created a TCP connection succesfully, Just send out the packet. Initially you can try sending a hard coded packet like i send in the video by using excel sheet. Once everything goes well, you can send auto formed packets.
Those are not junk values, They are data in binary. Use TMFT or docklight or any terminal which makes it possible to see hex data.
As i can see in your above screenshot, you are sending MQTT in CIPSEND. change it to MQIsdp and you should get it working.
I wrote the same arduino code as you shown in video.But i am getting junk values.Please tell me the reason behind it.Please find the attachment which I have attached with this message.
Thanks again for your kind support.
Thats not junk. Thats MQTT packets in binary. Nothing wrong in that.
P.S: Dont flag the post, flagging means something wrong about that post, like SPAM
A post was merged into an existing topic: Arduino MQTT code for SIM800L module
I am facing the same problem.
Can you help me please ?