The LEGO® MINDSTORMS® EV3 brick is at the core of the pyev3 package. Once the brick is powered up, you can use a PC to communicte with it in two ways:

  • USB (fastest)

    • requires a USB cable (that comes with the set)

    • very repeatable command/reply round-trip times of approx. 5 ms

  • WiFi (free to move around!)

    • requires a WiFi dongle (purchased separately)

    • not very repeatable command/reply round-trip times between 10 to 20 ms

class brick.LegoEV3(commtype='usb', IPaddress=None, deviceID=None)[source]

The class to represent the LEGO EV3 brick. You can use LegoEV3 to interact with the EV3 brick.

Set up USB connection between host and EV3 brick.

>>> from pyev3.brick import LegoEV3
>>> myev3 = LegoEV3(commtype='usb')
>>> myev3.display_info()
>>> myev3.close()

Set up WiFi connection between host and EV3 brick

>>> myev3 = LegoEV3(commtype='wifi', IPaddress='', deviceID='001653470e58')
>>> myev3.display_info()
>>> myev3.close()
  • commtype (str) – The type of communication with the brick. 'usb' or 'wifi'.

  • IPaddress (str) – The IP address assigned to the EV3 brick.

  • deviceID (str) – The individual device ID of the EV3 brick. Connect to the brick using commtype=’usb’ and use the display_info() method to retrieve the ID of the brick.


  1. Always use the close() method before opening a new connection.

  2. Try a USB connection first. It’s easier to set up and faster.


Close the EV3 brick connection.

>>> myev3.close()

Displays a summary with the brick information.

play_tone(volume=10, frequency=440, duration=1)[source]

Play a tone on the EV3 brick.

  • volume (int) – The volume of the played tone: 0 to 100

  • frequency (int) – The frequency (Hz) of the played tone: 0 to 10000

  • duration (float) – The duration (s) of the played tone: 0 to 5

>>> myev3.play_tone(volume=5, frequency=880, duration=0.5)
set_statuslight(mode='solid', color='green')[source]

Set the status light of the EV3 brick.

  • mode (str) – The light mode: 'solid', 'pulsing', 'off'

  • color (str) – The light color: 'green', 'orange', 'red'

>>> myev3.set_statuslight(mode='pulsing', color='orange')
property batterylevel

Contains the EV3 battery level in % (read only).

property connectedsensors

Contains a list with the sensors connected to the EV3 (read only).

property devmode

Contains a developer mode flag. Default is False. When True, communication info is displayed after each direct command (read/write).