Example Code for MicroPython-Camera Photo Capture
Last revision 2026/01/22
This example demonstrates how to take photos with the ESP32-P4 and save them to the device.
Hardware Preparation
Software Preparation
Sample Code
import camera, time, jpeg
camera.init()
time.sleep(5)
img = camera.capture() # Returns image data in bytes
camera.deinit()
with open("capture.jpg", "wb") as f:
f.write(img)
print("JPEG encoding completed")
Result

Was this article helpful?
