Connecting

Before you can start working with UPER1 you have to make sure that it was successfully recognized by the host. To do so, please choose your platform and follow the steps:

Installing libraries

First of all, even though UPER1 is controlled with SFP messages sent over the command port, this will not be a tutorial about SFP messages. If you really want to send SFP messages by yourself, you should refer to the UPER1 function list to see the available functions and SFP wiki to learn how the messages are encoded.

Instead it will be shown how to create an LED blinky program by using IoTPy API, which is the recommended way of developing applications not only because it's much easier to use, but it also gives a lot of power and flexibility in all development stages. In order to run the code using IoTPy you will need to install two things:

First program

The IoTPy API has its own concept and to better understand it you should read the full IoTPY API reference. But for this example it will suffice to know that the main idea behind IoTPy is that you have a device object from which you can get certain modules, for example a GPIO module. Each module has it's own capabilities, which usually manifest in a form of a function. One of the GPIO modules capability is to output certain voltage (write digital signal) on the physical pin, which, as you may have guessed it, will be used to turn on and off an LED.

So the short theory is here, lets jump to the code:

from time import sleep
from IoTPy.core.gpio import GPIO
from IoTPy.pyuper.uper import UPER1
 
with UPER1() as board, board.GPIO(27) as redPin:
 
    redPin.setup(GPIO.OUTPUT)  # set GPIO pin to be output
 
    while True:
        redPin.write(0)  # Turn led ON (LED on board is common anode - therefore inverted)
        sleep(0.5)
        redPin.write(1)  # Turn led OFF
        sleep(0.5)

Copy and paste the code into a file (for example blinky.py) and run it. In UNIX-like systems type python blinky.py and in Windows you can open the file with IDLE and press F5 key or simply double click it.

For those who are new to Python or are unclear about the code, here's some details: