Mag_Pi
Posts: 2
Joined: Wed Sep 30, 2015 10:23 am

Astro Pi Magnetometer Not working

Wed Sep 30, 2015 10:40 am

Hi

I am attempting to get the magnetometer on board the astro pi to work.

Specifically, the compass.py example program.

I have calibrated the magnetometer according to the RTIMUlib instructions, and have a .ini file in the same folder as the compass.py program.

When I run the code, the magnetometer appears to point in the same corner of the board. The following pictures illustrate this (bounty for orientation!).

http://imgur.com/a/6yFl1

The light definitely moves, but only by one or two LEDs at most.

Am I doing something wrong?

Thanks.

tvjon
Posts: 730
Joined: Mon Jan 07, 2013 9:11 am

Re: Astro Pi Magnetometer Not working

Wed Sep 30, 2015 11:35 am

I'm currently running it on the new Jessie.

Initial run was:

[email protected] ~/Downloads/python-sense-hat-master/examples $ python3 compass.py
Traceback (most recent call last):
File "compass.py", line 25, in <module>
offset = led_loop[led_index]
IndexError: list index out of range

but a subsequent run after running the display only examples seems fine. The single blue led moves to keep correct orientation as I move the RPi board, & there's no error message.

Do you get any errors reported?

Mag_Pi
Posts: 2
Joined: Wed Sep 30, 2015 10:23 am

Re: Astro Pi Magnetometer Not working

Wed Sep 30, 2015 1:19 pm

No errors, same problem.

I've tried it in 2.7, and the same thing happens.

I've also completely wiped my pi, re-followed the setup instructions, to no avail.

How likely would it be that it is a hardware problem?

EDIT:

I have run the program a few times, and I got your error once. Subsequent attempts told me to use root/sudo, even though the command I used was "sudo python3 compass.py"

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6164
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Astro Pi Magnetometer Not working

Wed Sep 30, 2015 2:17 pm

That error could be caused by missing i2c-dev nodes. Also, the RTIMULib.ini file doesn't go in the current working directory:

Code: Select all

rm ~/.config/sense_hat/RTIMULib.ini
sudo rm ./root/.config/sense_hat/RTIMULib.ini
sudo cp RTIMULib.ini /etc

tvjon
Posts: 730
Joined: Mon Jan 07, 2013 9:11 am

Re: Astro Pi Magnetometer Not working

Wed Sep 30, 2015 2:52 pm

I have no sense-hat folder in root, only in /etc & /home/pi/.config/

Where are you copying RTIMULib.ini from ?

"sudo cp RTIMULib.ini /etc"

Here's my RTIMULib.ini in case it helps.
RTIMULib.ini.bz2
(2.37 KiB) Downloaded 134 times

User avatar
TideMan
Posts: 240
Joined: Fri Jun 22, 2012 8:08 am
Location: ChCh, NZ

Re: Astro Pi Magnetometer Not working

Tue Oct 13, 2015 2:49 am

tvjon:

I am having exactly the same problem.
My RTIMULib.ini is almost identical to yours.

ShiftPlusOne:
The comments in compass.py specifically say to "copy RTIMULib.ini into the same folder as your Python code".
If you wish in this world to advance, your merits you're bound to enhance.
You must stir it and stump it and blow your own trumpet, or trust me you haven't a chance.
Ruddigore, G&S

tvjon
Posts: 730
Joined: Mon Jan 07, 2013 9:11 am

Re: Astro Pi Magnetometer Not working

Tue Oct 13, 2015 7:12 am

Tideman, hello.

We were in your area a few months before the 'quake. I imagine Astro-Pi could be very handy for some sort of "early warning" indication !

My friend has taken his Astro-Pi back home now, but I became sufficiently interested that I've now ordered one for myself, so until it arrives I can't do any more testing. All I can suggest is that you ensure your µSD card is updated, including:

sudo rpi-update

& that if you have a spare card, install Jessie, & see if you get the same results as on the Wheezy Raspbian.

AndersM
Posts: 33
Joined: Sun Sep 06, 2015 1:18 pm

Re: Astro Pi Magnetometer Not working

Tue Oct 13, 2015 11:35 am

I had a frustrating time not getting the IMU to work when I first tried. Then I found out that my problem was a polling issue.
See this thread. Could this be the issue here too?

User avatar
TideMan
Posts: 240
Joined: Fri Jun 22, 2012 8:08 am
Location: ChCh, NZ

Re: Astro Pi Magnetometer Not working

Tue Oct 13, 2015 7:29 pm

tvjon wrote:Tideman, hello.

We were in your area a few months before the 'quake. I imagine Astro-Pi could be very handy for some sort of "early warning" indication !
Back in 2011, when we were getting magnitude 5 aftershocks every day or so, it would have been interesting to monitor the motion of our house with the astro-pi, though I don't think it would have worked as an early warning device. We all got pretty good at estimating the EQ magnitude from the motion we felt.
The aftershocks have died away now, thank goodness.
If you wish in this world to advance, your merits you're bound to enhance.
You must stir it and stump it and blow your own trumpet, or trust me you haven't a chance.
Ruddigore, G&S

Return to “Astro Pi”