Pycom is a Dutch company that produces small electronic boards.
The boards are:
- Based on the ESP32 SoC, which is fairly powerfull for a small breadboard;
- Support MicroPython, so it is easy to program with Python;
- Integration with multiple communication protocols.
One of the strengths of Pycom devices is that they have great support for all sort of communication mechanisms. The protocols supported are:
- Wifi (802.11b/g/n)
- Bluetooth Low Energy (BLE)
- LTE-M (mobile)
See Domotics for some more information on these protocols.
The products are:
Development Board Features
All development boards contain a ESP32, which includes many of the features exposed.
- Wifi with onboard antenna (an external antenna can be connected for a larger range, reportedly up to 1 km)
- Bluetooth (standard and low energy
- A slew of peripheral iterfaces: UART, SPI, I2C, CAN (only with external CAN bus transceiver), JTAG, PWM, ADC, DAC and SD. Most can be dynamically configured on each general purpose IO (GPIO) pin.
- Cryptographic hardware acceleration
- A real time clock (RTC). For the WiFy and LoPy, an external RTC module can be connected for more accuracy (on the FiPy, those pins are in use)
- Power regulator (3.3-5.5V input)
- Temperature and hall effect sensor inside the ESP32 (very inaccurate, not calibrated)
- Deep sleep coprocessor. For WiPy2, LoPy1, SiPy1 a deep sleep shield is required to correct for an error in the hardware. This is corrected in FiPy and WiPy3. Typical power consumption is 35 mA while on without radio; 100 mA with wifi or Bluetooth; 0.5 mA for deep sleep (14 mA without the deep sleep shield).
- Wipy2: 520 kB RAM, 4 MB External flash
- Wipy3, LoPy, Fipy: 4 MB RAM, 8 MB External flash
Extension Board Sensors
All extension boards contain:
- USB port for power and serial connection to mounted development board
- LiPo battery connector, is charged via USB when connected
- MicroSD card slot
- Push button
In addition, the following sensors are available on specific extension boards:
- Headers for easy connection to all GPIO pins (extension board only)
- Sensor header connector with I2C, 1 input pin and 1 GPIO pin (Pysense2 and Pytrack2 only)
- GPS/Glonass (L76GNSS), communicates over I2C address 0x10 (Pytrack only)
- SMA connector for external GPS antenna (Pytrack2 only)
- 3-axis accelerometer (LIS2HH12), communicates over I2C address 0x1E (Pysense and Pytrack only)
- Temperature and humidity sensor (SI7006), communicates over I2C address 0x40 (Pysense only)
- Barometric pressure sensor (MPL3115A2), communicates over I2C address 0x60 (Pysense only)
- Optical sensor (LTR-329ALS), communicates over I2C address 0x29 (Pysense only)
- PIC which can be firmware upgraded (Extension board v3, Pysense, and Pytrack only)
All sensors are connected via I2C.
>>> import os >>> os.getcwd() '/flash' >>> os.listdir() ['main.py', 'sys', 'lib', 'cert', 'boot.py']
The three folders are empty by default.
After booting, the device executes the Python code in
boot.py, then the code in
There is no real difference between
main.py. Usually I add code in
boot.py that ensures that I can communicate to the device over a serial cable, and all other code in
main.py. That way, if I make a syntax error in
main.py, I can still easily access the device and correct it.
See https://www.pycom.io/support/supportdownloads/ for firmware updates. Now that since version 1.0, the same updater
PyMakr is a useful tool which allows easy execution of Python code on the device, either while connected via the serial console or via SSH over wifi.
Pinout diagrams for both the chip, as well as the expansion board, can be found at the above URL.
If machine is bricked, the easiest way is to login with serial console, reset the network to an access point, and login with user micro, password python to the build-in FTP server.
Beside the info in
os.uname() give most information.
os.uname().release contains the firmware version,
os.uname().version contains the Micropython version.
>>> os.uname() (sysname='LoPy', nodename='LoPy', release='1.2.0.b1', version='v1.8.6-290-gdac16bd on 2017-01-05', machine='LoPy with ESP32')
Display a File
Not pretty, but a short way to print the contents of a file:
>>> print (open('boot.py').read())
The default contents of
# Allow serial connections import os from machine import UART uart = UART(0, 115200) os.dupterm(uart)
I would not change this default. That way, if you make a syntax error in
boot.py is still executed and you can still easily access the device.
See https://docs.pycom.io/lopy/lopy/tutorial/wlan.html for some examples.
To reset the network to an access point:
from network import WLAN wlan = WLAN(mode=WLAN.AP)
Connect to the MacFreek wifi network:
# connect to wifi # see https://docs.pycom.io/lopy/lopy/tutorial/wlan.html import machine from network import WLAN if machine.reset_cause() != machine.SOFT_RESET: wlan = WLAN(mode=WLAN.STA) wlan.connect('MacFreek', auth=(WLAN.WPA2, 'my_password_'), timeout=5000) while not wlan.isconnected(): machine.idle() # save power while waiting print("Connected to MacFreek network") print(wlan.ifconfig()) else: print("soft reset")
import pycom pycom.heartbeat(False) # disable the heartbeat (blue flashing) LED pycom.rgbled(0xff00) # make the LED light up in green color pycom.heartbeat(True) # enable the heartbeat again
from network import LoRa import time import binascii lora = LoRa(mode=LoRa.LORAWAN) # Get an EUI for your application by e.g. The Things Network. app_eui = binascii.unhexlify('BE78F5B66FF57A1D') app_key = binascii.unhexlify('DC2EC903F98672153DC683BE2F6E3BDE') # Use OTAA addresses, not the older ABP addresses. lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0) # wait until the module has joined the network while not lora.has_joined(): time.sleep(2.5) print('Not joined LoRa yet...') print('LoRa network joined!')
Pycom has great support for the sensors on the extension boards. However, there are fewer libraries for other sensors.
A good starting point is to look at devices with a CircuitPython library. Both the PyCom devices and AdaFruit CircuitPython are both running MicroPython. While they use a different underlying hardware abstraction, it is often easy to rewrite the IO to use the Pycom abstraction layer instead of the AdaFruit abstraction layer.