HVHardiman
Posts: 10
Joined: Thu Sep 05, 2013 5:28 pm

Sense Hat Calibration and Compass.py Example Code

Mon Oct 10, 2016 10:38 pm

Hello,

I am doing some playing around with the Sense Hat and I have a few questions.

1. I did the calibration listed here: https://www.raspberrypi.org/documentati ... sense-hat/. I did the first two options for calibration, m and e. My question is as follows. They do not mention calibrating the accelerometers in the link. Is that something that can or should be done? If so, can someone explain how to do it? The instructions were not as clear...

2. After I did the calibration, I experimented with the provided compass.py code. Unfortunately, the blue dot does not point north. I am checking it by way of my knowledge of my surroundings and double checking it with a compass app on my mobile device. What could be wrong? What kind of interference could cause a problem?

3. Is it possible to receive the example codes for this board with more detailed or line by line comments to explain what is happening?

Thanks,

Howard

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1662
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: Sense Hat Calibration and Compass.py Example Code

Wed Oct 12, 2016 10:18 am

Ah yes, I think there is a bug with the actual python code in that example. I think it points West... so it's always 90 degrees out :)
You can bodge it by using set_rotation and then it should work.

HVHardiman
Posts: 10
Joined: Thu Sep 05, 2013 5:28 pm

Re: Sense Hat Calibration and Compass.py Example Code

Wed Oct 12, 2016 2:46 pm

Now that, my friend, would make sense. It did indeed point west on a consistent basis. Can you provide more with respect to the fix?

HH

HVHardiman
Posts: 10
Joined: Thu Sep 05, 2013 5:28 pm

Re: Sense Hat Calibration and Compass.py Example Code

Wed Oct 12, 2016 4:53 pm

So, I changed this line:

dir_inverted = 360 - dir # So LED appears to follow North

to this:

dir_inverted = 90 - dir # So LED appears to follow North

And all seems to be well.

HH

User avatar
Davespice
Forum Moderator
Forum Moderator
Posts: 1662
Joined: Fri Oct 14, 2011 8:06 pm
Location: The Netherlands
Contact: Twitter

Re: Sense Hat Calibration and Compass.py Example Code

Thu Oct 13, 2016 1:49 pm

Yeah you can do it that way, or - you can set the screen rotation to I think either 90 or 270.

Code: Select all

sense.set_rotation(angle)
The other thing you can do is manipulate the led_loop variable at the top of the program, move some LED numbers from the front to the back and you'll see this offsets where the blue LED ends up.

Return to “Astro Pi”