Easy LoRaWAN and more with LoPy
Prototyping friendly multi-radio platform is packed with plentiful features
The LoPy from Pycom integrates LoRaWAN, WiFi and Bluetooth into a compact module with a prototyping friendly DIP form factor. As if that were not enough, it’s based around the popular Espressif ESP32 SoC, with 512KB RAM and 4MB flash, RTC, plus plenty of GPIO — which even includes 8x 12-bit ADC channels. Application development is supported via MicroPython.
A closer look at I/O
- 2 x UART, 2 x SPI, I2C, I2S, micro SD card
- Analogue channels: 8×12 bit ADCs
- Timers: 4×16 bit with PWM and input capture
- DMA on all peripherals
- GPIO: Up to 24
There is no shortage of GPIO and handily for a device which is likely to prove popular in sensor applications, this also includes 8x analogue inputs, removing the need for external ADCs. However, should even more or higher resolution analogue inputs be required, both I2C and SPI are available for interfacing ADCs along with other external peripherals, such as digital sensors.
Eight of the GPIOs can also be configured as touch inputs, with two that can be configured as DAC outputs and eighteen GPIO pins that are PWM capable! As such the LoPy lends itself to use in far more than just sensor applications and should appeal to those with motion control and creative etc. uses also, amongst a wide variety of other wireless enabled embedded applications.
Thanks to its ULP co-processor, the LoPy is also able monitor the GPIOs — including ADC channels — during deep-sleep and while consuming as little as 25uA.
For hardware prototyping the module can simply be inserted into a solderless breadboard. However, the low cost Universal Expansion Board adds even greater convenience, making it possible to power the module via USB or LiPo battery — and incorporating a charger circuit — while also including a USB-serial converter, Micro SD card slot, headers and other useful features.
LoRaWAN, WiFi & Bluetooth
- LoRaWAN Class A and C
- 802.11b/g/n 16mbps
- Bluetooth Low Energy and Classic
LoPy has the claim of being the only triple bearer MicroPython enabled module and its support for LoRaWAN, WiFi and Bluetooth (LE and Classic!) provides plenty of connectivity options, along with the possibility of using different bearers for primary and fall-back purposes.
Wireless range and power consumption
15mA in active mode, 1-uA in standby
12mA in active mode, 5uA in standby
Figure not provided
Figure not provided
The LoPy can also be configured for use as a LoRaWAN “nano-gateway”, with a quoted range of up to 22km and capacity of 100 nodes. Which could be perfect where the capacity of a much costlier, full blown LoRaWAN gateway able to service thousands of nodes, would be overkill. With the LoPy also capable of connecting to backhaul via WiFi while carrying out some local processing.
It’s generally a good idea with any platform where this is available to start by updating the firmware to the latest available — and Pycom are keen to ensure that you do with the LoPy, with prominent notices to this effect on their website. Instructions are provided for Windows, Mac OS X and Linux, with use of the latter requiring a single dependency, the dialog software, be installed first.
$ sudo apt-get install dialog
$ tar xvf pycom_update_1.1.1.b1.tar.gz
With the downloaded archive extracted the update can then be run.
The update utility provides further instructions and explains how to put the LoPy into firmware update mode, by jumpering a couple of pins on the expansion board.
Following which the device type can be selected and the update completed. Simple!
Python with Pymakr
MicroPython together with the Pymakr IDE provide the official development environment for Pycom platforms. Installing the IDE on Ubuntu is as simple as downloading the appropriate package and e.g.:
$ sudo dpkg -i pymakr_1.0.0.b8-1_all.deb
$ sudo apt-get -f install
For further details, including how to install this on Windows and OS X, see the website.
MicroPython describes itself as “a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimised to run on microcontrollers and in constrained environments.” As a language eminently suited to rapid prototyping and that benefits from plenty of libraries — including for sensors and many other useful peripherals — it’s easy to see how the Python language was chosen.
Using the Pymakr IDE and Quickstart guide it didn’t take long at all to enter a simple example, connect to the board over USB/serial and to upload this, which then cycled the onboard LED through green, yellow and red. With one of the really great features of the LoPy and Pymakr being that you can also upload applications over a WiFi connection.
The Things Network test
Of course, amongst all the other great features of this little board is the one of perhaps most interest, LoRaWAN support. And what better way to test this than to configure the LoPy to join The Things Network (TTN) using Over-The-Air Activation (OTAA), before then performing uplink.
As it happens, configuring the module for use with TTN is covered in the official documentation.
It may perhaps be obvious to some and it is noted in the LoPy documentation, but it’s worthwhile noting here also, that a suitable antenna should be connected to the U.FL connector adjacent to the reset button on the module, prior to use. Otherwise damage to the LoRa radio could occur.
The optional Pycase was also used as not only does this protect the module and expansion board, but it provides a handy mounting for an SMA connector to which an antenna can be affixed.
In order to provision our node on TTN,we need to first get the factory configured Device EUI, which is simple enough to do and involves entering a few lines of Python into the REPL (interpreter prompt). With this we can then register the LoPy against our test application via TTN Console.
With the device registered to the lopy_testing application we now had an Application EUI and App Key that could be configured in our Python application.
All we did here was to take the OTAA and Send examples from the TTN documentation and combine these into a single, very simple script.
Once this had been sync’ed across to the LoPy and the device reset, we could then confirm via TTN Console that it had indeed succeeded in joining the network and sending data up to it!
Getting hands-on with a LoPy module had been on my to-do list for some time and when I finally got round to this, I must say that it did not disappoint. Obviously, I’ve barely scratched the surface and putting one (or more!) to use in an actual application will be the real test, but so far I am impressed. Not only does the LoPy pack a lot of great features into a relatively small package, but the documentation and overall user experience is fairly polished also.
Speaking of documentation, Pycom provide a number of LoPy tutorials, including LoRaWAN ones, along with those based around a much simpler “raw” LoRa MAC which can be used for point-to-point communication between two LoPy — removing the need for a LoRaWAN gateway and Internet access. Generic tutorials applicable to all Pycom modules are also available, covering things such as HTTPS, MQTT, ADC, I2C, threading and timers etc.
Open source (hardware and software!) advocate, Treasurer and Director of the Free and Open Source Silicon Foundation, organiser of Wuthering Bytes technology festival and founder of the Open Source Hardware User Group.
February 20, 2017 17:53
CommentsAdd a comment
March 8, 2017 10:04
Thanks for sharing this great LoPy board overview. My startup is a huge fan of the advanced Pycom LPWAN boards like the LoPy. It might be good to mention that as far as I know, LoRaWAN Class C (which is one of the reasons we love the LoPy) currently isn't supported neither by Pycom in the Python s/w, nor by TTN. My expectations regarding this important feature has been lowered somewhat recently, when I found out :-(