0

I'm using Raspberry Pi 3 B+ with a SIM7600X 4G HAT for SMS and mobile internet connection.

I want to use Paho MQTT library (it works fine), but it only works via Ethernet or Wifi.

How can I use the Paho MQTT library from python to use the SIM7600X HAT mobile internet connection?

I tried to use the SIM7600X AT+MQTT commands directly writing to the serial port for subscribing to a topic, and it works fine (so there is mobile internet through the 4G HAT), but after a while (1-2 hours) it loses connection all the time, and I can't release client and reconnect, that's why I thought I should use the Paho MQTT library, but it's not working without Ethernet or Wifi connection.

1 Answer 1

2

The Paho Python library will work just fine via LTE. The library is built to interact with the OS's TCP/IP stack. It has no knowledge of the underlying hardware of how that TCP/IP stack talks to the outside world.

If you want it to work you need to have the LTE connection presented as a network device to the OS, not just a serial port.

I suggest you go look at things like PPP and how to use it to "dial up" style connection to your LTE provider.

2
  • Thanks, I followed this guide, and works really well: The only problem is that I can't use the serial port while this script is running. I tried writing AT commands to the serial from a script, but this was the error. Is there any way to write AT commands to the Serial port while I'm connected to the net via SIM7600 module? ser.write(("AT+CMGD=,4"+"\r\n").encode()) File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 578, in write if not timeout.is_non_blocking and timeout.expired(): Commented Jun 5, 2020 at 8:58
  • Yes, that is expected, the serial port is going to be in use delivering the PPP stream, if the HAT only provides one serial interface then you won't be able to do other things with it at the same time.
    – hardillb
    Commented Jun 5, 2020 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.