Arduino MQTT code for SIM800L module - Working :)


#1

Hi Ravi,

Thanks for the quick response earlier today.

I incorporated the code into my already existing error handling code.

the modem connects to the server but the connection is closed immediately as per this video

the code I am using can be found in a repository Here

Kindly let me know what could be wrong with the code since it worked with sim900 in Ravi’s Tutorial.
Regards


MQTT TCP connection getting closed using SIM800 with PIC18F4620
MQTT TCP connection getting closed using SIM800 with PIC18F4620
Problem while receiving packets from cloudmqtt.com to Arduino
#2

I am seeing no gap between CIPSEND commands. One command is sent before another is finished.
Add a delay and try. Also put some delay after TCP connection is opened and then send the connect packet.
To see if packets are formed properly, may be you can tap the UART lines and see in a hex editor.


#3

I figured out the problem. The repository is updated for anyone that may wish to try it out!
Happy coding


#4

Thanks Peter :slight_smile:
Working code link re written by Peter


#5

Hello Peter Sir… I have downloaded the re written code by you on the link mbari_peter / sim800 mqtt-ravi
But when i am compiling it then it shows error that Serial2 is not declared , initTCP not declared… please help


#6

Hello guys
i tried it too, and it gives me an error
“exit status 1 ‘initTCP’ was not declared in this scope”
your replay will be highly appreciated
regards


#7

Same problem with my setup.

“exit status 1 ‘initTCP’ was not declared in this scope”

Please help!


#8

Hi champ! So the file you’ve downloaded comes with two .ino files, “modemDrivers” & “mqtt_NEW”. The problem you’re having is that the functions (e.g. “initTCP”) is defined in the “modemDrivers.ino” sketch. So to solve this the easiest way would be to 1. open modemDrivers, 2. press ctrl+a to select everything in that sketch 3. ctrl+c to copy everything 4. open mqtt_NEW and paste the copied code into the mqtt_NEW sketch - NB don’t override the code already inside the mqtt_NEW sketch, so just paste it way at the bottom.


#9

Hi Matko, see reply to champ’s question.


#10

Hi, ok but now it gives me ‘Serial2’ was not declared in this scope error


#11

Hi
I am facing a problem.
When I send an AT command, the response is empty.
Like as
I send “AT+CIPSEND” the response is empty.
How can I solve this problem ?


#13

@Md_Iqbal_Hossain Create separate thread for your question.


#14