element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Personal Blogs
  • Members
  • More
Personal Blogs
Legacy Personal Blogs Sequans Monarch-Go Python Example
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: james.flynn
  • Date Created: 16 Mar 2020 7:43 PM Date Created
  • Views 938 views
  • Likes 4 likes
  • Comments 2 comments
  • monarchgo
  • avnet_wireless
  • cellular iot prototyping
  • iot
Related
Recommended

Sequans Monarch-Go Python Example

james.flynn
james.flynn
16 Mar 2020

Introduction image

The Sequans Monarch Module is a LTE-M cellular modem that comes in two styles; one has GPS integrated, and one does not.  Both starter kits are available for purchased from Avnet using the following links:

 

https://www.avnet.com/wps/portal/us/products/new-product-introductions/npi/sequans-monarch-go

 

Using the Monarch Module in an IoT solution allows easy addition of Cellular communications capabilities--great for remote placement of sensors. This Blog discusses the setup of the Monarch-GO Module and utilizing it with AT commands over a serial connection.  I have posted an example Python script (at https://github.com/Avnet/sequans_python ) that implements a typical HTTP/HTTPS and MQTT connection

 

Sequans Monarch-GO setup

The Sequans Monarch-Go Module comes configured to use the Verizon cellular network.  To begin, ensure the Verizon SIM card is installed properly by removing the module from the PCB (two screws holding the module to the PCB board) and accessing the SIM card via the access door:

image

 

With the SIM card installation verified, connect the module to a PC using the serial port on the PCB to allow communications with a connected computer.  It is necessary to use a Serial Terminal program such as minicom or Putty when communicating with the module.

image

Once the mini-USB cable in connected, the Monarch-Go module and should automatically connect.  On a Windows PC the drivers will be auto-installed, on a Linux PC the connection is made as VCP ports (usually identified as /dev/ttyUSBx).   In total, there are 4 ports enabled by the module but only UART 1 is utilized:

 

UARTDescriptionBaudrateData BitsFlow ControlParityStop Bits
0AT Commands9216008HardwareNone1
1AT Commands1152008HardwareNone1
2Console1152008NoneNone1
3UnusedNANANANANA

 

After you have connected the module to your PC, use the Serial Terminal program to verify the module is responding correctly by entering an ‘AT’ and return.  You will see an “OK” response generated by the Monarch.

 

Verizon SIM sign-up

Because the module was provided with a Verizon SIM card, it has to be associated with a ThingSpace account.  This association is made by going to the web page https://thingspace.verizon.com/service/connectivity-for-developers/ and following the signup procedure.

 

With the serial communications between the Monarch and PC confirmed and the SIM card association complete, you can verify a network connection by observing the power-up log of the Monarch.  The log will report:

 

+SYSSTART
 +CEREG: 2
 +CEREG: 0
 +CEREG: 2
 +CEREG: 1,"9B01","02610402",7

 

Note: the values following CEREG: 1 may be different

 

The SYSSTART indicates the module is starting and the CEREG command reports registration status after startup. The status of ‘2’ indicates that the device isn’t registered and ‘0’ indicates that a search is underway for an operator to register with.  Once the operator is found--in this case Verizon--the device registers and the network information is shown after the ‘1’ status.  At this point, the module has registered with the network using the SIM that you associated with a ThingSpace account and you can issue commands.  An easy way to verify operation is to  issue a Ping command to google.com (8.8.8.8), e.g.:

 

AT+PING="ping 8.8.8.8"

 

PING 8.8.8.8 with 32 bytes of data

        from 8.8.8.8 icmp_seq=1 ttl=51 time=200 ms

 

OK

As shown above, Google received the ping and responded as you would expect.

 

The HTTP/HTTPS Interface

With internet connectivity confirmed, AT commands can be used in Python scripts for network communications.  The example (implemented in Python3) provided at  https://github.com/Avnet/sequans_python demonstrates both HTTP and MQTT communications.  When started, the example script displays the following to the user:

 

  image

 

For HTTP communications, the script interacts with http://httpbin.org--a simple HTTP Request & Response service--by sending PUT, POST, GET, DELETE, and STREAM commands.  When httpbin.org receives the commands, it echos the command back.  An example using a PUT command is:

  image

You can also use HTTPS rather than HTTP by toggling TLS prior to issuing the command.  In the example above, TLS was enabled so the response url is displayed as "https://httpbin.org/put".

 

MQTT Interface

The example script also supports posting and subscribing to an MQTT exchange. To demonstrate interaction with an MQTT broker, the script uses HiveMQ and the Chrome browser application MQTTBox.  To begin, setup the MQTTBox application to use an MQTT Client id of 'client-test1' and a Host address of 'broker.hivemq.com'. This will allow you to monitor and post to topics from within MQTTBox.  The setup should look similar to:

 

image

Once configured, you can monitor and post topics.  In the script, 'sqn/test' is the topic used so when posting to the Sequans module, use this topic (in the Topic to publish box) and whatever Payload you would like will be sent to this topic.  When the 'Publish' button is pressed, the payload will be displayed on the right side of the dialog showing the payload for the 'sqn/test' topic.  An example of this is shown below:

image

Using the example script provided, select either 7 or 8 to Subscribe/Post messages between HiveMQ, the MQTTBox application, and the Python script.  For example, in the following screen shot, an MQTT Subscribe action has been executed and the script then waits for a subscribed message to be received. When the payload is posted to the 'sqn/test' topic using MQTTBox, it will also be displayed in the Python Script as shown below.

image

 

   Similarly, when a Post is executed by the Python script (selection 8), the published message is displayed within MQTTBox as shown below:

 

image

 

 

Summary

The Sequans Monarch-Go module has an extensive set of AT commands that can be utilized, the currently implemented script is but a limited sub-set.  For a complete listing of AT commands, reference the Sequans Monarch AT Command Reference Guide.

  • Sign in to reply
  • mainpp
    mainpp over 1 year ago

    I have been able to run this demo, mostly with MQTT (SQNSMQTTCFG), but I can't find a way to log in with username and password from python and it doesn't show how to do it from Sequans documentation either. any idea?

     

    def mqtt_post(debug, server, port, username, password):

        try:

            mqtt_cfg = "AT+SQNSMQTTCFG=0,\"" + clientID + "\""+ r

            do_debug(debug,"Send Command: " + mqtt_cfg)

            channel0_at.write(mqtt_cfg.encode())

            print('AT+SQNSMQTTCFG=0->',mqtt_cfg)

            waiting_response_noexit('OK')

     

     

    Thanks

     

    He podido realizar la ejecución de esta demo, mas que nada con MQTT, pero no encuentro la manera de ingresar con usuario y contraseña desde python y tampoco se muestra como hacerlo desde la documentación de Sequans. ¿alguna idea?

    Gracias

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dubbie
    dubbie over 3 years ago

    These look good and I like the functionality, but I think they are a bit too expensive for anything I might like to play with.

     

    Dubbie

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube