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 × Arduino

Read the SharpShot Vision with Arduino in three steps

An Arduino program goes in this order. First wire it up and paste the helper. Then, in setup(), start talking and wait until the SharpShot is ready. Last, in loop(), read values with mbcRead(). Follow the steps on the left, and the program on the right grows with you. In the pretend camera picture you can drag the blob, change its colour and change its size, and see what the Serial Monitor shows.

1

Wire it up and paste the helper

Arduino talks to the sensor over I2C (4 wires). You do not need to install a library. Write 2 lines at the very top and paste a "helper" at the very bottom. Then you can read values with mbcRead() and send commands with mbcWrite().

Which board do you use? (Only the SDA / SCL pins change. The program is the same.)

  1. Unplug the USB cable before wiring. Use the Universal I2C edition (the SPIKE and EV3 editions have different firmware and cannot connect to Arduino).
  2. Sensor VCC → 5V, GND → GND
  3. Sensor SDA → A4, SCL → A5
  4. On the SharpShot connector, IO3 = SDA and IO1 = SCL. The SharpShot must have the I2C firmware: the EV3 and SPIKE editions use the same pins for serial, so it is one or the other.
  5. Set the colours on the SharpShot first: with the screen and buttons on the back, use "Setup 1: COLOR" to pick sample point S1 and "Setup 2: TRACK" to pick the colour to track. The settings are stored on the device. The Arduino only reads the results; a program cannot change them.
  6. Open the Arduino IDE: File → New, and delete what is already there.
  7. Write lines 1 and 2 at the very top. Paste the "helper" at the very bottom (marked ① in the program on the right; "Copy program" copies it too).
2

Start talking and wait until the sensor is ready

setup() runs only once, when the board starts. It opens the serial port, starts I2C and waits until the sensor says "I am ready". ADDR is the sensor's "house number" (its I2C address). You write it every time you read a value.

The sensor's I2C address:

If the sensor is not found:

3

Use a function

To read a value, write "mbcRead(ADDR, id)". To send a command, write "mbcWrite(ADDR, command)". Click a function, and the program and the Serial Monitor change to its example.

Pretend sensor (what the camera sees): drag the blob and watch the Serial Monitor 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 S1 (the spot you picked on the SharpShot in "Setup 1: COLOR"); hue, saturation and brightness are read at the cross. Green box = the blob the SharpShot is tracking (the colour you picked in "Setup 2: TRACK"). X: left 0, right 100. Y: bottom 0, top 75. When the sensor is unplugged, every value the Arduino reads is -32768.

An example for every function

21 functions (values, reading many at once, and the shared ids every MBC sensor has). Each one has a short example. Press "Try it" to jump to step 3. The program and the Serial Monitor on the right change to that example.

Full examples

Press "Copy" to get the whole program (the helper is already at the bottom). Paste it into the Arduino IDE and upload.

What colour is this?

        

!Reads hue, saturation and brightness of sample point S1 (0x01–0x03 in one call) and prints the colour name. When hue is −1 it uses brightness for black / grey / white. It only prints when the colour changes. The limits are in printHueName at the bottom; adjust them for the light where you are.

Where is the blob?

        

!Reads 6 values 0x05–0x0A in one call: X, Y, width, height, area, found. It checks "found" first, then says left / middle / right and bottom / middle / top. Y is bottom = 0, top = 75, the opposite of a computer screen.

Servo follows the blob (SG90, no library)

        

!Fix the SharpShot on the arm of an SG90 servo: blob X 0–100 becomes 20–160 degrees; no blob or no reading goes back to 90 degrees. SG90 brown → GND, red → 5V, orange → pin 9 (ESP32: GPIO 13). If it turns the wrong way, set REVERSE to true. If the servo shakes or the Arduino keeps restarting, USB power is not enough: use a 4–6 V battery and connect its minus to GND too.

Good to know

  1. Unplugging does not stop the program. When the SharpShot cannot be read, mbcRead() gives -32768 (MBC_NONE) and mbcReadMany() gives false. Plug it back in and it works again. Ids the School edition does not have (for example the WRO edition ids 0x10–0x2B) also read -32768. Tick "Unplug the sensor" on the right to see this.
  2. Do not delete delay(2) in the helper. The SharpShot is an ESP32-based slave. It cannot hold the I2C clock while it gets the data ready (no clock stretching), so after writing the id you must wait 2 ms. Without it you read the previous data. The SharpShot needs a few seconds to boot (camera and screen), so mbcWaitReady() waits up to 8 s. Set the Serial Monitor to 115200 baud.
  3. You set the colours on the SharpShot, not in the program. Hue looks at sample point S1 from "Setup 1: COLOR". The blob is the colour you picked in "Setup 2: TRACK". Both are set with the screen and buttons on the back (the SharpShot has no write commands). If you have not done Setup 1, hue is always 0, the same as red, so the program thinks it sees red.
  4. Reading the hue: 0–100 is the hue ring 0–240 scaled down: red 0 (100 is also red), yellow about 17, green about 33, cyan about 50, blue about 67, purple about 83. −1 = black, white or grey (saturation below 10, no colour). Then use 0x03 brightness to tell black, grey and white apart (the full example "What colour is this?" does this).
  5. Check that a blob is found first. When there is no blob, 0x05–0x09 (X, Y, width, height, area) are all 0, which looks like "the blob is in the bottom-left corner". So look at 0x0A first (1 = found). X goes from 0 (left) to 100 (right). Y goes from 0 (bottom) to 75 (top), the opposite of a computer screen. Ids 0x05–0x0A are next to each other, so read them with one mbcReadMany() call and they all come from the same moment (the SharpShot updates every 10 ms).
  6. Motion looks at the whole picture. 0x04 has nothing to do with the colour settings; the more the picture changes, the bigger it is. When the robot itself moves, the whole picture changes, so stop the robot first if you want to detect "someone walking past".