• Get Started
    • Overview
      • What is Zerynth
      • How Zerynth Works
      • Licensing
    • Tools
      • Zerynth Studio
      • Zerynth Virtual Machine
      • Zerynth App
    • Integrations
      • Microcontrollers / Boards
      • Cloud / IoT Dashboards
      • Sensors / Actuators
    • Learn
      • Documentation
      • Video Tutorials
      • Zerynth Academy
      • Knowledge Base
  • Community
    • Forum
    • Projects
    • Blog
  • Company
    • About Zerynth
    • Partners
    • Careers
    • Services
    • Contact us
Zerynth - Python for Microcontrollers, IoT and Embedded Solutions Zerynth - Python for Microcontrollers, IoT and Embedded Solutions
  • Get Started
    • Overview
      • What is Zerynth
      • How Zerynth Works
      • Licensing
    • Tools
      • Zerynth Studio
      • Zerynth Virtual Machine
      • Zerynth App
    • Integrations
      • Microcontrollers / Boards
      • Cloud / IoT Dashboards
      • Sensors / Actuators
    • Learn
      • Documentation
      • Video Tutorials
      • Zerynth Academy
      • Knowledge Base
  • Community
    • Forum
    • Projects
    • Blog
  • Company
    • About Zerynth
    • Partners
    • Careers
    • Services
    • Contact us
How to Program Particle Electron (cellular IoT) in Python with Zerynth

How to Program Particle Electron (cellular IoT) in Python with Zerynth

Nov 8, 2016 | Posted by Luigi F. Cerfeda | Zerynth Academy |

In this article, we’ll see how to program Particle Electron in Python using Zerynth to develop cellular-connected electronics projects and products in a few clicks.

Particle Electron is a GSM enabled development platform for creating cellular-connected electronics projects and products with M2M in mind. It comes with a Particle SIM card with service in more than 100 countries worldwide and includes 3 months of Particle’s 1MB monthly data plan for IoT devices.

Particle Electron combines a powerful ARM Cortex M3 microcontroller (STM32F205RG Cortex M3) with a 3G/2G gsm module from UBlox (U260 or G350). In addition to having 1Mb of internal flash memory for storing the firmware, the Electron also features 128k of Ram and 120 MHz of clock.

Note: all the reported information are extracted from the official Particle Electron reference page, visit this page for more details and updates.

Particle Electron Board Summary

  • Microcontroller: ARM 32-bit Cortex™-M3 CPU Core
  • Operating Voltage: 3.3V
  • Input Voltage: 3.6-6V
  • Digital I/O Pins (DIO): 28
  • Analog Input Pins (ADC): 14
  • Analog Outputs Pins (DAC): 1
  • UARTs: 5
  • SPIs: 2
  • I2Cs: 1
  • CANs: 1
  • Flash Memory: 1Mb
  • SRAM: 128 KB
  • Clock Speed: 120Mhz
  • Cellular modem: U-Blox SARA U-series (3G)
  • Board dimensions: 2.0″ x 0.8″ x 0.3″ (0.5″ including headers)

 

Particle Electron Pinout and Associated Zerynth Features

Particle Electron pinout and Zerynth features

Required Materials to get started

From Particle Store:

  • Particle’s data plan
  • Particle Electron board
  • Particle SIM Card

 

From Zerynth:

  • Zerynth Studio

 

Miscellaneous:

  • Li-Po battery (2000mAh)
  • USB cable

 

The Electron is equipped with on board power management circuit powered by BQ24195 pm unit and MAX17043 fuel gauge. The Electron can be powered via the VIN (3.9V-12VDC) pin, the USB Micro B connector or a LiPo battery. When powered from a LiPo battery alone, the power management IC switches off the internal regulator and supplies power to the system directly from the battery.

Connect and virtualize a Particle Electron

If you hadn’t done it yet, download and install Zerynth Studio.

Then connect the board to your PC. On Windows machines, the Particle Electron USB Drivers are required by the Zerynth Studio for accessing the serial port establishing a connection with the STM32 UART. More detailed info on the related Zerynth Doc section.

Follow these steps to register and virtualize a Particle Electron:

  • Put the Electron in DFU Mode (Device Firmware Upgrade):
    • Hold down BOTH buttons (reset and setup);
    • Release only the reset button, while holding down the setup button;
    • Wait for the LED to start flashing flashing magenta, then yellow;
    • Release the setup button; the device is now in DFU Mode (yellow blinking led);
  • Select the Electron on the Device Management Toolbar;
  • Register the device by clicking the “Z” button from the Zerynth Studio;
  • Create a Virtual Machine for the device by clicking the “Z” button for the second time;
  • Virtualize the device by clicking the “Z” button for the third time.

Program a Particle Electron in Python

After virtualization, the Particle Electron is ready to be programmed and the Zerynth scripts uploaded.

Let’s start with the “HTTP Time GSM Example” example to show the capabilities of the Particle Electron.

Just follow the steps below (for more detailed info read this getting started):

  1. access the Quick Search Bar (more info here) through the shortcut Ctrl+P and type “GSM HTTP”;
  2. select the example and clone it by clicking on the dedicated button;
  3. at this stage, Zerynth Studio converts the example in a new project giving you the possibility to edit the Title and the Description. Remember that Zerynth Studio doesn’t allow two projects to have the same name. If you are trying to clone an example that you already cloned in the past leaving the default Title, then you need to give a different title to this new project.
  4. click on “Create” and you are done!

Below you can see the code.

Zerynth - HTTP Time GSM Example
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
################################################################################
#
# HTTP Time GSM Example
#
################################################################################
 
# the classic wifi requests example, very little changes accessing
# the net through a gsm connection!
 
# import our gsm chip specific driver
from ublox.g350 import g350
# and the generic gsm module
from wireless import gsm
import streams
import requests
 
 
streams.serial()
 
# init the gsm driver!
# The driver automatically registers itself to the gsm interface
# with the correct configuration for the selected board
g350.auto_init()
print("Connecting...")
try:
    # connect to our APN
    gsm.connect_net('spark.telefonica.com')
except Exception as e:
    print("ooops, something wrong while connecting :(", e)
    while True:
        sleep(1000)
 
# from now on everything is exactly identical to wifi HTTP Time Example ;)
 
# let's try to connect to timeapi.org to get the current UTC time
for i in range(3):
    try:
        print("Trying to connect...")
        # we need to impersonate a web browser: as easy as setting the http user-agent header
        user_agent = {"user-agent":"Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405"}
        # go get that time!
        # url resolution and http protocol handling are hidden inside the requests module
        response = requests.get("http://www.timeapi.org/utc/now",headers=user_agent)
        # let's check the http response status: if different than 200, something went wrong
        print("Http Status:",response.status)
        # if we get here, there has been no exception, exit the loop
        break
    except Exception as e:
        print(e)
 
 
try:
    # check status and print the result
    if response.status==200:
        print("Success!!")
        print("-------------")
        print("And the result is:",response.content)
        print("-------------")
except Exception as e:
    print("ooops, something very wrong! :(",e)

Now you have to uplink the code.

Just Select the virtualized device from the “Device Management Toolbar, click the dedicated “uplink” button of Zerynth Studio and reset the device by pressing the Reset on-board button when asked.

Done! Now you can see the result printed on the serial monitor!

 

Related

Tags: Cellular IoTParticleParticle Electron
Share
Loading Facebook Comments ...

Newsletter

Follow us!

My Tweets

Latest Posts

  • Day one – Impressions from the IoT Tech Expo in London
    Day one – Impressions from the IoT Tech Expo in London
  • Zerynth r2.1.1 is out with support for JTAG and customizable VMs for your own hardware solutions!
    Zerynth r2.1.1 is out with support for JTAG and customizable VMs for your own hardware solutions!
  • Connected Industrial Toolkit for IoT – Zerynth and Eseye partnership announced
    Connected Industrial Toolkit for IoT – Zerynth and Eseye partnership announced
  • Meet Zerynth at IoT Tech Expo and learn about IoT, Microcontrollers and Blockchain
    Meet Zerynth at IoT Tech Expo and learn about IoT, Microcontrollers and Blockchain
  • Zerynth and WolkAbout Announce Technology Partnership
    Zerynth and WolkAbout Announce Technology Partnership

Categories

  • News
  • Releases and Updates
  • Zerynth Academy

TAGS CLOUD

4zerobox Adafruit Amazon Web Services Arduino AWS Blockchain Click Boards Cloud Cloud IoT Embedded World ESP32 ESP8266 Espressif Espressif Systems Flip and Click FOTA Google Cloud Platform Google IoT Core Hexiwear HUZZAH Industry 4.0 IoT Tech Expo Kickstarter LoRa LoraWAN Maker Faire Maker Faire NYC Maker Faire Rome Microchip mikroBUS MikroElektronika Multiblink Particle Photon SAMD21 ST Nucleo The Things Network Ubidots Wolkabout Workshop Zerynth Advanced Device Manager Zerynth App Zerynth Package Manager Zerynth Stack Zerynth Studio Zerynth Virtual Machine

Zerynth Tools

• Zerynth Studio
• Zerynth Virtual Machine
• Zerynth App

Zerynth Integrations

• Microcontrollers / Boards
• Cloud / IoT Dashboards
• Sensors / Actuators

Get started

• What is Zerynth
• How Zerynth Works
• Licensing

Learn

• Documentation
• Video Tutorials
• Zerynth Academy
• Knowledge Base

Community

• Forum
• Projects
• Blog

Company

• About zerynth
• Partners
• Careers
• Services
• Contact us

Zerynth Newsletter

Zerynth Social

© 2018 by Kinzica Ventures LLC, New York, USA | Copyright | Terms of service | License | Privacy policy

  • License
  • Terms of Service
  • Privacy
  • Copyright
Prev Next
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.Accept Read More