hub

The hub package is home to all of the modules used to interact with various integrated inputs (gyroscope, buttons) and outputs (lights, sound) on a Spike Hub (e.g. LEGO parts 45601 or 45609). This package also contains the hub module with several direct functions used to interrogate and control the hub itself.

To use the hub module itself, add the following import statement to your project:

import hub

All functions in the module should be called inside the hub module as a prefix like so:

t = hub.temperature()

NOTE: The hub module contains a number of functions that are not documented in the official LEGO materials. These are marked as UNDOCUMENTED in the function descriptions below. Their behavior has been determined empirically and they should be used with caution.

Functions

battery_current()

UNDOCUMENTED Get the battery current.

battery_temperature()

UNDOCUMENTED Get the battery temperature.

battery_voltage()

UNDOCUMENTED Get the battery voltage.

bootloader()

UNDOCUMENTED Result currently unclear: don't use in code unless you know what you are doing.

device_uuid()

Get the device id.

hardware_id()

Get the hardware id.

power_off()

Turn off the hub.

reset()

UNDOCUMENTED Send a hard reset command to the hub.

soft_reset()

UNDOCUMENTED Send a soft reset command to the hub.

temperature()

Get the hub temperature measured in decidegrees Celsius (d°C), which is 1/10 of a degree Celsius (°C).

usb_charge_current()

UNDOCUMENTED Get the USB charge current.

hub.battery_current()

UNDOCUMENTED Get the battery current.

Return type:

int

hub.battery_temperature()

UNDOCUMENTED Get the battery temperature.

Return type:

int

hub.battery_voltage()

UNDOCUMENTED Get the battery voltage.

Return type:

int

hub.bootloader()

UNDOCUMENTED Result currently unclear: don’t use in code unless you know what you are doing.

Return type:

int

hub.device_uuid()

Get the device id.

Return type:

str

hub.hardware_id()

Get the hardware id.

Return type:

str

hub.power_off()

Turn off the hub.

Return type:

int

hub.reset()

UNDOCUMENTED Send a hard reset command to the hub.

Return type:

int

hub.soft_reset()

UNDOCUMENTED Send a soft reset command to the hub.

Return type:

int

hub.temperature()

Get the hub temperature measured in decidegrees Celsius (d°C), which is 1/10 of a degree Celsius (°C).

Return type:

int

hub.usb_charge_current()

UNDOCUMENTED Get the USB charge current.

Return type:

int