Page 1 of 2

Anyone got the SIMCOM7600 working with MQTT?

Posted: Sun Aug 02, 2020 3:53 pm
by daveywatt
So I've decided to hook up my Freematics one + to AWS IoT via MQTT.

According to the 7600 manual, it supports MQTT via AT commands.

https://simcom.ee/documents/SIM7600E/SI ... _V1.01.pdf

I've been trying to get this working for the past couple of weeks, but I keep getting a error 0,14 "client is busy" response from the modem whenever I attempt to subscribe or publish to a topic.

Has anyone got this working or perhaps has some experience with this that could help?

So far SIMCOM support has not responded and unfortunately I can't find anything online.

Here is the modem output:

Code: Select all



=== SENT@4254 ===
AT
==================
=== RECV@4257 ===

OK
==================
=== SENT@4257 ===
ATE0
==================
=== RECV@4260 ===

OK
==================
=== SENT@4260 ===
ATI
==================
=== RECV@4273 ===

Manufacturer: SIMCOM INCORPORATED
Model: SIMCOM_SIM7600E
Revision: SIM7600M21-A_V1.1
IMEI: XXXXXXXXXXXXXXXXXXXXX
+GCAP: ==================
=== RECV@4277 ===
+CGSM

OK
==================
 OK
Registering on network...
=== SENT@4284 ===
AT+CPSI?
==================
=== RECV@4295 ===

+CPSI: LTE,Online,505-01,0x309D,136092930,257,EUTRAN-BAND3,1275,4,4,-178,-1185,-789,7

OK
==================
=== SENT@4300 ===
AT+CREG?
==================
=== RECV@4304 ===

+CREG: 0,1

OK
==================
=== SENT@4309 ===
AT+CGREG?
==================
=== RECV@4314 ===

+CGREG: 0,1

OK
==================
=== SENT@4319 ===
AT+CGDCONT=1,"IP","connect.apn"
==================
=== RECV@4341 ===

OK
==================
=== SENT@4341 ===
AT+CGACT=1,1
==================
=== RECV@4345 ===

OK
==================
OK
Init MQTT...
Connecting...
=== SENT@74524 ===
AT+CMQTTSTART
==================
=== RECV@74533 ===

+CMQTTSTART: 0

OK
==================
=== SENT@75533 ===
AT+CMQTTACCQ=0,"SIMCom_client01",1
==================
=== RECV@75539 ===

OK
==================
=== SENT@77539 ===
AT+CMQTTWILLTOPIC=0,10
==================
=== RECV@77543 ===

>==================
=== SENT@78543 ===
esp32/will
==================
=== RECV@78546 ===

OK
==================
=== SENT@79546 ===
AT+CMQTTWILLMSG=0,4,1
==================
=== RECV@79550 ===

>==================
=== SENT@80550 ===
test
==================
=== RECV@80554 ===

OK
==================
OK, CONNECTION SETUP READY!
CMQTTCONNECT Connecting...
=== SENT@81554 ===
AT+CMQTTCONNECT=0,"tcp://test.mosquitto.org:1883",60,1
==================
=== RECV@81569 ===

OK
==================
CMQTTCONNECT SUCCESS
CONNECTED!
=== SENT@82569 ===
AT+CMQTTSUBTOPIC=0,10,1
==================
=== RECV@82576 ===

+CMQTTSUBTOPIC: 0,14

ERROR
==================
FAILED TO SUBSCRIBE!



Re: Anyone got the SIMCOM7600 working with MQTT?

Posted: Tue Aug 04, 2020 4:54 am
by cmendes0101
I finally got AT commands to work with AWS IoT a few months back directly to the SIM7600 module. It was a bit of a struggle due to not having a clear example but the pub/sub do works. I have notes and steps for the manual, give me a few hours and I'll post that up in here. I was not testing with the One+ but a standalone SIM7600A dev board.

I started to build a MQTT method into the teleloggerv5 but haven't really had a chance to integrate it all the way so like halfway on that. I do want to finish it since I'm hoping it'll reduce the payloads compared to HTTPS and allow for some events triggers alternative to inbound SMS triggers but not sure when I'll get some time to get back on that. Hopefully you can beat me to it :D

Re: Anyone got the SIMCOM7600 working with MQTT?

Posted: Tue Aug 04, 2020 8:10 am
by daveywatt
Mate that would be fantastic. Hopefully the 7600A is similar enough for me to spot the issue in my command set/code.

I have built the MQTT code class by extending the existing Freematics network base class. So once it's working it should work fine with the telelogger v5 code.

More than happy to share it or submit a pull request to the Freematics codebase... But unfortunately I've been stuck on this issue for weeks.

Re: Anyone got the SIMCOM7600 working with MQTT?

Posted: Tue Aug 04, 2020 1:45 pm
by cmendes0101
I saw in your log that you tried mosquitto. I forgot my exact mosquitto test but I believe using them MQTT wouldn't work but MQTTS does, there is another forum/blog that showed testing of SIM7600+MQTT(S) with mosquitto but I can't find the link. Using AWS IoT it's only MQTTS and I haven't found anyone else showing examples yet.

These are directly from my notes so not exactly step by step on AWS console so hopefully it works for you. SIM7600A should be the exact same as SIM7600E if you have that version in the One+.

AWS Provisioning
https://us-west-2.console.aws.amazon.co ... ovisioning
You will generate SSL certs for the devices in a zip file and get the MQTTS endpoint.

Check for required information
You should have these items to start the SIM7600 configuration
AWS IOT SSL ZIP FILE - mqtt-aws-iot-ssl
  • A*********-certificate.pem.crt - will be clientcert.pem
  • A*********-private.pem.key - will be clientkey.pem
  • A*********-public.pem.key (not used)
  • AmazonRootCA1.pem - will be cacert.pem
MQTT Topic - “aws/things/SOMETOPIC/”
MQTTS Endpoint - “a15************-ats.iot.us-west-2.amazonaws.com:8883”

Upload SSL Certs to SIM7600
The second parameter for CCERTDOWN is the byte size of the file. Make sure to get the byte size and replace below. Ex. AT+CCERTDOWN="CERTFILE",BYTESIZE

Code: Select all

AT
OK
AT+CCERTDOWN="clientcert.pem",1220
>(Insert a********-certificate.pem.crt. If Tera Term drag and drop on terminal)
OK
AT+CCERTDOWN="clientkey.pem",1679
>(Insert a********-private.pem.key. If Tera Term drag and drop on terminal)
OK
AT+CCERTDOWN="cacert.pem",1188
>(Insert a********-private.pem.key. If Tera Term drag and drop on terminal)
OK
Verify uploaded SSL files

Code: Select all

AT+CCERTLIST
+CCERTLIST: "cacert.pem"
+CCERTLIST: "clientcert.pem"
+CCERTLIST: "clientkey.pem"
OK
Configure SSL and connect to network

Code: Select all

AT+CSSLCFG="sslversion",0,4
OK
AT+CSSLCFG="authmode",0,2
OK
AT+CSSLCFG="cacert",0,"cacert.pem"
OK
AT+CSSLCFG="clientcert",0,"clientcert.pem"
OK
AT+CSSLCFG="clientkey",0,"clientkey.pem"
OK
AT+NETOPEN
OK
+NETOPEN: 0 ######## If != 0 then something is wrong. Check antenna connected and SIM inserted correctly
AT+IPADDR
+IPADDR: 10.184.191.67
OK
AT+CMQTTSTART
+CMQTTSTART: 0
OK
AT+CMQTTACCQ=0,"SIMCom_client01",1
OK
AT+CMQTTSSLCFG=0,0
OK
AT+CMQTTCONNECT=0,"tcp://a1***********-ats.iot.us-west-2.amazonaws.com:8883",60,1
OK
AT+CMQTTCONNECT: 0,0
OK
+CMQTTCONNECT: 0,0
Subscribe to Topic (Receive)
Second param to CMQTTSUBTOPIC is size of topic string

Code: Select all

AT+CMQTTSUBTOPIC=0,21,1
>aws/things/SOMETOPIC/
OK+CMQ
Receiving payload from subscribed topic

This message was sent from AWS IoT console connected to the above topic. Testing section that handled pub/sub?!

Code: Select all

+CMQTTRXSTART: 0,31,45
+CMQTTRXTOPIC: 0,21
aws/things/SOMETOPIC/
+CMQTTRXPAYLOAD: 0,45
{
   "message": "Hello from AWS IoT console"
                                          }
+CMQTTRXEND: 0

Publish Message (Send)

Code: Select all

AT+CMQTTTOPIC=0,21
>aws/things/SOMETOPIC/
OK
AT+CMQTTPAYLOAD=0,38
>{"message":"Hello from SIMCom Module"}
OK
AT+CMQTTPUB=0,1,60
OK
+CMQTTPUB: 0,0
Unsubscribe from Topic

Code: Select all

AT+CMQTTUNSUB=0,21,1
>aws/things/SOMETOPIC/
OK
+CMQTTUNSUB: 0,6
+CMQTTCONNLOST: 0,1
Disconnect from everything else

Code: Select all

AT+CMQTTDISC=0,120
OK
+CMQTTDISC: 0,0
AT+CMQTTREL=0
OK
AT+CMQTTSTOP
OK
+CMQTTSTOP: 0

AT+NETCLOSE
OK
+NETCLOSE: 0
I have these sources for my commands as reference:
https://simcom.ee/documents/SIM7X00/SIM ... _V1.00.pdf
https://www.waveshare.com/w/upload/5/54 ... _V1.08.pdf
https://simcom.ee/documents/SIM7500E/SI ... _V1.01.pdf

Let me know how that works or if you get stuck on any part of that!

Re: Anyone got the SIMCOM7600 working with MQTT?

Posted: Wed Aug 05, 2020 2:16 pm
by daveywatt
Thanks heaps for that mate.

I've actually built my code specifically for AWS (via SSL).. I removed all of the SSL setup and switched to mosquitto in order to achieve the base minimum required to achieve a connection.

This was in an effort to debug.

One thing that stands out is that you call NETOPEN after all of the SLL setup. In my case, I was calling this directly after a GPRS connection is established.

I will give this a try tonight and will post my results.

Re: Anyone got the SIMCOM7600 working with MQTT?

Posted: Thu Aug 06, 2020 11:50 am
by daveywatt
Ok, I have seemed to make some progress here thanks to your breakdown!

However, I am still receiving an error when attempting any MQTT commands (publish or subscribe).
The new error is 0,11 which according to the manual is "no connection".

The only difference in your AT command set is I have set the PDP context, which according to the manual "SIM7500_SIM7600_SIM7800 Series_MQTT_AT Command Manual_V1.00.pdf" is required to then later be activated by the AT+CMQTTSTART command.

Any idea on what could be going wrong here? I suspect is something to do with the network or MQTT connection (however the commands are all returning and OK response). I am also getting an IP addresss... so the GPRS network should be good to go at this point.

Here is my debug output:

Code: Select all

Bee Rx:35 Tx:2
Init cellular module...xBee power pin set to low
xBee power pin set to high
=== SENT@4254 ===
AT
==================
=== RECV@4254 ===

SMS DONE

PB DONE
==================
=== RECV@4256 ===
AT
OK
==================
 OK
Registering on network...

Loading certificate: 
clientcert.pem
AT+CCERTDOWN="clientcert.pem",1222
=== SENT@4266 ===
AT+CCERTDOWN="clientcert.pem",1222
==================
=== RECV@4273 ===
==================ntcert.pem",1222
=== RECV@4279 ===

>==================
CERT ACCEPTED!
=== SENT@4386 ===

-----BEGIN CERTIFICATE-----
[REMOVED...]
-----END CERTIFICATE-----

==================
=== RECV@4488 ===

-----BEGIN CERTIFICATE-----
[REMOVED...]
-----END CERTIFICATE-----

OK
==================
CERT LOADED!
Loading certificate: 
clientkey.pem
AT+CCERTDOWN="clientkey.pem",1677
=== SENT@4567 ===
AT+CCERTDOWN="clientkey.pem",1677
==================
=== RECV@4574 ===
AT+CCERTDOWN="clientkey.pem",1677
>==================
CERT ACCEPTED!
=== SENT@4724 ===

-----BEGIN RSA PRIVATE KEY-----
[REMOVED...]
-----END RSA PRIVATE KEY-----

==================
=== RECV@4866 ===

-----BEGIN RSA PRIVATE KEY-----
[REMOVED...]
-----END RSA PRIVATE KEY-----

OK
==================
CERT LOADED!
Loading certificate: 
cacert.pem
AT+CCERTDOWN="cacert.pem",1190
=== SENT@4936 ===
AT+CCERTDOWN="cacert.pem",1190
==================
=== RECV@4943 ===
AT+CCERTDOWN="cacert.pem",1190
>==================
CERT ACCEPTED!
=== SENT@5052 ===

-----BEGIN CERTIFICATE-----
[REMOVED...]
-----END CERTIFICATE-----

==================
=== RECV@5152 ===

-----BEGIN CERTIFICATE-----
[REMOVED...]
-----END CERTIFICATE----
==================
=== RECV@5212 ===
-

OK
==================
CERT LOADED!
All Certs Loaded! ...
=== SENT@5220 ===
AT+CCERTLIST
==================
=== RECV@5231 ===
AT+CCERTLIST
+CCERTLIST: "cacert.pem"
+CCERTLIST: "clientcert.pem"
+CCERTLIST: "clientkey.pem"

OK
==================
Certs verified!
Configure SSL
=== SENT@10238 ===
AT+CSSLCFG="sslversion",0,4
==================
=== RECV@10245 ===
AT+CSSLCFG="sslversion",0,4
OK
==================
=== SENT@10245 ===
AT+CSSLCFG="authmode",0,2
==================
=== RECV@10251 ===
AT+CSSLCFG="authmode",0,2
OK
==================
=== SENT@10253 ===
AT+CSSLCFG="ignorelocaltime",0,1
==================
=== RECV@10260 ===
AT+CSSLCFG="ignorelocaltime",0,1
OK
==================
=== SENT@10267 ===
AT+CSSLCFG="negotiatetime",0,120
==================
=== RECV@10274 ===
AT+CSSLCFG="negotiatetime",0,120
OK
==================
SSL CONFIGURED!
=== SENT@10281 ===
AT+CSSLCFG="cacert",0,"cacert.pem"
==================
=== RECV@10289 ===
AT+CSSLCFG="cacert",0,"cacert.pem"
OK
==================
=== SENT@10295 ===
AT+CSSLCFG="clientcert",0,"clientcert.pem"
==================
=== RECV@10304 ===
AT+CSSLCFG="clientcert",0,"clientcert.pem"
OK
==================
=== SENT@10310 ===
AT+CSSLCFG="clientkey",0,"clientkey.pem"
==================
=== RECV@10319 ===
AT+CSSLCFG="clientkey",0,"clientkey.pem"
OK
==================
SSL READY!
Init MQTT stack...=== SENT@10328 ===
AT+CGDCONT=1,"IP","telstra.iph"
==================
=== RECV@10334 ===
=================="telstra.iph"
=== RECV@10349 ===

OK
==================
=== SENT@11349 ===
AT+NETOPEN
==================
=== RECV@11352 ===
==================
=== RECV@11360 ===

OK

+NETOPEN: 0
==================
=== SENT@12360 ===
AT+IPADDR
==================
=== RECV@12366 ===
AT+IPADDR
+IPADDR: 10.224.87.65

OK
==================
=== SENT@13367 ===
AT+CMQTTSTART
==================
=== RECV@13371 ===
==================
=== RECV@13380 ===

+CMQTTSTART: 0

OK
==================
=== SENT@14380 ===
AT+CMQTTACCQ=0,"SIMCom_client01",1
==================
=== RECV@14388 ===
AT+CMQTTACCQ=0,"SIMCom_client01",1
OK
==================
=== SENT@15388 ===
AT+CMQTTSSLCFG=0,0
==================
=== RECV@15393 ===
AT+CMQTTSSLCFG=0,0
OK
==================
OK, CONNECTION SETUP READY!
CMQTTCONNECT Connecting...
=== SENT@17394 ===
AT+CMQTTCONNECT=0,"tcp://xxxxxx.iot.ap-southeast-2.amazonaws.com:8883",60,1
==================
=== RECV@17412 ===
AT+CMQTTCONNECT=0,"tcp://xxxxxx.iot.ap-southeast-2.amazonaws.com:8883",60,1
OK
==================
CMQTTCONNECT SUCCESS
=== SENT@17415 ===
AT+CMQTTCONNECT?
==================
=== RECV@17423 ===
AT+CMQTTCONNECT?
+CMQTTCONNECT: 0
+CMQTTCONNECT: 1

OK
==================
CONNECTED
NET STATE: 
1
=== SENT@17431 ===
AT+CMQTTTOPIC=0,10
==================
=== RECV@17438 ===
AT+CMQTTTOPIC=0,10
+CMQTTTOPIC: 0,11

ERROR
==================
CMQTTTOPIC failure
FAILED TO SEND MESSAGE!

Re: Anyone got the SIMCOM7600 working with MQTT?

Posted: Thu Aug 06, 2020 12:18 pm
by cmendes0101
Hmm yah that is interesting. It appears to be the same steps. There is the "+CMQTTCONNECT: 1" returning before the TOPIC command. Not sure if it disconnected at that point for some reason right before.

Re: "AT+CGDCONT". I've been leaving APN configuration out on my SIM7600 and One+ setups since it seems to auto-detect and work correctly on the carriers in the US that I have tested like Tmobile, Google Fi, and Hologram. It's probably not relevant but just noting why it's missing in case it's somehow relevant :?:

I'll try and do another rerun of my setup. Would you be willing to share some of the code you have that you are testing with? Might help in finding what might be off. If your doing this on github my username is the same on here.

Re: Anyone got the SIMCOM7600 working with MQTT?

Posted: Thu Aug 06, 2020 1:29 pm
by daveywatt
Thanks for the help mate.

You will notice I am sending AT+CMQTTCONNECT? to query the connection state. It seems to return OK and according to the manual this is the expected output of a successful connection.

I haven't commit my code to any repo yet, but I will get it up later today and share the code with you.

I have created a new class that extends the freematics client code. So as long as you reference the correct location of the library in your includes it should work just fine.

Re: Anyone got the SIMCOM7600 working with MQTT?

Posted: Thu Aug 06, 2020 7:51 pm
by cmendes0101
I just remembered an issue I had. This might be solely the SIM7600A and may not be related to the SIM7600E though. I don't know how to confirm since I don't know how to upgrade the SIM7600 firmware in the One+.

Background:
I ordered a few SIM7600A dev boards, while testing MQTT I kept getting "ERROR" response back on AT+CSSLCFG="sslversion",0,4. Digging into this I found the firmware installed was "LE11B02SIM7500A" by running AT+CGMR. I ended up finding "LE11B03SIM7600A-H" firmware and upgrading via the USB. After upgrading the rest of the AT commands started working and I was able to get everything running.

So for the Freematics One+ B...

I just went through some testing and it looks like my model B is running "LE11B02SIM7500A". For reference one of my devices main PCB is marked 2019-05-07 F3_v1.4.

Checked using:

Code: Select all

AT+CGMR
+CGMR: LE11B02SIM7500A
Performing the same "sslversion" step it errors the same.

Code: Select all

AT+CSSLCFG="sslversion",0,4
ERROR
Looks like I'll probably need to upgrade for MQTT to work. But again this might be an issue only on SIM7600A but I'd be curious what your version is on E.

Anyone know how I can upgrade firmware??

Re: Anyone got the SIMCOM7600 working with MQTT?

Posted: Fri Aug 07, 2020 9:40 am
by daveywatt
I think you may be right. I saw in another post someone had an issue with the "client is busy" issue, he reported that it was resolved with a firmware update.

The issue is, Freematics is running the module as a shield via UART. The SIMCom documents only provide instructions on how to firmware update via direct USB connection... however the module is supposed to support "FOTA" that allows firmware to be updated via HTTP or other IP but I can't find any AT commands related to this, and I have found no other info online.

We may be able to knock this on the head if we can work out how to do a firmware update.

Here is the details of my chip:

ATI
Manufacturer: SIMCOM INCORPORATED
Model: SIMCOM_SIM7600E
Revision: SIM7600M21-A_V1.1

AT+CGMR
+CGMR: LE11B02SIM7600M21-A