Arduino icon indicating copy to clipboard operation
Arduino copied to clipboard

error: ‘i2c_smbus_write_word_data’ was not declared in this scope

Open thaiwash opened this issue 4 years ago • 31 comments

I tried to raspberry this, and i went to ArduCAM/examples/RaspberryPi and typed make

g++ -std=c++0x -I./ -I../../../ArduCAM -c arducam_arch_raspberrypi.c arducam_arch_raspberrypi.c: In function ‘uint8_t arducam_i2c_word_write(uint16_t, uint8_t)’: arducam_arch_raspberrypi.c:125:3: error: ‘i2c_smbus_write_word_data’ was not declared in this scope i2c_smbus_write_word_data(FD, reg_H, value); ^~~~~~~~~~~~~~~~~~~~~~~~~ arducam_arch_raspberrypi.c:125:3: note: suggested alternative: ‘i2c_smbus_ioctl_data’ i2c_smbus_write_word_data(FD, reg_H, value); ^~~~~~~~~~~~~~~~~~~~~~~~~ i2c_smbus_ioctl_data arducam_arch_raspberrypi.c: In function ‘uint8_t arducam_i2c_word_read(uint16_t, uint8_t*)’: arducam_arch_raspberrypi.c:140:7: error: ‘i2c_smbus_write_byte_data’ was not declared in this scope r = i2c_smbus_write_byte_data(FD,reg_H,reg_L); ^~~~~~~~~~~~~~~~~~~~~~~~~ arducam_arch_raspberrypi.c:140:7: note: suggested alternative: ‘i2c_smbus_ioctl_data’ r = i2c_smbus_write_byte_data(FD,reg_H,reg_L); ^~~~~~~~~~~~~~~~~~~~~~~~~ i2c_smbus_ioctl_data arducam_arch_raspberrypi.c:143:13: error: ‘i2c_smbus_read_byte’ was not declared in this scope *regDat = i2c_smbus_read_byte(FD); ^~~~~~~~~~~~~~~~~~~ arducam_arch_raspberrypi.c:143:13: note: suggested alternative: ‘i2c_smbus_data’ *regDat = i2c_smbus_read_byte(FD); ^~~~~~~~~~~~~~~~~~~ i2c_smbus_data

thaiwash avatar Apr 13 '20 17:04 thaiwash

I added #include <smbus.h>

to arducam_arch_raspberrypi.c

and copypasted the content of the .c file from https://stackoverflow.com/questions/14268530/linking-smbus-c-to-smbus-h (I know, hackish)

I got it compiling!

now I need to figure out how to plug the pins, I know how to wire 4 wires now, 3.3v, gnd and SCL and SCK

running: sudo ./ov2640_capture -c test.jpg 320x240 I get: Unable to open I2C device: No such file or directory

thaiwash avatar Apr 13 '20 19:04 thaiwash

Hi, You may not turned on the I2C device, so you can try this link.

ArducamSupport avatar Apr 14 '20 00:04 ArducamSupport

I have i2c working since i can run my gyro no poblem. I'm using only 4 pins right now, 3.3v, gnd and sck sda its not even detecting the camera with i2cdetect -y 1

thaiwash avatar Apr 14 '20 18:04 thaiwash

Perhaps you have a problem with the I2C method, I suggest you refer to our example on raspberry pi. Link

ArducamSupport avatar Apr 15 '20 01:04 ArducamSupport

Perhaps you have a problem with the I2C method, I suggest you refer to our example on raspberry pi. Link

Okay, i'll try that, what about the pin configurations, is having only sda and sck okay for spi?

thaiwash avatar Apr 15 '20 08:04 thaiwash

The I2C pins of the camera are SCL and SDA. The SPI pins are CS、MOSI、MISO and SCK, is your I2C clock using SCK?

ArducamSupport avatar Apr 15 '20 08:04 ArducamSupport

no, its using SCL

thaiwash avatar Apr 15 '20 08:04 thaiwash

So, I wire up both I2C and SPI before running the program?

thaiwash avatar Apr 15 '20 08:04 thaiwash

https://pinout.xyz/pinout/spi#

thaiwash avatar Apr 15 '20 09:04 thaiwash

so, pins are BCM9 = 21 (MISO) BCM10 = 19 (MOSI) BCM11 = 23 (SCLK) BCM0 = 27 (SPI0)

I'm going to wire up SPI only.

thaiwash avatar Apr 15 '20 09:04 thaiwash

so, pins are BCM9 = 21 (MISO) BCM10 = 19 (MOSI) BCM11 = 23 (SCLK) BCM0 = 27 (SPI0)

I'm going to wire up SPI only.

BCM0 is not used, please wire the CS to BCM17. You could see the README.

ArducamSupport avatar Apr 15 '20 09:04 ArducamSupport

This is from the readme,

//SPI pins //set 9 (MISO), 10 (MOSI), 11 (SCLK) alt fxn 0 (SPI0)

I dont know what alt fxn means thoough..

thaiwash avatar Apr 15 '20 09:04 thaiwash

Sorry for the readme mislead you. Just ignore the alt fxn (SPI0), which just want to tell you to use SPI0.

UCTRONICS avatar Apr 15 '20 10:04 UCTRONICS

dgram2 Lets draw a picture here, where is MISO MOSI SCLK and SPI0 on the camera?

thaiwash avatar Apr 15 '20 10:04 thaiwash

The ArduCAM/RaspberryPi/SPI_Camera/ is used for the specified camera, as shown in the following figure, for reference: https://www.arducam.com/product/arducam-2mp-spi-camera-b0067-arduino/ Not the parallel camera in your picture. image

ArducamSupport avatar Apr 16 '20 00:04 ArducamSupport

I have the same question at first。finally ,I can compile it. but when I run the command line sudo ./ov5642_capture -c test.jpg 320x240 I get the result as below

OV5642 detected. Changed resolution1 to 320x240 Start capture CAM Capture Done Reading FIFO and saving IMG The length is 2792

but ,the size of picture is 0

WHY?

phymatld avatar Aug 08 '20 11:08 phymatld

Hi, We noticed that there is no clearing FIFO in your output. Please clear FIFO before you start capture. In addition, you can print the data read from FIFO to the terminal. If the data is jpeg data, then there may be a problem with the way you save the image.

ArducamSupport avatar Aug 09 '20 02:08 ArducamSupport

thanks .but how to clear FIFO? in fact ,I bought a ARDUCAM OV5642 and raspberry pi 4B ,I want to use the camera to take some photo or video.but I didn`t find any tutorial to do that ,so I use this lib to try

phymatld avatar Aug 09 '20 03:08 phymatld

Are you using SPI camera on Raspberry Pi? If yes, please refer to https://github.com/ArduCAM/RaspberryPi/tree/master/SPI_Camera

ArducamSupport avatar Aug 09 '20 03:08 ArducamSupport

of cause I try it before . but when run the command line sudo ./run_Arducam_Demo But I can't get any results, and the program won't report an error.

phymatld avatar Aug 09 '20 04:08 phymatld

Hi, For PI4, please execute the following command to update the wiringpi library. image

Then you need to make the following changes in bcm283_board_driver.h: image

Finally, recompile and execute.

ArducamSupport avatar Aug 10 '20 03:08 ArducamSupport

image

according to your advise,I install the latest version of wiringpi,and change the bcm283_board_driver.h file But there's a problem.

image I connect the ARDUCAM ov5642 and pi4 according tothe picture。 image

phymatld avatar Aug 10 '20 03:08 phymatld

Hi, Please refer to this connection. image

ArducamSupport avatar Aug 10 '20 04:08 ArducamSupport

image finally,it works! but,my mobile can not connect to the camera, I have check the IP and port 。 my mobile status is always connecting...

phymatld avatar Aug 10 '20 05:08 phymatld

image

image

here is the screenshot

phymatld avatar Aug 10 '20 05:08 phymatld

Hi, Due to our negligence, there is a problem with the latest version code. Please use the code of this version. The part that needs to be modified has been explained in the reply above. https://github.com/ArduCAM/RaspberryPi/tree/9ebf547e2795f81835d0490a957aaad6e70e6595/SPI_Camera

1597052872793

ArducamSupport avatar Aug 10 '20 09:08 ArducamSupport

I am sorry but I really know how to download this version of demo. can you show me the command?

phymatld avatar Aug 10 '20 10:08 phymatld

thanks for your help. I can use it now . but I still have a question ,can I use it only by mobile? can I save photoes on raspberry derecctly?

phymatld avatar Aug 11 '20 00:08 phymatld

Hi,

You can save images directly to the Raspberry Pi, but there is no example of directly saving images on our Raspberry Pi. We suggest you refer to the Raspberry Pi code and the Arduino version code for testing. We are very busy lately, sorry for not being able to write a detailed example for you.

ArducamSupport avatar Aug 11 '20 01:08 ArducamSupport

in fact, I got the code by git clone https://github.com/ArduCAM/Arduino.git I told you that I capture a photo but the size is zero now ,I change the connection according to the picture you show ,now I got a error show as below

SPI interface error!

phymatld avatar Aug 11 '20 01:08 phymatld