Things used in this project

Hardware components:
Compare particleelectron
Particle Electron
×1
Software apps and online services:
Zpm toolbar 1
Zerynth Studio

Schematics

Particle Electron - Pinmap
Electron big wbfbhl1gca

Code

Zerynth - HTTP Time GSM ExamplePython
################################################################################
#
# 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)

Credits

Photo
Luigi Francesco Cerfeda

Yet another Tony Stark wannabe

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

E-Paper Weather Display with Photon and IFTTT
Easy
  • 4,154
  • 19

Full instructions

Create a beautiful medium for weather information using Particle's cloud services and IFTTT.

2-Way Particle Photon Communication
Easy
  • 194
  • 4

Make two Particle Photons "talk" via the usage of webhooks!

WiFi Strength Meter
Easy
  • 469
  • 6

A meter that indicates the Wi-Fi signal strength in an intuitive way, using the parts I had on hand.

IFTTT - Enabled Sensors with Particle Photon
Easy
  • 727
  • 12

Full instructions

Connect any sensor to Particle Photon and use it to trigger an IFTTT action with just a few lines of code.

Light Detecting Email Sender
Easy
  • 230
  • 4

Full instructions

Receive an email about when the light is too strong on your device; nobody wants a heated device left directly under the sun. Photon + IFTTT

Internet-Connected Popcorn Popper
Easy
  • 164
  • 1

Full instructions

A hot air popcorn popper triggered via the Internet! (Built for the Bellingham Codes May event.)

Add projectSign up / Login