MBC SharpShot Vision × LEGO SPIKE App (Python)
Read SharpShot Vision with SPIKE App Python in three steps
The LEGO SPIKE App (Education) runs Python too, with no firmware change. In the App, SharpShot Vision is a color sensor, and the App cannot import your own files, so the order is: first paste the reading helper at the top and pick the camera mode, then create an object and name the camera, then call update() once per loop and call its functions with that name. Work down the steps on the left and watch the program grow on the right; drag the blobs, papers, blocks or line in the simulated camera view to see what the program prints.
Verified on SPIKE hardwareRun on real hubs on 2026-11-01 with shipping firmware v1.0-261101 (Pybricks library and blocks, Pybricks built-in blocks, the official app Education and home edition, MBC Blocks website).
Bytes 8–15: values the helper cannot read
The camera sends 16 bytes each time. The App's color_sensor.color(), reflection() and rgbi() only get the first 8, which is what the helper uses. On real hubs (2026-11-01), App Python's device.data(port.C) returns 8 values: byte 0, byte 1, then one int16 per 2 bytes (raw red, green, blue, bytes 8–9, 10–11, 12–13), so bytes 8–13 can be read and bytes 14–15 cannot. The helper does not use it; to get the values below, split them yourself as shown at the bottom, or switch to Pybricks MicroPython (same camera, same firmware; with the Pybricks firmware on the hub everything can be read). Full layouts are in the value reference.
| Mode | In bytes 8–15 (not read by the helper) |
| 11Color tracking ① Max colors | color 8–14 X×10 + Y (8×6 grid, top = small) |
| 12Color tracking ② Multi-color | color 1–7 count |
| 13Color tracking ③ Standard | color 1–4 count, color 1–4 area (% of picture) |
| 14Color tracking ④ Fine | color 1–2 count, color 1–2 area (% of picture) |
| 21Color at points ① Hue | S7–14 hue |
| 22Color at points ② Hue + saturation | S4–5 hue, S5 saturation, S6 hue, S6 saturation, S7 hue, S7 saturation |
| 23Color at points ③ Hue + sat + value | S2–3 value, S4 hue, S4 saturation, S4 value |
| 30Color order | block 7–13 from the left, hue |
| 41Line ① Black line | mid offset (+100), line flags (near 1 + mid 2 + far 4), junction distance %, colored marker line color, marker line count, far line width %, near line left edge (+100), near line right edge (+100) |
| 42Line ② White line | mid offset (+100), line flags (near 1 + mid 2 + far 4), junction distance %, colored marker line color, marker line count, far line width %, near line left edge (+100), near line right edge (+100) |
| 43Line ③ Colored line | mid offset (+100), line flags (near 1 + mid 2 + far 4), junction distance %, colored marker line color, marker line count, far line width %, near line left edge (+100), near line right edge (+100) |
| 51Objects ① Object list | object 4 code (color × 10 + shape), object 4 X×10 + Y (8×6 grid, top = small), object 5 code (color × 10 + shape), object 5 X×10 + Y (8×6 grid, top = small), object 6 code (color × 10 + shape), object 6 X×10 + Y (8×6 grid, top = small), object 7 code (color × 10 + shape), object 7 X×10 + Y (8×6 grid, top = small) |
| 52Objects ② Object details | object 1 angle, object 2 X (pixels), object 2 Y (pixels, top = small), object 2 width (pixels), object 2 height (pixels), object 2 angle, object 1 vertex count, object count |
Splitting bytes 8–13 with device.data() (each int16: low byte = the first byte, high byte = the second):
import device
from hub import port
import runloop
async def main():
while True:
d = device.data(port.C) # 8 values: byte 0, byte 1, raw red, green, blue, bytes 8-9, 10-11, 12-13
b8, b9 = d[5] & 255, (d[5] >> 8) & 255
b10, b11 = d[6] & 255, (d[6] >> 8) & 255
b12, b13 = d[7] & 255, (d[7] >> 8) & 255
print(d[0], b8, b9, b10, b11, b12, b13) # d[0] = the raw "color" slot (5 stays 5)
await runloop.sleep_ms(500)
runloop.run(main())