Note

Hello, welcome to the SunFounder Raspberry Pi & Arduino & ESP32 Enthusiasts Community on Facebook! Dive deeper into Raspberry Pi, Arduino, and ESP32 with fellow enthusiasts.

Why Join?

  • Expert Support: Solve post-sale issues and technical challenges with help from our community and team.

  • Learn & Share: Exchange tips and tutorials to enhance your skills.

  • Exclusive Previews: Get early access to new product announcements and sneak peeks.

  • Special Discounts: Enjoy exclusive discounts on our newest products.

  • Festive Promotions and Giveaways: Take part in giveaways and holiday promotions.

👉 Ready to explore and create with us? Click [here] and join today!

module utils

robot_hat.utils.set_volume(value)

Set volume

Parameters:

value (int) – volume(0~100)

robot_hat.utils.run_command(cmd)

Run command and return status and output

Parameters:

cmd (str) – command to run

Returns:

status, output

Return type:

tuple

robot_hat.utils.is_installed(cmd)

Check if command is installed

Parameters:

cmd (str) – command to check

Returns:

True if installed

Return type:

bool

robot_hat.utils.mapping(x, in_min, in_max, out_min, out_max)

Map value from one range to another range

Parameters:
  • x (float/int) – value to map

  • in_min (float/int) – input minimum

  • in_max (float/int) – input maximum

  • out_min (float/int) – output minimum

  • out_max (float/int) – output maximum

Returns:

mapped value

Return type:

float/int

robot_hat.utils.get_ip(ifaces=['wlan0', 'eth0'])

Get IP address

Parameters:

ifaces (list) – interfaces to check

Returns:

IP address or False if not found

Return type:

str/False

robot_hat.utils.reset_mcu()

Reset mcu on Robot Hat.

This is helpful if the mcu somehow stuck in a I2C data transfer loop, and Raspberry Pi getting IOError while Reading ADC, manipulating PWM, etc.

robot_hat.utils.get_battery_voltage()

Get battery voltage

Returns:

battery voltage(V)

Return type:

float

robot_hat.utils.enable_speaker()

Enable speaker

robot_hat.utils.disable_speaker()

Disable speaker