Skip to content

Getting Started

Adam Robichaud edited this page Mar 14, 2024 · 1 revision

Requirements

You will need a serial-enabled Boltwood Cloud Sensor III S or SO with firmware revision 12 or greater connected to your computer.

This guide assumes you have Python 3.10 or greater installed on your system with the installation added to your PATH environment variable, and are familiar with basic Python toolchain tools like PyPI. You can verify this by executing:

>> python --version
Python 3.11.8 (tags/v3.11.8:db85d51, Feb  6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Installation

pyboltwood is available on PyPI: pyboltwood project page. Begin by downloading the latest Boltwood Python package using PyPI on your command line:

>> pip install pyboltwood

Determining the Boltwood's serial port

In order to communicate with your Boltwood, you need to discover which port the device is connected to. Unfortunately, every operating system has a different way of presenting serial port access, so you'll need to familiarize yourself with the process for your environment.

Windows

Windows list connected serial devices in the Device Manager under "Ports (COM & LPT)". Boltwood devices list as "USB Serial Port (COM#)", where "COM#" will be something like "COM3". That value is the port you'll be addressing when you create the Boltwood class instance.

Ubuntu 22.04 LTS

Linux drivers list their serial devices in the /dev folder. Our serial converters will typically list as /dev/ttyUSB# where "ttyUSB#" will be something like "ttyUSB0". This file needs to be given read/write privileges. This can be achieved with the following command:

$ sudo usermod -a -G dialout $USER

where you replace $USER with your user account name.

Your first program

Once you've installed boltwood.py's dependencies and determined the port your Boltwood is connected to, you can write your first application. Create a new directory and place "boltwood.py" in it. Then create a new file, named "example.py" and paste the following code into it:

# example.py
from pyboltwood import Boltwood, DeviceDescriptor

# Sets up a Boltwood instance on Windows COM port `"COM1"` 
# and open the connection. Always wrap your code in a try-except
# block to prevent abnormal program termination
try:
    bcs = Boltwood("COM1")
    bcs.open()

    # Attempt to retrieve Device Descriptor's Serial property, handle any errors
    rc, value = bcs.get(Interface.DD, DeviceDescriptor.SERIAL)
    if not rc:
        # Print the supplied error message to screen
        print(f'There was an error retrieving your device\'s serial number: {value}')
        exit(1)

    # Print the device's returned serial number
    print(f'Success! {value}')
except:
    print("Failed to connect to Boltwood CSIII")

Be sure to update "COM1" with whatever serial port identifier your environment requires to communicate with your device.

Finally, execute the script from your command line. Presuming you've got the correct port selected and your device is running with firmware revision 12 or later, you should see your device's serial number printed to the screen:

>>> py example.py
Success! BCS3S24010203

Clone this wiki locally