botletics / SIM7000-LTE-Shield

Botletics SIM7000 LTE CAT-M1/NB-IoT Shield for Arduino
https://www.botletics.com/products/sim7000-shield
GNU General Public License v3.0
477 stars 215 forks source link

Fona libary SIM7000 MQTT read commands #59

Closed bradleytompkins closed 4 years ago

bradleytompkins commented 5 years ago

I see the functionality for reading MQTT topics is missing from you updated FONA library. Is this something you plan to implement? The Adafruit IO library is quite memory intensive.

botletics commented 5 years ago

Maybe if I get the time later, no guarantees though :(

robotsflo commented 5 years ago

+1, Do you have some news ? I also see MQTT Cloud method in IOT_example -> connect and disconnect TCP connection in loop.

The advantage of MQTT is maintaning TCP connection to pub or receive message with less data consomption. If you close the TCP connection before waiting 10s, we loose benefits to mqtt. (the opening connect / disconnect MQTT TCP eat some data).

https://cloud.google.com/blog/products/iot-devices/http-vs-mqtt-a-tale-of-two-iot-protocols

I don't know how the adafruit mqtt IO library was built, but i think that the TCP connection is always "ON".

adam6806 commented 5 years ago

That's really interesting and explains a lot about why the data consumption I was seeing was higher than expected. I didn't realize that opening and closing the connection consumed data.

On Wed, Mar 6, 2019 at 4:24 PM robotsflo notifications@github.com wrote:

+1, Do you have some news ? I also see MQTT Cloud method in IOT_example -> connect and disconnect TCP connection in loop.

The advantage of MQTT is maintaning TCP connection to pub or receive message with less data consomption. If you close the TCP connection before waiting 10s, we loose benefits to mqtt. (the opening connect / disconnect MQTT TCP eat some data).

https://cloud.google.com/blog/products/iot-devices/http-vs-mqtt-a-tale-of-two-iot-protocols http://url

I don't know how the adafruit mqtt IO library was built, but i think that the TCP connection is always "ON".

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/botletics/SIM7000-LTE-Shield/issues/59#issuecomment-470282624, or mute the thread https://github.com/notifications/unsubscribe-auth/ACvwn15tnB57viBM63s6TCBgHPpM-VISks5vUDITgaJpZM4Zaez- .

botletics commented 5 years ago

There are dedicated MQTT commands for the SIM7000 now, but I simply don't have time to implement them due to long term personal commitments.

botletics commented 4 years ago

As a quick update, I've added the dedicated MQTT commands from the MQTT app note and also added a SIM7000_MQTT_Demo sketch but haven't tested it yet. The next logical step would be finding out how to read the data coming in after using the subscribe feature because the MQTT app note doesn't mention it.

Rick-GO commented 4 years ago

If you subscribe to a topic using the embedded MQTT AT commands, the SIM7000 will send the received data from this topic over UART (or USB) to the MCU (or PC).

For example: Subscribe to topic ‘testTopic’ with QoS 1

AT+SMSUB=”testTopic”,1

If this topic contains retained data on the broker or another device is publishing to this topic, it will be received by the SIM7000 and send to the MCU (or PC) as:

+SMSUB: “testTopic”,”data from this topic”

botletics commented 4 years ago

Thanks for the heads up! I figured it was that way but didn't remember to test it until I saw this. I just updated the SIM7000_MQTT_Demo sketch to include reading messages from subscribed topics and parsing them to do stuff (like turn an LED on/off)