Stereo Camera Hat not detected on RasPi 4B I2C bus

1.Which seller did you purchase the product(s) from?
UCTRONICS

2.The Model number of the product(s) you have purchased?
https://www.uctronics.com/camera-modules/camera-for-raspberry-pi/arducam-1mp-2-stereoscopic-camera-bundle-kit-for-raspberry-pi-nvidia-jetson-nano-xavier-nx-two-ov9281-global-shutter-monochrome-camera-modules-and-camarray-stereo-camera-hat.html

3.Which Platform are you using the product(s) on?
Raspberry Pi 4B 8 GB

4.Which instruction are you following?
https://www.arducam.com/docs/cameras-for-raspberry-pi/synchronized-stereo-camera-hat/camarry-1mp2-stereoscopic-camera-hat/

5.Has your product ever worked properly?
I2C communication has never worked

6.What problems are you experiencing?

My stereo cameras work but I cannot switch mode with i2cset -y 0 0x24 0x24 <mode> due to this error:

Error: Write failed

I enabled I2C by editing /boot/config.txt and restarting:

dtparam=i2c_vc=on

I tried plugging in the stereo board as a hat, and with a separate cable to ensure 5V, 3.3V, GND, SDA and SCL are all plugged in to matching pins, but it made no difference. I also removed and re-inserted the ribbon a few times.

I2C detect for bus 0 (i2cdetect -y 0) returns this:

0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- UU -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- <code></code>

If I try to write to 0C it says driver busy. What should I do next?

7.What attempts at troubleshooting have you already made?
Enabling I2C, scanning I2C ports, looking at I2C waveforms in oscilloscope, checking voltages on all pins with osc and meter

8.How would you like us to help you?
Help me get communication working with the hat over I2C so I can switch modes

Hello,

Recently I am keeping on optimizing MIPI_Camera library and have released a new version which supports auto detected hat. Please download the latest driver to try

https://github.com/ArduCAM/MIPI_Camera/tree/master/RPI

https://github.com/ArduCAM/MIPI_Camera/blob/master/RPI/README.md

 

Feel free to let me know if you need more help.

Hello, I went through the whole readme, and noticed that output from ./camera_i2c is to be sent for troubleshooting. Here’s what I got:

setting GPIO for board revsion: d03114 Raspberry Pi3B / Pi3B+ / 3A / 4B(1G/2G/4G) Set state of 133 to 1 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- UU -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- -- <code></code>

You mentioned that I should install the latest driver following instructions in that readme. I don’t see any instructions for driver installation, but I installed and built the SDK:

make install
sudo install -m 644 lib/libarducam_mipicamera.so /usr/lib/
cd /tmp
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
chmod +x enable_i2c_vc.sh
./enable_i2c_vc.sh

…back to MIPI_Camera

make clean && make

Lastly, I found the utility called read_write_sensor_reg, and it freezes after the following output (has to be terminated):

Found arducam_isp_camera at address 0C

If I missed any steps like installing the updated driver, can you point to the steps for that? Thank you.

Going through all of the source files, I also found capture-dualcam which appears to fail:

Open camera... init camera status = 4100 Open camera... init camera status = 4100 <code></code>

I know this is obvious, but pinout returns:


   3V3  (1) (2)  5V    
 GPIO2  (3) (4)  5V    
 GPIO3  (5) (6)  GND   
 GPIO4  (7) (8)  GPIO14
   GND  (9) (10) GPIO15
GPIO17 (11) (12) GPIO18
GPIO27 (13) (14) GND   
GPIO22 (15) (16) GPIO23
   3V3 (17) (18) GPIO24
GPIO10 (19) (20) GND   
 GPIO9 (21) (22) GPIO25
GPIO11 (23) (24) GPIO8 
   GND (25) (26) GPIO7 
 GPIO0 (27) (28) GPIO1 
 GPIO5 (29) (30) GND   
 GPIO6 (31) (32) GPIO12
GPIO13 (33) (34) GND   
GPIO19 (35) (36) GPIO16
GPIO26 (37) (38) GPIO20
   GND (39) (40) GPIO21

I see see in the code in capture-dualcam.c does this:


struct camera_interface cam_interface = {
        .i2c_bus = 0,           // /dev/i2c-0  or /dev/i2c-1   
        .camera_num = camera_num,        // mipi interface num
        .sda_pins = {28, 0},    // enable sda_pins[camera_num], disable sda_pins[camera_num ? 0 : 1]
        .scl_pins = {29, 1},    // enable scl_pins[camera_num], disable scl_pins[camera_num ? 0 : 1]
        .led_pins = {30, 2},
        .shutdown_pins ={31, 3},
    };

Those are not the pins used for SDA and SCL, it’s GPIO2 = SDA and GPIO3 = SCL.

Hello,

I have tested it and fix a bug. Now it can work normally. Please download our new demo to try.

Feel free to let me know if you need more help.

Hello, my original question was mode switching not working - switching between left camera, right camera, and both by using i2cset. I am looking at all the code in your repo because I don’t know what else to do, since your I2C interface does not seem to work. The error message is the same when attempting to switch mode using I2C:

Error: Write failed

I tried the following:

i2cset -y 0 0x24 0x24 0x00
i2cset -y 0 0x24 0x24 0x01
i2cset -y 0 0x24 0x24 0x02

All result in the same error message. If I use 0x0C as an address instead of 0x24, I get this:

Error: Could not set address to 0x0c: Device or resource busy

I don’t necessarily need this to work by using i2cset, I’m OK with modifying one of your executables that capture images, however all instructions you have are for using i2cset.

Oh, I just noticed arducamstill no longer works. The previous command line that used to capture an image no longer captures anything, and the program hangs (does not quit) and has to be terminated.


arducamstill -t 0 -pixfmt GREY -w 2560 -h 800
Hardare version: d03114
No match to hardware version!
Device /dev/video0) opened.
GREY
Video format set: GREY (59455247) 2560x800
^C

I did git reset --hard and re-built everything, and arducamstill is back to working. I see you checked in a change to x64 binary after my last test, maybe that did it.

Let me re-iterate my issue for this thread, and please let me know how to solve this:

I would like to change Arducam mode so that I can capture images from the left camera separately from the right camera. I followed your guide for doing this using i2cset command and it’s not working. What should I do?

Thank you.

Hi,

Sorry for my late reply, Recently I have optimized our mipi_camera library and please download our latest version to test.

Feel free to let me know if you need more help.

@01binary @lvbin

I have the same problem, I have the stereo hat (UC-512) and I can run the stereo_depth_demo 1_test.py:

pi@roverpi:~/MIPI_Camera/RPI/stereo_depth_demo $ python3 1_test.py 
Open camera...
Found sensor imx219 at address 10
mode: 7, width: 1600, height: 600
mode: 8, width: 2560, height: 720
mode: 9, width: 3840, height: 1080
mode: 10, width: 5184, height: 1944
mode: 11, width: 6528, height: 1848
mode: 12, width: 6528, height: 2464
Please enter the mode number:7
mmal: Failed to fix lens shading, use the default mode!
The stereo hat firmware version: 5.1 2020/10/15
Current mode: 7,resolution: 1600x600
Enable Auto Exposure...
Enable Auto White Balance...

(I added the exposure+AWB manually because the images were much too dark).
But I cannot see anything on the i2c bus at all:

pi@roverpi:~/MIPI_Camera/RPI/utils $ ./camera_i2c 
setting GPIO for board revsion: d03114
Raspberry Pi3B / Pi3B+ / 3A / 4B(1G/2G/4G)
Set state of 133 to 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

pi@roverpi:~/MIPI_Camera/RPI/stereo_depth_demo $ i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

My PI is a brand new 8GB 4B. The MIPI git was cloned yesterday (Jan 15th 2022).
I tried with and without the wiringpi-latest.deb.
config.txt contains the necessary paramers and I’ve rebooted since:

pi@roverpi:~/MIPI_Camera/RPI/stereo_depth_demo $ grep i2c /boot/config.txt 
dtparam=i2c_arm=on
dtparam=i2c_vc=on

I also want to switch camera modes left/right/both using:

$ i2cset -y 0 0x24 0x24 0x01
Error: Write failed

I appreciate any help. Thank you!

Meanwhile I found out some more: Apparently my Pi4 has more i2c busses than only 0+1:

pi@roverpi:~ $ i2cdetect -l
i2c-1	i2c       	bcm2835 (i2c@7e804000)          	I2C adapter
i2c-22	i2c       	bcm2835 (i2c@7e205000)          	I2C adapter
i2c-0	i2c       	i2c-22-mux (chan_id 0)          	I2C adapter
i2c-10	i2c       	i2c-22-mux (chan_id 1)          	I2C adapter
pi@roverpi:~ $ i2cdetect -y 10
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- 24 -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- 64 -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

And now I finally see something reacting on Bus 0x0A (=10).

And now I can finally write to it and switch cameras:

pi@roverpi:~ $ i2cset -y 10 0x24 0x24 1
1 Like

Thanks, that was helpful! I faced the same issue.