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 SHT3XService on 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 the SHT3XService on the Raspberry Pi.

smartgadget.dewpoint(temperature, humidity)[source]

Calculate the dew point.

Parameters
  • temperature (float) – The temperature [degree C].

  • humidity (float) – The humidity [%RH].

Returns

float – The dew point [degree C].

smartgadget.kill_manager(*, host='raspberrypi', rpi_username='pi', rpi_password=None, timeout=10, **kwargs)[source]

Kill the Network Manager on 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.

Parameters

milliseconds (int) – A timestamp in milliseconds.

Returns

datetime – The milliseconds converted to a datetime object.

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 Manager and the SHT3XService.

This function should only be called from the smartgadget console script (see setup.py).

smartgadget.timestamp_to_milliseconds(obj)[source]

Convert an object into a timestamp in milliseconds.

Parameters

obj – A datetime object, an ISO-8601 formatted str, a float in seconds, or an int in milliseconds.

Returns

int – The timestamp in milliseconds.