The Binho Nova host adapter works seamlessly with CircuitPython. You can leverage all of the open-source device drivers and example code right from your PC. In the video below, Shannon Morse walks through the process of setting this up from scratch, starting with Python installation, and shows how simple it is to use with Nova.
The same instructions presented in the video can be found below for easy reference, along with some additional examples.
Setup
Prerequisites
This guide presumes that you already have Python 3.x and pip installed on your computer.
You can verify these requirements by entering the following command:
Step 1: Setup Binho Nova Host Adapter Hardware
The Binho Nova Multi-Protocol USB Host Adapter utilizes the standardized USB Communications Device Class driver in order to achieve maximum compatibility with as many systems as possible. As such, there's no driver to download and install for most operating systems.
Certain operating systems like Mac and Ubuntu may require additional permissions to start using Binho Nova. In addition, Windows 7 does not have the standard USB CDC driver included as default.
Please check the following guide to setup permissions on Mac/Ubuntu and Windows 7 driver setup:
Verify Nova can communicate with binhoHostAdapter python library:
Step 3: Install Adafruit Blinka
Step 4: Set BLINKA_NOVA environment variable
In order for Adafruit Blinka libraries to use Binho Nova, set the BLINKA_NOVA environment variable with the following command:
Windows Command line:
Windows Powershell:
Mac/Ubuntu:
Verify Binho Nova’s environment variable is set and Adafruit Blinka libraries can recognize and communicate with the adapter:
Examples
For the examples shown below, it may make sense to review the Connecting the Hardware guide which includes the pinout of the Binho Nova connector for easy reference.
This example uses Adafruit’s busio package to create a UART object. It will read 3 characters from the FTDI cable which CoolTerm is connected to. The script then sends ‘hello world’ to the FTDI cable which will display in CoolTerm.
C:\Binho\adafruit>pip --version
pip 19.3.1 from c:\program files (x86)\python38-32\lib\site-packages\pip (python 3.8)
pip install binho-host-adapter
C:\Binho\adafruit>python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from binhoHostAdapter import binhoUtilities
>>> devices = binhoUtilities.binhoUtilities().listAvailableDevices()
>>> print(devices)
['COM8']
pip install adafruit-blinka
set BLINKA_NOVA=1
$Env:BLINKA_NOVA = "1"
export BLINKA_NOVA=1
C:\Binho\adafruit>set BLINKA_NOVA=1
C:\Binho\adafruit>python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import board
>>> dir(board)
['I2C', 'IO0', 'IO1', 'IO2', 'IO3', 'IO4', 'MISO', 'MOSI', 'RX', 'SCK',
'SCL', 'SCLK', 'SDA', 'SPI', 'SS0', 'SS1', 'TX', '__builtins__',
'__cached__', '__doc__', '__file__', '__loader__', '__name__',
'__package__', '__spec__', 'ap_board', 'board_id', 'detector', 'pin',
'sys']
>>>
pip install adafruit-circuitpython-bme280
import time
import board
import digitalio
import busio
import adafruit_bme280
# Create library object using our Bus SPI port
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
bme_cs = digitalio.DigitalInOut(board.IO0)
bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, bme_cs)
# change this to match the location's pressure (hPa) at sea level
bme280.sea_level_pressure = 1013.25
while True:
print("\nTemperature: %0.1f C" % bme280.temperature)
print("Humidity: %0.1f %%" % bme280.humidity)
print("Pressure: %0.1f hPa" % bme280.pressure)
print("Altitude = %0.2f meters" % bme280.altitude)
time.sleep(2)
import time
import board
import busio
import adafruit_bme280
# Create library object using our Bus I2C port
i2c = busio.I2C(board.SCL, board.SDA)
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
# change this to match the location's pressure (hPa) at sea level
bme280.sea_level_pressure = 1013.25
while True:
print("\nTemperature: %0.1f C" % bme280.temperature)
print("Humidity: %0.1f %%" % bme280.humidity)
print("Pressure: %0.1f hPa" % bme280.pressure)
print("Altitude = %0.2f meters" % bme280.altitude)
time.sleep(2)
import time
import board
import digitalio
led = digitalio.DigitalInOut(board.IO0)
led.direction = digitalio.Direction.OUTPUT
while True:
led.value = True
time.sleep(0.5)
led.value = False
time.sleep(0.5)
import time
import board
import pulseio
led = pulseio.PWMOut(board.IO0, frequency=5000, duty_cycle=0)
while True:
for i in range(100):
# PWM LED up and down
if i < 50:
# Up
led.duty_cycle = int(i * 2 * 65535 / 100)
Else:
# Down
led.duty_cycle = 65535 - int((i - 50) * 2 * 65535 / 100)
time.sleep(0.01)
import board
import busio
uart = busio.UART(board.IO4, board.IO3, 115200, 8, None, 1, 1000)
data = uart.read(2)
# convert bytearray to string
data_string = ''.join([chr(b) for b in data])
print(data_string, end="")
uart.write('hello world')
uart.deinit()