kashimAstro / ofxGPIO

Library C++ for raspberrypi and orangepi, GPIO interfaces compatible with openframeworks.
MIT License
191 stars 44 forks source link

12c examples #19

Open fred-dev opened 6 years ago

fred-dev commented 6 years ago

Hi, there are some errors in the 12C examples, for the I2C scanner the OF version is actually without OF and throws, no rule to make target run

The straight 12c examples bails on the make.

I am trying to use an LIS3DH adafruit accelerometer, but I want to check the connection first...

kashimAstro commented 6 years ago

an anomaly has been reported to me with i2c on debian stretch.

what operating system are you working on? you can pass me a: uname -a ?

now i'm traveling, in a few days i go back to the laboratory and try to understand the problem!

thanks!

fred-dev commented 6 years ago

Hey, I get this: Linux raspberrypi 4.14.30-v7+ #1102 SMP Mon Mar 26 16:45:49 BST 2018 armv7l GNU/Linux I am also trying to get SPI for an MCP3008, I don't manage to get any input (I have used the chip before). In the meantime can you recommend a version of OF and the stretch/or previous OS for linux that will function?

kashimAstro commented 6 years ago

Hi @fred-dev ,

I just fixed the examples for the i2c bus scanner, now you should see the addresses on the bus!

the example for the openframeworks scanner wired the path to the device: /dev/i2c-1 in the code you can modify it as you wish.

regarding SPI there should not be any problem, both the example i2c and SPI must be executed with a user who can access you device, you can check if your user belongs to the i2c group and spi with command: id or run the example with sudo.

you can also refer to this issues: https://github.com/kashimAstro/ofxGPIO/issues/18

for some additions made to the SPI class. make sure the MCP example points to the right path for the SPI device you are using.

try to look at this example that takes the path of the spi device as a parameter in the setup method https://github.com/kashimAstro/ofxGPIO/blob/master/example-mcp-simple-syntax/src/main.cpp

please let me know Greetings

fred-dev commented 6 years ago

Hi, thanks, I have no idea what I was doing wrong but I started from scratch and the MCP worked fine, I had used it a few months ago so I had already found these quirks, just wanted to do a poc before I send a PCB for fabrication.

The i2c is a different issue. I can confirm everything is working hardware wise, but just not with your code. I have added a picture that I can scan the 12c bus with a command, but your addon does not work, I have been using elevated permissions. Knowing that it can work I will go ahead with my PCB, needless to say it would be great to be able to use your code and have everything in a single app, rather than run the 12c from another script.

Cheers

Fred

PS, thanks a million for this work, ofxGpio is really extensive and well put together, you are making a lot of crazy projects happen!!

i2c issue

PS, I reinstalled raspbian to the latest kernel 4.9

kashimAstro commented 6 years ago

Hi, thanks for feedback!

unfortunately, I can only reach a remote raspberry that is in my office in Italy, while I am now in switzerland. I'd like to solve this, can you help me debug?

if you can! add a: cout << result << endl; to the scanner example, immediately after this line: https://github.com/kashimAstro/ofxGPIO/blob/master/example-i2c-scanner/src/main.cpp#L28 and pass me the output.

Grazie!

fred-dev commented 6 years ago

It gives me:

65415

Cheers - and I am ok for a few days, thanks so much for the effort.

On 19 April 2018 at 10:10, Dario Longobardi notifications@github.com wrote:

Hi, thanks for feedback!

unfortunately, I can only reach a remote raspberry that is in my office in Italy, while I am now in switzerland. I'd like to solve this, can you help me debug?

if you can! add a: cout << result << endl; to the scanner example, immediately after this line: https://github.com/kashimAstro/ofxGPIO/blob/master/example-i2c-scanner/ src/main.cpp#L28 and pass me the output.

Grazie!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kashimAstro/ofxGPIO/issues/19#issuecomment-382682627, or mute the thread https://github.com/notifications/unsubscribe-auth/ABg9lRsHMJ5kKmF8kTWX1m4GPgigyZrRks5tqGKigaJpZM4TYVAC .

-- Frederick Rodrigues

+31685253512

http://www.fredrodrigues.net/

kashimAstro commented 6 years ago

the whole list contains only the value: 65415? this is strange smbus should return 0 or 255 if it finds an address.. Is the chip connected when you run example?

fred-dev commented 6 years ago

Ok, I had a chance to try this again, I was wrong it is not only 6514.

The 24th value is read as 31. My 12c device is addressed at 18, as shown in the previous picture.

Could it be that this value is now coming in as octal and with an offset?

My sensor should be 18, but if there is now a start address offset (it starts at 1 not zero) and the values are octal.

031 octal is 19 hex and 25 decimal?

On 19 Apr 2018, at 3:07 pm, Dario Longobardi notifications@github.com wrote:

the whole list contains only the value: 65415? Is the chip conn this is strange smbus should return 0 or 255 if it finds an address.. ected when you run example?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kashimAstro/ofxGPIO/issues/19#issuecomment-382727655, or mute the thread https://github.com/notifications/unsubscribe-auth/ABg9lSylJ5bMJA9r5Ts1MsJHxvgx6K6Cks5tqIwOgaJpZM4TYVAC.

kashimAstro commented 6 years ago

Hi @fred-dev thanks for this, in the next few days I solve this problem!