Direction of compass, Orientation device?

I wonder how the compass on the LCD screen works. Is there a gyro sensor and a compass on board, or do you achieve the direction somehow via GPS? How is this handled on boards without GPS?

Thanks :slight_smile:

It is doing dead reckoning based on your movement. We calculate a vector between the current position and a recent position and use that to guess at the direction you are walking/facing.

I forget if the heuristic to find that “recent” position is X seconds ago or Y meters ago. It could probably be improved though :wink:

1 Like

Ah ok, thanks for the explanation. It makes sense now, why sometimes North is pointing to real North and sometimes not.

This means, the top of the display is the assumed movement direction, and from that you calculate North and remote nodes direction vectors.

1 Like

Suggest showing the heading in degrees, so you can point a compass in the right direction.
Once you have a heading, you have a realtime non-digital direction finder.

Hi, going to bring back another thread here.

As mentioned by @Scout and also noticed by me during my last 3 field tests, the north indicator doesn’t seem to be working properly for me. While traveling north directly towards my other node, the arrow points very accurately to my node, but the north indicator is usually showing 120-180 degrees off. Not a big deal but can be confusing at first. Wondering if its just me or if this happens for anyone else? Lilygo T-Beam v1.1

1 Like

Hey, I took a trip to town today and set up couple of T-Beams in the house and LoRa32 with BN-180 GPS in the car. Our house is approx. 8km straight North of town.
So, as we are driving South arrow was pointing directly opposite to where N was indicated (arrow pointing up and N at the bottom of circle). Doesn’t seem right any way you look at it. Most other times, it seems to be working correctly.
I’m wondering if it has to do something with how often it recalculates bearing? Maybe I’m just impatient and don’t let it work everything out? T-beams at the house were stationary and already had satellite lock. LoRa32 in the car was on the dash and had also had satellite lock the entire time.


Hmm. Well the last couple times I tested it I was walking from 1000m and 500m in a straight line heading north towards a node, with the arrow pointing to the top of the device (Which is supposed to be your direction of travel) and the north indicator was 180 degrees at the bottom.

I’ve got my location frequency settings down to 30 seconds which works GREAT, and if I zig-zag slightly while heading north it shifts side to side a few degrees every time it refreshes.

But maybe there is another setting I have to look at? It could just be that it calculates the node position every 30 seconds but takes much longer to calculate north??

I’m probably going to try around 5-6km today and give it some more time, I’ll see I that makes any difference

Edit: Got 8km today with 92% signal. Node direction and North both seemed to work pretty accurately the whole time.

The calculation should happen in a tiny fraction of a millisecond.

While I don’t understand the math, the function is very straight forward.

static float bearing(double lat1, double lon1, double lat2, double lon2)
double lat1Rad = toRadians(lat1);
double lat2Rad = toRadians(lat2);
double deltaLonRad = toRadians(lon2 - lon1);
double y = sin(deltaLonRad) * cos(lat2Rad);
double x = cos(lat1Rad) * sin(lat2Rad) - (sin(lat1Rad) * cos(lat2Rad) * cos(deltaLonRad));
return atan2(y, x);

I have an idea of what’s going on …

The bearing is based on the coordinates of two points, a start and the stop. The calculation is done on the values given by the GPS, but what we’re not taking into account is the accuracy of the data. It’s totally possible that the device has a poor GPS lock and the absolute position of the two points are not accurate. That would contribute to the poor bearing.

1 Like

Ah that does make sense now that I think about it.

I wonder if the upgraded GPS antenna (Maybe with a ground plane as well) will make it much more accurate. I only had 4 satellites outside at the time, I’ve heard people get around 20 with the new antenna.

I’m patiently waiting for the mail to get here from a land far, far away…

1 Like

Thats interesting, I get a lock on 12 Sats sitting in my living room with 1 window facing the west. All with the stock antenna.

1 Like

I’m getting max 8 satellites with t-beams with stock antenna and outside. Only 4 inside by the window.

Getting 12 satellites with LoRa32 V2 1.6 + BN-180 module either outside or inside even 10feet from the window.

1 Like

When I got mine I disconnected the antenna and re-seated it. One of the things I noticed was that when I applied more pressure to the connector, I got more sats. Release the pressure and I lost sats. And there were many comments in throughout that there was a crappy connection point on the board for many people.

1 Like

Interesting! Tried it inside 2 inches from my window and got 4 satellites right away. After both pressing on the connector and reseating it still had 4.

Could also be because we’re in a valley :upside_down_face: I’ll report back when these guys arrive

I’ve noticed this with my devices too. Sometimes the pointer is dead on and other times it’s off by quite a bit. It makes sense that the bearing would be pretty far out of whack at walking speeds if the GPS suddenly reports you as 10 feet to the left of where you were a moment ago, even though you haven’t moved.

Is it possible this would be more accurate if it took into account several points instead of just two?

Like, maybe given points A, B, C, D, E, F, G, H, I
Calculate bearing(A,B) then bearing(B,C) bearing(H,I) and average them?

All of those points would have to be read from the GPS hardware in fairly rapid succession, I suppose. Looks like the UBLOX NEO-6M supports five position updates per second. Or, maybe you would want to spread them out over several seconds, to get an average bearing?

1 Like

These are good thoughts. Could you file a feature request on this so we don’t lose track of it? This is really a user experience issue and that’s one of those things that should be well polished.


Issue #662


I marked that as a good first issue for anyone who would like to try their hand at a ticket. :slight_smile:

When I get into the grove of things, I plan to play with the magnetic declination to map it in; the LCD with arrow is nice for a group backpacking trip or … just out and about at a mega mall to find each other =)

Besides being more accurate to determine bearing, I think it makes sense to provide an option to keep map locked with North at the top. It is often the case that heading != bearing and rotating maps could be confusing.

1 Like