LTE-M Attach/Connect Best Practices?

  • Hi, I'm new to both PYCOM and LTE-M . I'm looking for any info/advice about using LTE (on Gpy) with regards to how long is acceptable to stay attached and/or connected without any IP traffic.

    My application requires sending small (<100bytes) UDP packets in response to real time events (with minimal delays). Typically these might occur approx 10 mins apart, but could be anywhere from 10 secs to several weeks apart. I can't find any documentation regarding using PYCOMs LTE library over a long period of time, the only docs and examples I can find simply say LTE.attach(), LTE.connect() and then send data but no mention of what to do next or how long theses connections can be expected to last.

    I have had success sending several UDP packets (approx 1 minute apart) without disconnecting/etc, however, if I time.sleep() for more than about 2 mins between sending, no further UDP send commands will succeed even though LTE.isconnected() and LTE.isattached() continue to return True. I have found by wrapping the send function with LTE.connect() LTE.disconnect() I can successfully send packets with larger delays between them (up to an hour or so). Sometimes when it's time to resend, the LTE needs to be re-attached (i.e. LTE.isattached() returns False) but doing so usually succeeds and the packet can be sent. Not sure if leaving the LTE attached is considered good or bad practice?

    My question is: Does anyone have any experience with (or at least a good rule of thumb regarding) how often an application could/should remain idle before disconnecting and/or detaching from the LTE network. I'm assuming network providers have IDLE timers to kick devices off their network as a result of inactivity, but I can't find anywhere that has documented this.

    My tests so far have been using an M2MONE SIM card on the Telstra network in Australia if that is at all significant. Telstra publish a developers guide on their website that encourages applications to not hog resource unnecessarily, but I have also come across warnings about other providers locking devices off their networks due to excessive connect/disconnect cycles. Again, someone with some experience can hopefully shed some light on the situation.

    Any help would be greatly appreciated.

  • @dgerman Thanks for sharing your code. My device will be attached to a vehicle and therefore power consumption is of little concern. It will be powered on for potentially many hours at a time and will be in continual communications with other devices over a CAN bus. Only when certain events occur on the CAN bus do I need to send data to the cloud. As I said before I have found that holding the LTE connection open for too long (a couple of mins) results in no data throughput even though lte.isconnected() remains True. Disconnecting after every data send appears to be working but seems network unfriendly. I admit, due to the lack of documentation from Pycom, I have no idea what lte.connect() and isconnected() actually does. I have downloaded the pycom source code and begun sifting through it to try to find out.

    I plan to experiment with the PSM features in the hope that notifying the network that there may be no radio contact for a period of time might speed up the re-attach/re-connect cycle. I am un-easy using the "Suck And See" method for development however, as this has the very real potential of back firing 12 months down the track when a provider tweaks their network and you have 1000 customers on the phone complaining their devices no longer function.

  • This post is deleted!

  • @ruok4t Is your application battery and/or solar powered?
    I have a Gpy on an expansion board running of a 3800mAh running remotely using hologram sim connection in northEastern USA.
    I deepsleep for 20 minutes, wait a couple of seconds for a blueTooth packet then transmit it as a UDP syslog packet.
    This works a lot of the time!!
    Battery has been known to last 2 weeks as long as sequence ends with LTE.disconnect otherwise much shorter lifetime.

    I think you need to experiment with your specific provider.

    Be sure to failsafe you code with limited attempts for attach/connect.
    It's better to give up for this cycle and try again later.
    Feel free to use/adapt my code at and
    See the results at
    Let me know how you make out.

Log in to reply

Pycom on Twitter