lemariva/micropython-camera-driver

Camera won't initialise

alport opened this issue · 4 comments

Using Thonny, I've successfully installed your latest binary: https://github.com/lemariva/micropython-camera-driver/blob/master/firmware/micropython_camera_feeeb5ea3_esp32_idf4_4.bin
and get the Micropython prompt,

but, I can't seem to get past the simplest test:

import camera
camera.init(0, format=camera.JPEG, fb_location=camera.PSRAM)
Traceback (most recent call last):
File "", line 1, in
OSError: Camera Init Failed

Any pointers please?
Thanks,

Hey! can you please flash the firmware using esptool and connect to the board using VSCode and the PyMakr plugin? The firmware seems to be working by other users e.g. #36 (comment) . Thus, I think the IDE is the problem. You can follow the steps here: https://lemariva.com/blog/2022/01/micropython-upgraded-support-cameras-m5camera-esp32-cam-etc

Same issue here with the AIThinker esp32-cam

import camera
camera.init(0, format=camera.JPEG, fb_location=camera.PSRAM)
Traceback (most recent call last):
File "", line 6, in
OSError: Camera Init Failed

I flashed your firmware this way:

esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 ~/Downloads/micropython_camera_feeeb5ea3_esp32_idf4_4.bin

@aguaviva did you get any solution? Please help me.
Same problem I faced. Please give a solution @lemariva

@lemariva, Also, I flash like @aguaviva and restore it again. but problems are the same.

Yimro commented

Hello, I know this is an old thread, but I have the same problem. After flashing the firmware everything is fine. After a few times initializing and deinitializing, I get error messages.

I have a cheapo-version AI-Thinker ESP32-CAM and installed the @lemariva firmware like this:

esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 micropython_camera_feeeb5ea3_esp32_idf4_4.bin 

When trying to initialize the camera in Thonny, I run:

import camera
camera.init(0, format=camera.JPEG, fb_location=camera.PSRAM)

which is fine for a couple of times, then results results in an error:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
OSError: Camera Init Failed

When running in a terminal, the error description has more useful details:

MicroPython v1.18-74-gfeeeb5ea3 on 2022-02-02; ESP32-cam module (i2s) with ESP32
Type "help()" for more information.
>>> import camera
>>> camera.init(0, format=camera.JPEG, fb_location=camera.PSRAM)
E (17020) gpio: gpio_install_isr_service(449): GPIO isr service already installed
E (17020) camera: Camera probe failed with error 0x103(ESP_ERR_INVALID_STATE)
E (17030) camera: Camera Init Failed
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: Camera Init Failed

Sometimes on trying to camera.init(0, format=camera.JPEG, fb_location=camera.PSRAM), the error messages in the terminal look like this:

E (170) sccb: SCCB_Write Failed addr:0x30, reg:0xff, data:0x01, ret:-1
E (170) camera: Detected camera not supported.
E (170) camera: Camera probe failed with error 0x106(ESP_ERR_NOT_SUPPORTED)

and like this:

E (13290) camera: Camera probe failed with error 0x105(ESP_ERR_NOT_FOUND)

So, different errors. I found out that disconnecting and connecting the ESP32-CAM physically or pressing the "reset" button sometimes resolves this issue in many cases.

Hello, if anyone still faces the issue, here is a solution:
You need to deinit the camera at the end of ever camera usage. Here is a sample code:
`
def take_photo(qualityy):
camera.quality(qualityy) #between 10-63 lower number means higher quality
buf = camera.capture()
return buf

def camera_deinit():
camera.deinit()

`