PyCom FiPy
FiPy is a development board developed and manufactured by PyCom . It is a good IoT platform based on MicroPython, and features 5 networks in one board (WiFi, Bluetooth, LoRa, Sigfox, Cat M1 and NB-IoT).
Introduction
Connecting your FiPy to Spark LTE Cat M1 Network
Updating the FiPy Firmware
Instructions for updating the FiPy firmware can be found at the manufacturers website, along with the latest version of the firmware:
- Instructions for updating FiPy expansion-board firmware
- Download and install the latest FiPy firmware from PyCom
and these steps must be performed before attempting to connect to the Spark CatM1 network.
Uploading a Test Application
After updating your FiPy to the latest firmware version, upload the following Python code to the FiPy:
###############################################################
# Author : Adamson dela Cruz
# Date : Aug 8, 2018
#
# NOTE : Sample application that demonstrates how to connect
# a FiPy module into Spark network using Cat M1
###############################################################
import socket
import ssl
import time, pycom
from network import LTE
import machine
import gc
url = "google.com"
buffer = 4096
# instantiate the LTE object
lte = LTE()
# attach the cellular modem to a base station
lte.attach()
pycom.heartbeat(False)
# Set the LED to red
pycom.rgbled(0xff0000)
# Set a counter
ctr=1
while not lte.isattached():
print(ctr,' Attaching to Spark LTE network...')
time.sleep(2.5)
ctr = ctr +1
print("Modem ATTACHED to Spark LTE Network...")
# Set LED to Yellow
pycom.rgbled(0xffff00)
# Get the System FSM
print(lte.send_at_cmd('AT!="fsm"'))
# Reset the counter
ctr = 1
# start a data session and obtain an IP address
lte.connect()
while not lte.isconnected():
print(ctr, 'Connecting to Spark LTE Network...')
time.sleep(2.5)
ctr = ctr + 1
# Connected set LED to green
pycom.rgbled(0x00ff00)
print("CONNECTED !!!")
# Send a simple http request
print("Connecting to https network...")
# Create a socket and use ssl
s = socket.socket()
s = ssl.wrap_socket(s)
s.connect(socket.getaddrinfo(url, 443)[0][-1])
s.send(b"GET / HTTP/1.0\r\n\r\n")
# Wait for the response and receive it in a variable
response = s.recv(buffer)
print("RESPONSE: ", response)
# Set the LED to blinking blue
pycom .heartbeat(True)
# Clean up
s.close()
lte.disconnect()
lte.dettach()
PyCom have built an Atom IDE plugin for working with their devices.