[Resolved]Unable to open I2C bus

Home Forums Forums Technical Support for BerryIMU [Resolved]Unable to open I2C bus

Viewing 15 posts - 1 through 15 (of 36 total)
  • Author
    Posts
  • #3937
    jawood
    Participant

    Connected new BerryIMU to Raspberry Pi 2 with PiScreen on SanDisk Extreme 32Gig.

    Installed piscreen image 1.8

    raspi-config
    - advanced settings - update - Expand file system - change password - change international settings - change host name - reboot

    rpi-update
    - reboot

    apt-get update
    apt-get upgrade
    - reboot

    sudo apt-get install i2c-tools libi2c-dev

    sudo nano /etc/modules
    - add i2c-dev, i2c-bcm2708

    sudo nano /boot/config.txt
    - add dtparam=i2c_arm=on, dtparam=i2c1=on
    -reboot

    sudo i2cdetect -y 1
    0 1 2 3 4 5 6 7 8 9 a b c d e f
    00: -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- 6a -- -- -- -- --
    70: -- -- -- -- -- -- -- 77

    git clone https://github.com/mwilliams03/BerryIMU.git

    gcc compass_tutorial01.c -o compass_tutorial01 -lm

    ./compass_tutorial01
    - Unable to open I2C bus!

    P.S. Of course I still have the problem with the touch screen calibration too!

    #3945
    Mark Williams
    Keymaster

    Thanks for all the info.

    Have you tried with 'sudo'
    sudo ./compass_tutorial01

    Mark --OzzMaker.com --

    #3947
    jawood
    Participant

    🙂 that worked.

    #3954
    jawood
    Participant

    ok so that's all good now moving onto the next issue...

    Doing the compass calibration tutorial 03

    Create text file with sudo ./compass_tutorial01 > rawdatauncalibrated.txt no problems

    Remove first and last line with awk ‘NR>2{ print l} {l=$0}’ calnewtemp.txt > ~/uncalibrated.txt I get
    - awk: 1: unexpected character 0xe2 (Even if I go into a text editor and remove 1st and last lines and any data that is not formatted correctly, I get the same error when running this command.)

    #3956
    jawood
    Participant

    rawdatauncalibrated.txt is the piped output
    and
    rawdatauncalibrated-1.txt is after I have manually edited the file and removed all erroneous data.
    When run
    awk ‘NR>2{ print l} {l=$0}’ calnewtemp.txt > ~/uncalibrated.txt
    or
    awk ‘NR>2{ print l} {l=$0}’ calnewtemp.txt > ~/uncalibrated-1.txt
    get same error
    awk: 1: unexpected character 0xe2

    #3959
    jawood
    Participant

    When trying to plot data with Mathematica

    data = Import ["~/calibrated-1.txt", "Table", "FieldSeparators" -> {",", " "}];
    ListPlot[data[[All, {6, 9}]], AspectRatio -> 1, Frame -> True]

    Import::nffil : File not found during import.

    even if I do this

    data = Import ["/home/pi/BerryIMU/compass_tutorial01_basics/calibrated-1.txt", "Table", "FieldSeparators" -> {",", " "}];
    ListPlot[data[[All, {6, 9}]], AspectRatio -> 1, Frame -> True]

    #3962
    Mark Williams
    Keymaster

    I tested the above syntax with your data and it works. See image below.

    1.check the location of your data file
    2.check the permissions on your data file

    Mark --OzzMaker.com --

    #3963
    jawood
    Participant

    ok I got that to work now and can display un-calibrated plot graph.
    when compiling compass_tutorial03.c after modifying calibration data I get error

    pi@INS-RPi2-01 ~/BerryIMU/compass_tutorial03_calibration $ gcc -o compass_tutorial03 compass_tutorial03.c

    /tmp/ccwU8pZV.o: In function `main':
    compass_tutorial03.c:(.text+0x354): undefined reference to `atan2'
    collect2: ld returned 1 exit status

    You were right though, it was just file name and paths incorrect.

    #3964
    jawood
    Participant

    Attached is copy of compass_tutorial03.c that I have after changing the calibration data variables.

    #3967
    Mark Williams
    Keymaster

    compile with;
    gcc -o compass_tutorial03_calibration compass_tutorial03_calibration.c -lm

    -lm was missing on the instruction page.. sorry about that

    Mark --OzzMaker.com --

    #3971
    jawood
    Participant

    thanks that's got that sorted, now onto tutorial 4...

    #3972
    jawood
    Participant

    Ok so I dod the SDL install
    sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-gfx1.2-dev libsdl-ttf2.0-dev

    sudo nano test.c

    copy

    #include <SDL/SDL.h>

    int main(int argc, char** argv) {
    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_Surface *screen;

    screen = SDL_SetVideoMode( 480, 320, 16, SDL_SWSURFACE );
    SDL_Rect rect;
    rect.x = 10;
    rect.y = 10;
    rect.w = 20;
    rect.h = 20;

    Uint32 color = SDL_MapRGB(screen->format, 0xff,0xff,0xff);
    Uint32 color2 = SDL_MapRGB(screen->format, 0,0,0);
    SDL_FillRect(screen, &screen->clip_rect, color);
    SDL_Flip(screen);
    getchar();

    SDL_Quit();
    return 0;
    }

    gcc -o test test.c sdl-config –cflags sdl-config –libs

    Get error:-

    Usage: sdl-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs] [--static-libs]
    Usage: sdl-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs] [--static-libs]
    /tmp/ccM8y3Uh.o: In function `main':
    test.c:(.text+0x18): undefined reference to `SDL_Init'
    test.c:(.text+0x2c): undefined reference to `SDL_SetVideoMode'
    test.c:(.text+0x6c): undefined reference to `SDL_MapRGB'
    test.c:(.text+0x8c): undefined reference to `SDL_MapRGB'
    test.c:(.text+0xa8): undefined reference to `SDL_FillRect'
    test.c:(.text+0xb0): undefined reference to `SDL_Flip'
    test.c:(.text+0xb8): undefined reference to `SDL_Quit'
    collect2: ld returned 1 exit status

    Ow and thanks for all your help so far

    #3974
    Mark Williams
    Keymaster

    link sdl by adding -lSDL to the end of the compile statement.

    Mark --OzzMaker.com --

    #3976
    jawood
    Participant

    Thankyou again that got it going.
    Now im doing the Inclinometer when I do this

    gcc -o gyro_accelerometer_tutorial02 -lm gyro_accelerometer_tutorial02.c sdl-config –cflags sdl-config –libs -lSDL_image -lSDL_gfx

    I get

    Usage: sdl-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs] [--static-libs]
    Usage: sdl-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs] [--static-libs]
    gyro_accelerometer_tutorial02.c:25:17: fatal error: SDL.h: No such file or directory
    compilation terminated.

    #3979
    Mark Williams
    Keymaster

    I am not near a Pi at the moment... but can you try again with -SDL at the end. Let me know how you go

    Mark --OzzMaker.com --

Viewing 15 posts - 1 through 15 (of 36 total)
  • You must be logged in to reply to this topic.

Blip, blop, bloop...