Compass Data Output

I want to bring data into a data logger via simple serial connection, and initially just need a basic Roll/Pitch/Yaw for development, later on we might customise the IMU application.

The 'Compass' demo app from the developer website sends a 'C1' message out the serial port (SCK & MOSI pins), without needing to configure anything, whereas the AHRS and IMU don't send serial without configuration commands via the USB serial port (I think?)

I can't find a specification of the contents of the C1 message - nor can I locate the source code to look it up. I would expect the definition of the message would be in the .json file.
Could you point me to a definition of the file (data and scaling)?
also, is the example code available?


@Richard Hi Richard,currently we do not support the ecompass open source code in aceinna extension, you could check the json file to locate the payload of the "c1" package. btw, i attached the ecompass source code for your reference

I played around with the prebuilt demo code in the IMU a little
(V1.0.0 As available from,
and discovered that the data fields in it requires an 'endian swap'.
(& for anyone interested - the payload is sort of spec'd in "UserMessaging.c" in the zipfile you provided.)

I eventually decided that it was easier to modify the AHRS code to output 'e1' messages at my desired data rate - than persist with the Compass Code.
(I have the dev kit to do this) That is working nicely for me.
Thank you for your help!

you are welcome, thanks for sharing!

Regarding compass output - the IMU and AHRS code don't seem to initalise the heading from the magnetic sensor. The heading direction is set to 0.00degrees at the power on position.
I haven't yet had the chance to try - but I presume that by having a GPS attached, and some motion of the body - then the North direction would be resolved.
I notice in the code that there is an option of (algorithm.h)

// Define heading initialization reliability
#define HEADING_MAG             1
#define HEADING_GNSS_LOW        2
#define HEADING_GNSS_HIGH       3

But there doesn't appear to be any code to handle the MAG case.
I presume I would need to add in some of the code from the Compass example to initialise the heading, or is there an easier way??

Generally in UserAlgorithm.c, you will find:
static uint8_t algoType = AHRS;
it means heading calculation from mag, pls check.
Already enabled in VG_AHRS app on ANS(, you can test.
Just a reminder, we didn't calibrated the 300ZI mag in plant, for mag is too easy influenced by environment. and you need to calibrated by your self if you need, steps in topic_11(

@cek Thankyou!
Seems I managed to confuse myself during initial testing - AHRS does report mag based heading straight off ☺
Thankyou for pointers to relevant code & reminder.
I have code working, have created my own messages & and have completed mag calibration - very happy. 😃

Log in to reply