Skip to content
anthonyrowe edited this page Nov 20, 2017 · 45 revisions

Pycom LoPy Module with OpenChirp

The LoPy from Pycom is a great module that mates an ESP32 processor running Python with LoRa, WiFi and BLE radios. Its super easy to quickly get going with the ability to send an receive using an onboard Python interpreter. This page describes how to setup and install a board with OpenChirp. Its worth noting that while this is an easy way to get going quickly its unclear how power efficient the ESP32 running Python is in its current form. We are doing some testing, but its likely not as efficient as boards that are optimized specifically for power. Below is a photo of the LoPy with a standard I/O expansion kit for connecting to GPIO.

You can get the LoPy and PySense from Seed Studio.

LoPy Image

The easiest way to get going with the LoPy is to use our PySense demo project and OpenChirp template described in the PySense section.

Setup your LoPy

  1. Download the pycom software from pycom's website to update the LoPy firmware (recommended)
  2. Install ATOM as described in the LoPy Install Instructions

Setup the Firmware on the LoPy

In Atom, More -> Get serial ports Settings -> Global settings -> Device address (Paste your device address here!) Connect

To figure out the DevID, copy and paste the following into an empty document (File -> New File)

from network import LoRa
import binascii

# Initialize LoRa in LORAWAN mode.
lora = LoRa(mode=LoRa.LORAWAN, adr=True, public=True, tx_retries=0)

print("Mac ", binascii.hexlify(lora.mac()))

Simply, Run. Write this down as you will need this to setup the device on OpenChirp (copy & paste doesn't work with this terminal).

Get the LoPy on OpenChirp

The examples project can be cloned from this repo.

  1. File -> Add Project Folder
  2. Update pymakr.conf with your device address (get from More -> Get serial ports)
  3. Connect (make sure only one project folder is added to your working project tree since pymakr will try to flash your device with root folder)
  4. Open main.py, update your application eui and key (you will have to generate this!)
  5. Write program to flash (Packages -> Pymakr -> Synchronize project or Upload)

Note: you can safely disconnect your serial communication by selecting the up/down chevron on the far right hand side of the pycom console.

LoPy can be used with 1 of the 3 useful companion boards:

PySense

We provide demo code and an OpenChirp template for the PySense shield that makes it easy to connect with OpenChirp.

LoPy Pysense

Its important to note that you need to install the PySense Firmware before using this project. You can find instructions for that here: https://docs.pycom.io/chapter/pytrackpysense/installation/firmware.html

A demo OpenChirp Demo project can be found here: https://github.com/OpenChirp/PySenseDemo

Install this project, run it and record the DevEUI provided from your board at startup. You will need to enter this into the OpenChirp Web Portal.

To register a device into OpenChirp in three easy steps:

  1. Create device using the "LoPy PySense" template
  2. Set the DevEUI in the LoRaWAN Service config
  3. Collect data!

Screenshots for each of these steps below:

Step 1: Add a new device and choose "LoPy PySense" from the templates

Screen 1

Step 2: Add your DevEUI to the LoRaWAN service by clicking the "Service" tab and then "View/Update Config" on the LoRaWAN service.

It is normal to see the LoRaWAN service having failed before you enter the DevEUI.

Screen 2

This screen shows where to enter the DevEUI:

Screen 3

Step 3: Refresh the browser and look at the "Transducer" tab to see your sensor data!

Screen 4

More documentations can be found at docs.pycom.io - 4.3.2.

Expansionboard

LoPy Exp LoPy Exp Deployable

Note: you will need this to upgrade the firmware of your LoPy.

Simple LoPy Demo with Byte Translator:

To test sending and receiving your own raw data on OpenChirp using the LoPy and configuring your own device, try running this test project: https://github.com/OpenChirp/LoPyDemo

This project will send three uint8 values every five seconds over LoRaWAN and will print out any data received from the server. Make sure to set the APP_EUI and APP_KEY as described above. You can create a device for this demo using the "LoPy Simple Demo Template" or build it from scratch as described below.

You will want to setup the following three services:

  1. LoRaWAN Service
  2. TimeSeries Storage
  3. Byte Translator

You will add services on the "Services" tab of the OpenChirp web portal. First, add the TimeSeries service and then add the LoRaWAN Service.

Screen 1

Configure the LoRaWAN service as follows:

Screen 2

Next, load the demo program onto your LoPy and let it connect to the network. Once a packet is received you will see the "rawrx" field in the "Transducer" page update. This is technically added by the TimeSeries Service, so that needs to be running for the value to appear. You many need to refresh the browser window.

Screen 3

Next add the "Byte Translator" service to convert raw data into transducers. For the purpose of the demo, configure it as shown below:

Screen 4

Now once data arrives, you will see the following uplink data types appear.

Screen 5

Add the downlink transducers yourself using the "Transducer" tab. The units don't really matter, but make sure to set "Actuable" flag to "true".

Screen 6

Now create a command to test if the downlink is working.

Screen 7

You can add a variety as follows:

Screen 8

When you click on each of these, you should see the LoPy demo program print out the value. To review, these are the types that will eventually appear in your Transducer list if everything is working correctly:

Screen 9

You should now see data appear on the console of the LoPy when you run a command and you should see the received values plotted in the Visualize Tab.

Pytrack

Follow the instructions can be found at docs.pycom.io - 4.2.1 to update the firmware (recommended).

Documentations can be found at docs.pycom.io - 4.3.1. LoPy Pytrack