smartgadget package¶
Communicate with a Sensirion SHTxx Smart Gadget.
- smartgadget.connect(*, host='raspberrypi', rpi_username='pi', rpi_password=None, timeout=10, **kwargs)[source]¶
Connect to the
SHT3XServiceon the Raspberry Pi.- Parameters
host (
str, optional) – The hostname or IP address of the Raspberry Pi.rpi_username (
str, optional) – The username for the Raspberry Pi.rpi_password (
str, optional) – The password for rpi_username.timeout (
float, optional) – The maximum number of seconds to wait for the connection.kwargs – Keyword arguments that are passed to
run_services().
- Returns
SmartGadgetClient– A connection to theSHT3XServiceon the Raspberry Pi.
- smartgadget.kill_manager(*, host='raspberrypi', rpi_username='pi', rpi_password=None, timeout=10, **kwargs)[source]¶
Kill the Network
Manageron the Raspberry Pi.- Parameters
host (
str, optional) – The hostname or IP address of the Raspberry Pi.rpi_username (
str, optional) – The username for the Raspberry Pi.rpi_password (
str, optional) – The password for rpi_username.timeout (
float, optional) – The maximum number of seconds to wait for the connection.kwargs – Keyword arguments that are passed to
connect().
- smartgadget.milliseconds_to_datetime(milliseconds)[source]¶
Convert a timestamp in milliseconds to a
datetime.
- smartgadget.scan(*, interface=0, delegate=None, timeout=10, passive=False)[source]¶
Scan for Bluetooth devices.
This function can only be called if the bluepy package is installed.
- Parameters
interface (
int, optional) – The Bluetooth interface to use (where 0 is /dev/hci0).delegate (DefaultDelegate, optional) – Receives a callback when broadcasts from devices are received.
timeout (
float, optional) – Scan for devices for the given timeout in seconds. During this period, callbacks to the delegate object will be called.passive (
bool, optional) – Use active (to obtain more information when connecting) or passive scanning.
- Returns
A view of ScanEntry objects.
- smartgadget.start_service_on_rpi()[source]¶
Starts the Network
Managerand theSHT3XService.This function should only be called from the
smartgadgetconsole script (see setup.py).