Open curtpw opened 5 years ago
have you succeed working with esp32?
Had anyone tried with ESP32 processor?
Does anyone had tried with arducam esp32s?
I have succeeded in getting this to work on ESP32s. There was a few small things that I had to modify, but you also need to understand that there is a limit to how fast you can write to the ESP32 filesystem and also be pulling data out of the FIFO buffer, which ends up delivering an .3-.5 FPS, which is super slow. I am still trying to figure out how to speed the write speeds up.
If you all want I can make a repository on how I achieved this.
That's awesome! If you submit a pull request with the changes I can help get it merged here.
Yeah sure thing I will post it later tonight.
I uploaded the pull request.
I run the code on arducam esp32 but got ETIMEDOUT error. Can you please help me in this regard. Thanks
I run the code on arducam esp32 but got ETIMEDOUT error. Can you please help me in this regard. Thanks
ETIMEDOUT Error is typically given when your ESP32 can not communicate with the arducam. That communication error can be cause by either the pins are not connected securely, causing the camera to not have a connection with the ESP32. Furthermore, if you followed namato's guide for the ESP8266 for the ESP32, it won't work because of the differences in the pins and firmware. Check my forked version for the ESP32 https://github.com/cj667113/micropython-ov2640/.
Also note that the ESP32 needs to be connected to the camera after it boots/reboots but before your code looks for the device. For some reason I am getting boot errors on the dev boards when the camera is not connected at the right time.
@cj667113 Thanks for your reply. I have used the ESP32 version code but getting the error. I dont know how to solve it. Following is the log of error. Kindly help me in this regard.
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4928
ho 0 tail 12 room 4
load:0x40078000,len:9332
load:0x40080400,len:6216
entry 0x400806e8
[0;32mI (433) cpu_start: Pro cpu up.[0m
[0;32mI (433) cpu_start: Application information:[0m
[0;32mI (434) cpu_start: Compile time: 07:44:16[0m
[0;32mI (436) cpu_start: Compile date: May 29 2019[0m
[0;32mI (441) cpu_start: ESP-IDF: v3.3-beta1-268-g5c88c5996[0m
[0;32mI (448) cpu_start: Starting app cpu, entry point is 0x4008294c[0m
[0;32mI (0) cpu_start: App cpu up.[0m
[0;32mI (458) heap_init: Initializing. RAM available for dynamic allocation:[0m
[0;32mI (465) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM[0m
[0;32mI (471) heap_init: At 3FFB9B88 len 00026478 (153 KiB): DRAM[0m
[0;32mI (477) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM[0m
[0;32mI (484) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
[0;32mI (490) heap_init: At 40093398 len 0000CC68 (51 KiB): IRAM[0m
[0;32mI (496) cpu_start: Pro cpu start user code[0m
[0;32mI (67) cpu_start: Starting scheduler on PRO CPU.[0m
[0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m
initializing camera
ov2640_init: devices detected on on i2c:
Traceback (most recent call last):
File "main.py", line 28, in
Actually, I looked at the code, its failing to detect I2C, can you show me your pin configurations?
Thanks for your reply. Attached are pic of configuration
Please guide me in this regard. Thanks
Thanks for your reply. Attached are pic of configuration
Please guide me in this regard. Thanks
You will need to change the pins in the OV2640 python code to reflect the pins that the ESP32-Uno uses. Here is the photo above to what you should change them to. Apparently the ESP32-Uno uses different pins than what I used on my dev board.
Hi, I have resolved the previous error, now I am getting this error rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0018,len:4 load:0x3fff001c,len:4928 ho 0 tail 12 room 4 load:0x40078000,len:9332 load:0x40080400,len:6216 entry 0x400806e8 [0;32mI (433) cpu_start: Pro cpu up.[0m [0;32mI (433) cpu_start: Application information:[0m [0;32mI (433) cpu_start: Compile time: 07:44:16[0m [0;32mI (436) cpu_start: Compile date: May 29 2019[0m [0;32mI (441) cpu_start: ESP-IDF: v3.3-beta1-268-g5c88c5996[0m [0;32mI (447) cpu_start: Starting app cpu, entry point is 0x4008294c[0m [0;32mI (0) cpu_start: App cpu up.[0m [0;32mI (458) heap_init: Initializing. RAM available for dynamic allocation:[0m [0;32mI (465) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM[0m [0;32mI (471) heap_init: At 3FFB9B88 len 00026478 (153 KiB): DRAM[0m [0;32mI (477) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM[0m [0;32mI (483) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m [0;32mI (490) heap_init: At 40093398 len 0000CC68 (51 KiB): IRAM[0m [0;32mI (496) cpu_start: Pro cpu start user code[0m [0;32mI (67) cpu_start: Starting scheduler on PRO CPU.[0m [0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m initializing camera ov2640_init: devices detected on on i2c: ov2640 init: register test return bytes b'00' ov2640_init: register test failed! ov2640_init: device type looks correct, bytes: b'26'/b'42' 72224
It looks like you fixed the I2C read issue, now it is throwing an error at this part.
res = cam_spi_read(b'\x00', self.hspi, self.cspin)
print("ov2640 init: register test return bytes %s" % ubinascii.hexlify(res))
if (res == b'\x55'):
print("ov2640_init: register test successful")
else:
print("ov2640_init: register test failed!")
What this means is that the SPI pins are still not set correctly. Check to ensure these pins are changed in the OV2640.py program. Notice that SDA and SCL do not need to be changed, given that they are the pins that the ESP32-Uno uses.
def __init__(self, sclpin=22, sdapin=21, cspin=15, resolution=OV2640_320x240_JPEG):
self.i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21), freq=1000000)
self.hspi = machine.SPI(1, baudrate=80000000, polarity=0, phase=0,bits=8,sck=machine.Pin(14), mosi=machine.Pin(13), miso=machine.Pin(12))
self.cspin = machine.Pin(15, machine.Pin.OUT)
I checked the datasheet for the ESP32 and the ESP32-Uno. ESP32-Uno uses SPI pins with different ID on their development board. That means that
self.hspi = machine.SPI(1, baudrate=80000000, polarity=0, phase=0,bits=8,sck=machine.Pin(14), mosi=machine.Pin(13), miso=machine.Pin(12))
Needs to be changed to
self.hspi= machine.SPI(2, baudrate=80000000, polarity=0, phase=0, bits=8, firstbit=0, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
This could be found here: https://docs.micropython.org/en/latest/esp32/quickref.html
MIcropython on ESP32 uses the identifier id in machine.SPI (1 or 2) in order to understand what SPI pins you are configuring. I used the default pins (ID=1) where as the manufacturer of the ESP32-Uno decided to use the (ID=2) set.
Thanks for reply. I changed them but it was throwing the previous error so I only used this code
self.hspi = machine.SPI(1, baudrate=80000000, polarity=0, phase=0)
instead of
self.hspi = machine.SPI(1, baudrate=40000000, polarity=0, phase=0,bits=8,sck=machine.Pin(18), mosi=machine.Pin(23), miso=machine.Pin(19))
Kindly help me in this regard. Thanks
Thanks for reply. I changed them but it was throwing the previous error so I only used this code
self.hspi = machine.SPI(1, baudrate=80000000, polarity=0, phase=0)
instead of
self.hspi = machine.SPI(1, baudrate=40000000, polarity=0, phase=0,bits=8,sck=machine.Pin(18), mosi=machine.Pin(23), miso=machine.Pin(19))
Kindly help me in this regard. Thanks
You have to declare your SPI pins, that error is different, but it is not necessarily better.
self.hspi= machine.SPI(2, baudrate=80000000, polarity=0, phase=0, bits=8, firstbit=0, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
Should be what you need to change it too. Also you need to change your CS Pin to pin 17 here: 'def init(self, sclpin=22, sdapin=21, cspin=15, resolution=OV2640_320x240_JPEG):'
and here
self.cspin = machine.Pin(15, machine.Pin.OUT)
Thanks for reply. Yeah I changed it to but then the same error. I do not know how to solve this.
Every pin configuration is according to manual. But if I use this code
self.hspi= machine.SPI(2, baudrate=80000000, polarity=0, phase=0, bits=8, firstbit=0, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
I get "OSerror: invalid configuration"
and if use this code
self.hspi = machine.SPI(1, baudrate=80000000, polarity=0, phase=0)
then the error is register test failed!
So kindly help me.
Interesting. Try this:
self.hspi = machine.SPI(2, baudrate=80000000, polarity=0, phase=0,bits=8,sck=machine.Pin(18), mosi=machine.Pin(23), miso=machine.Pin(19))
Omit the firstbit=0 part.
Thanks for your reply. I tested the above code. So when I did not connect the "mosi" and "miso" I get following output rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0018,len:4 load:0x3fff001c,len:4928 ho 0 tail 12 room 4 load:0x40078000,len:9332 load:0x40080400,len:6216 entry 0x400806e8 [0;32mI (433) cpu_start: Pro cpu up.[0m [0;32mI (433) cpu_start: Application information:[0m [0;32mI (433) cpu_start: Compile time: 07:44:16[0m [0;32mI (436) cpu_start: Compile date: May 29 2019[0m [0;32mI (441) cpu_start: ESP-IDF: v3.3-beta1-268-g5c88c5996[0m [0;32mI (447) cpu_start: Starting app cpu, entry point is 0x4008294c[0m [0;32mI (0) cpu_start: App cpu up.[0m [0;32mI (458) heap_init: Initializing. RAM available for dynamic allocation:[0m [0;32mI (465) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM[0m [0;32mI (471) heap_init: At 3FFB9B88 len 00026478 (153 KiB): DRAM[0m [0;32mI (477) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM[0m [0;32mI (483) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m [0;32mI (490) heap_init: At 40093398 len 0000CC68 (51 KiB): IRAM[0m [0;32mI (496) cpu_start: Pro cpu start user code[0m [0;32mI (67) cpu_start: Starting scheduler on PRO CPU.[0m [0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m initializing camera ov2640_init: devices detected on on i2c: ov2640 init: register test return bytes b'ff' ov2640_init: register test failed! ov2640_init: device type looks correct, bytes: b'26'/b'42' 72176 ov2640_capture: 16777215 bytes in fifo
whereas if I connect the "mosi" and "miso" I get "OSError: [Errno 110] ETIMEDOUT". Kindly help. Thanks
Thanks for your reply. I tested the above code. So when I did not connect the "mosi" and "miso" I get following output rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0018,len:4 load:0x3fff001c,len:4928 ho 0 tail 12 room 4 load:0x40078000,len:9332 load:0x40080400,len:6216 entry 0x400806e8 �[0;32mI (433) cpu_start: Pro cpu up.�[0m �[0;32mI (433) cpu_start: Application information:�[0m �[0;32mI (433) cpu_start: Compile time: 07:44:16�[0m �[0;32mI (436) cpu_start: Compile date: May 29 2019�[0m �[0;32mI (441) cpu_start: ESP-IDF: v3.3-beta1-268-g5c88c5996�[0m �[0;32mI (447) cpu_start: Starting app cpu, entry point is 0x4008294c�[0m �[0;32mI (0) cpu_start: App cpu up.�[0m �[0;32mI (458) heap_init: Initializing. RAM available for dynamic allocation:�[0m �[0;32mI (465) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM�[0m �[0;32mI (471) heap_init: At 3FFB9B88 len 00026478 (153 KiB): DRAM�[0m �[0;32mI (477) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM�[0m �[0;32mI (483) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM�[0m �[0;32mI (490) heap_init: At 40093398 len 0000CC68 (51 KiB): IRAM�[0m �[0;32mI (496) cpu_start: Pro cpu start user code�[0m �[0;32mI (67) cpu_start: Starting scheduler on PRO CPU.�[0m �[0;32mI (0) cpu_start: Starting scheduler on APP CPU.�[0m initializing camera ov2640_init: devices detected on on i2c: ov2640 init: register test return bytes b'ff' ov2640_init: register test failed! ov2640_init: device type looks correct, bytes: b'26'/b'42' 72176 ov2640_capture: 16777215 bytes in fifo
whereas if I connect the "mosi" and "miso" I get "OSError: [Errno 110] ETIMEDOUT". Kindly help. Thanks
What version of micropython are you currently running? I am going to try and build it out on the same pins on my dev board.
Also give me your edited OV2640.py
Using this version of micropython esp32-20190529-v1.11.bin. ov2640.zip
Using this version of micropython esp32-20190529-v1.11.bin. ov2640.zip
Okay, I will build it out on my ESP32 with the pins that your dev board and share it with you once I get it working.
okay thanks a lot
Hi, Saw the discussion and it made me to think and ask if any thing can be used even in my project. Actually I have Pycom Lopy4 node the Lopy4 node has the ESP32 processor. I am intending to capture very low resolution image using the OV7670 camera and stuck with the micropython code to develop. Actually I bit of a new to the micropython programming.
Having a thought that since the Lopy4 also has ESP32 processor, if any one can advise me if it is possible even for the lopy4 to use your code to capture the image. Your kind advice will be of great help to me. Thank you.
Hi, Saw the discussion and it made me to think and ask if any thing can be used even in my project. Actually I have Pycom Lopy4 node the Lopy4 node has the ESP32 processor. I am intending to capture very low resolution image using the OV7670 camera and stuck with the micropython code to develop. Actually I bit of a new to the micropython programming.
Having a thought that since the Lopy4 also has ESP32 processor, if any one can advise me if it is possible even for the lopy4 to use your code to capture the image. Your kind advice will be of great help to me. Thank you.
The OV7670 is a different camera all together. This code was built to use the OV2640, specifically the OV2640 with the FIFO buffer, so most likely you would have to rework the code a lot.
There has been some success with the ESP32 with the OV7670 but I don't know anything about it: https://bitluni.net/esp32-i2s-camera-ov7670 https://github.com/desaster/ov7670test
Using this version of micropython esp32-20190529-v1.11.bin. ov2640.zip
Okay, I will build it out on my ESP32 with the pins that your dev board and share it with you once I get it working.
Any news here?
Did you ever figure out the SPI issue @cj667113?
This worked for me to solve the VSPI(2) issue. The board that I used was NodeMCU ESP-WROOM-32.
self.hspi=machine.SPI(2, baudrate=80000000, polarity=0, phase=0, bits=8, firstbit=0, sck=machine.Pin(18), mosi=machine.Pin(23), miso=machine.Pin(19))
Awesome! @cj667113 I got it working for my Pycom GPy and forked your file. Did you get it working for larger photos?
You can get it to work with larger photos, just expect a much lower framerate.
I am having trouble with over exposure when outside. Even when using an IR filter. Is there a way to set auto exposure?
Not that I am aware of. I don't have much knowledge on the module/camera, I just adapted the pins settings to get it to work on the ESP32.
Hello, I am trying to use this code, but I keep getting a memory allocation error, when I try to run it the following happens:
initializing camera
Warning: I2C(-1, ...) is deprecated, use SoftI2C(...) instead
ov2640_init: devices detected on on i2c:
ov2640 init: register test return bytes b'55'
ov2640_init: register test successful
ov2640_init: device type looks correct, bytes: b'26'/b'42'
63344
ov2640_capture: 3080 bytes in fifo
Traceback (most recent call last):
File "main.py", line 28, in
I'm not really sure how to fix this so any help would be appreciated.
Will this work with the ESP32?