Legacy edition, no longer supported: SharpShot Vision units shipped before 2026-10 (School and WRO editions) are no longer supported; their guides and examples stay here for reference. To upgrade to the current SharpShot Vision, contact the distributor you bought it from and send it back: the firmware update is free, and the buyer pays shipping both ways. Looking for the current SharpShot Vision? →
MBC SharpShot Vision (ESP32CAM) School edition × EV3 Pybricks

Read the SharpShot Vision on the EV3 with MicroPython in three steps

MicroPython on the EV3 always goes in this order. First import. Then create an object and give the sensor a name. Last, use that name to read values. First pick Pybricks v4 or EV3 MicroPython v2 above. Then follow the steps on the left, and the program on the right grows with you. Drag the blob in the pretend camera picture and change its colour and size to see what the program prints.

Your software:
1

Import the library

The first thing your program does is tell Pybricks: "I want to use the SharpShot Vision library". Without this line, the hub does not know what MBC_CAM_SCHOOL means, and you get a NameError.

Pick one library. Both work the same way. Only the import line is different.

  1. Download the library (save the file and keep its name): MBC_cam_school.py (only this sensor) or MBC_sensors.py (the all-in-one library). You picked MBC_cam_school.py.
  2. Open code.pybricks.com in Chrome. Follow the steps on the site to put the Pybricks firmware on the EV3 (the release version already includes the EV3 firmware).
  3. Press "Import a file" in the file list on the left. Import the library into the same project.
  4. Do not rename the file, and do not put it in a sub-folder.
  5. Go back to your main program. Write the lines below at the very top (marked ① in the program on the right).
2

Create an object: name your sensor

A robot can have several sensors, so you "create an object". It tells the program which port the sensor is on, and gives it a name. Every time you read a value, you use this name.

Which port is the sensor on?

Turn on multitasking?

The 1 in the program is the port number: EV3 1~4 = S1~S4. You can also write Port.S1, but then you also need from pybricks.parameters import Port.

3

Use a function

You always write "cam.function_name()": the name, a dot, then the function. Click a function, and the program and output change to its example.

Pretend sensor (what the camera sees): drag the blob and watch the output on the right

The pretend picture is only a guide: the numbers are simplified, and a real sensor can be a few steps off because of the light. Cross = sample point (the spot you picked on the sensor in "Setup 1: COLOR"); hue, saturation and brightness are read at the cross. Green box = the blob the sensor is tracking (the colour you picked in "Setup 2: TRACK"). X: left 0, right 98. Y: bottom 1, top 75.

An example for every function

Full examples


        

!


        

!


        

!

Good to know

  1. Unplugging works differently in the two programs. Pybricks v4 with the MBC library: when the sensor cannot be read, you get the last value it read (or None if it has never been read). The computer prints one warning line, and the program keeps running. If you unplug while chasing a blob, the robot keeps turning towards the last place it saw it. To check the cable, use sensor_ok(). EV3 MicroPython v2 with Ev3devSensor: you get an OSError and the program stops. Plug it back in and run the program again. Tick "Unplug the sensor" on the right to see both.
  2. Colours are set on the sensor, not in the program. The hue comes from the sample point of "Setup 1: COLOR", and the blob comes from the colour picked in "Setup 2: TRACK". You can only set them with the buttons on the sensor. Without Setup 1 the hue is always 0, the same as red, so the program thinks it sees red.
  3. Check that a blob is found first. When nothing is found, blob X, Y, width, height and area are all 0, which looks like "a blob in the bottom-left corner". So check found() (or blob width = 0) first, then look at the position.
  4. On the EV3 almost everything is mode 1. In the library, hue() to blob_h(), found(), area(), blob_xya() and read_all() all read mode 1, so reading them together is not slower. area() is width × height. The EV3 cannot read device_id() or firmware_version() (SPIKE only).
  5. Directions: standing behind the robot and looking forward, X is left/right with the centre at about 50, so X − 50 is negative on the left and positive on the right. Y is up/down: small at the bottom, big at the top. If left and right are swapped, switch H-Mirror in the camera menu on the sensor. Motion is only accurate when the robot stands still.