Arduino Uno WiFi Rev2 Inclinometer project

Hi all,
I already started a topic in the Nano section but because I moved to this board I am starting over here.
So I am trying to get data from WitMotion HWT905 TTL high accuracy 9 Axis AHRS Sensor
inclinometer. It has a written library from the manufacturer to get it going with Arduino Uno Rev3.

YouTube_Video

There is a youtube instructional video as well showing the steps and the way it has to be connected. I follow everything as per the instructions but when I load the library in the Arduino IDE and try to verify it before uploading it gives me an error.
I am starting just now with learning the coding and it seems a bit overwhelming so far I just can't find what I am doing wrong.
Can you guys give me some guidance on what could be wrong with that library?

#include <Wire.h>
#include <JY901.h>
/*
Test on Uno R3.
JY901   UnoR3
TX <---> 0(Rx)
*/
void setup() 
{
  Serial.begin(115200);
}

void loop() 
{
  //print received data. Data was received in serialEvent;
  Serial.print("Time:20");Serial.print(JY901.stcTime.ucYear);Serial.print("-");Serial.print(JY901.stcTime.ucMonth);Serial.print("-");Serial.print(JY901.stcTime.ucDay);
  Serial.print(" ");Serial.print(JY901.stcTime.ucHour);Serial.print(":");Serial.print(JY901.stcTime.ucMinute);Serial.print(":");Serial.println((float)JY901.stcTime.ucSecond+(float)JY901.stcTime.usMiliSecond/1000);
               
  Serial.print("Acc:");Serial.print((float)JY901.stcAcc.a[0]/32768*16);Serial.print(" ");Serial.print((float)JY901.stcAcc.a[1]/32768*16);Serial.print(" ");Serial.println((float)JY901.stcAcc.a[2]/32768*16);
  
  Serial.print("Gyro:");Serial.print((float)JY901.stcGyro.w[0]/32768*2000);Serial.print(" ");Serial.print((float)JY901.stcGyro.w[1]/32768*2000);Serial.print(" ");Serial.println((float)JY901.stcGyro.w[2]/32768*2000);
  
  Serial.print("Angle:");Serial.print((float)JY901.stcAngle.Angle[0]/32768*180);Serial.print(" ");Serial.print((float)JY901.stcAngle.Angle[1]/32768*180);Serial.print(" ");Serial.println((float)JY901.stcAngle.Angle[2]/32768*180);
  
  Serial.print("Mag:");Serial.print(JY901.stcMag.h[0]);Serial.print(" ");Serial.print(JY901.stcMag.h[1]);Serial.print(" ");Serial.println(JY901.stcMag.h[2]);
  
  Serial.print("Pressure:");Serial.print(JY901.stcPress.lPressure);Serial.print(" ");Serial.println((float)JY901.stcPress.lAltitude/100);
  
  Serial.print("DStatus:");Serial.print(JY901.stcDStatus.sDStatus[0]);Serial.print(" ");Serial.print(JY901.stcDStatus.sDStatus[1]);Serial.print(" ");Serial.print(JY901.stcDStatus.sDStatus[2]);Serial.print(" ");Serial.println(JY901.stcDStatus.sDStatus[3]);
  
  Serial.print("Longitude:");Serial.print(JY901.stcLonLat.lLon/10000000);Serial.print("Deg");Serial.print((double)(JY901.stcLonLat.lLon % 10000000)/1e5);Serial.print("m Lattitude:");
  Serial.print(JY901.stcLonLat.lLat/10000000);Serial.print("Deg");Serial.print((double)(JY901.stcLonLat.lLat % 10000000)/1e5);Serial.println("m");
  
  Serial.print("GPSHeight:");Serial.print((float)JY901.stcGPSV.sGPSHeight/10);Serial.print("m GPSYaw:");Serial.print((float)JY901.stcGPSV.sGPSYaw/10);Serial.print("Deg GPSV:");Serial.print((float)JY901.stcGPSV.lGPSVelocity/1000);Serial.println("km/h");
  
  Serial.println("");
  delay(500);
}

/*
  SerialEvent occurs whenever a new data comes in the
 hardware serial RX.  This routine is run between each
 time loop() runs, so using delay inside loop can delay
 response.  Multiple bytes of data may be available.
 */
void serialEvent() 
{
  while (Serial.available()) 
  {
    JY901.CopeSerialData(Serial.read()); //Call JY901 data cope function
  }
}



This is the error I get every time:

In file included from C:\Users\Bobby\Documents\Arduino\libraries\JY901\JY901.cpp:1:0:
C:\Users\Bobby\Documents\Arduino\libraries\JY901\JY901.h:50:17: error: expected unqualified-id before numeric constant
 #define TEMP    0x40
                 ^
C:\Users\Bobby\Documents\Arduino\libraries\JY901\JY901.h:50:17: error: expected unqualified-id before numeric constant
 #define TEMP    0x40
                 ^
C:\Users\Bobby\Documents\Arduino\libraries\JY901\JY901.h:50:17: error: expected unqualified-id before numeric constant
 #define TEMP    0x40
                 ^
C:\Users\Bobby\Documents\Arduino\libraries\JY901\JY901.h:50:17: error: expected unqualified-id before numeric constant
 #define TEMP    0x40
                 ^
In file included from c:\users\bobby\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\io.h:677:0,
                 from c:\users\bobby\appdata\local\arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\avr\pgmspace.h:90,
                 from C:\Users\Bobby\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/api/String.h:31,
                 from C:\Users\Bobby\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/api/IPAddress.h:24,
                 from C:\Users\Bobby\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/api/ArduinoAPI.h:30,
                 from C:\Users\Bobby\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\cores\arduino/Arduino.h:23,
                 from C:\Users\Bobby\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\libraries\Wire\src/Wire.h:25,
                 from C:\Users\Bobby\Documents\Arduino\libraries\JY901\JY901.h:165,
                 from C:\Users\Bobby\Documents\Arduino\libraries\JY901\JY901.cpp:1:
C:\Users\Bobby\Documents\Arduino\libraries\JY901\JY901.h:8:17: error: expected unqualified-id before numeric constant
 #define BAUD    0x04
                 ^
In file included from C:\Users\Bobby\Documents\Arduino\libraries\JY901\JY901.h:165:0,
                 from C:\Users\Bobby\Documents\Arduino\libraries\JY901\JY901.cpp:1:
C:\Users\Bobby\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\libraries\Wire\src/Wire.h: In member function 'void CJY901::readRegisters(unsigned char, unsigned char, unsigned char, char*)':
C:\Users\Bobby\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\libraries\Wire\src/Wire.h:63:12: note: candidate 1: size_t TwoWire::requestFrom(int, int)
     size_t requestFrom(int, int);
            ^~~~~~~~~~~
C:\Users\Bobby\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\libraries\Wire\src/Wire.h:61:12: note: candidate 2: virtual size_t TwoWire::requestFrom(uint8_t, size_t)
     size_t requestFrom(uint8_t, size_t);
            ^~~~~~~~~~~

exit status 1

Compilation error: exit status 1

This is the J901.ccp file

#include "JY901.h"
#include "string.h"

CJY901 ::CJY901 ()
{
	ucDevAddr =0x50;
}
void CJY901::StartIIC()
{
	ucDevAddr = 0x50;
	Wire.begin();
}
void CJY901::StartIIC(unsigned char ucAddr)
{
	ucDevAddr = ucAddr;
	Wire.begin();
}
void CJY901 ::CopeSerialData(unsigned char ucData)
{
	static unsigned char ucRxBuffer[250];
	static unsigned char ucRxCnt = 0;	
	
	ucRxBuffer[ucRxCnt++]=ucData;
	if (ucRxBuffer[0]!=0x55) 
	{
		ucRxCnt=0;
		return;
	}
	if (ucRxCnt<11) {return;}
	else
	{
		switch(ucRxBuffer[1])
		{
			case 0x50:	memcpy(&stcTime,&ucRxBuffer[2],8);break;
			case 0x51:	memcpy(&stcAcc,&ucRxBuffer[2],8);break;
			case 0x52:	memcpy(&stcGyro,&ucRxBuffer[2],8);break;
			case 0x53:	memcpy(&stcAngle,&ucRxBuffer[2],8);break;
			case 0x54:	memcpy(&stcMag,&ucRxBuffer[2],8);break;
			case 0x55:	memcpy(&stcDStatus,&ucRxBuffer[2],8);break;
			case 0x56:	memcpy(&stcPress,&ucRxBuffer[2],8);break;
			case 0x57:	memcpy(&stcLonLat,&ucRxBuffer[2],8);break;
			case 0x58:	memcpy(&stcGPSV,&ucRxBuffer[2],8);break;
		}
		ucRxCnt=0;
	}
}
void CJY901::readRegisters(unsigned char deviceAddr,unsigned char addressToRead, unsigned char bytesToRead, char * dest)
{
  Wire.beginTransmission(deviceAddr);
  Wire.write(addressToRead);
  Wire.endTransmission(false); //endTransmission but keep the connection active

  Wire.requestFrom(deviceAddr, bytesToRead); //Ask for bytes, once done, bus is released by default

  while(Wire.available() < bytesToRead); //Hang out until we get the # of bytes we expect

  for(int x = 0 ; x < bytesToRead ; x++)
    dest[x] = Wire.read();    
}
void CJY901::writeRegister(unsigned char deviceAddr,unsigned char addressToWrite,unsigned char bytesToRead, char *dataToWrite)
{
  Wire.beginTransmission(deviceAddr);
  Wire.write(addressToWrite);
  for(int i = 0 ; i < bytesToRead ; i++)
  Wire.write(dataToWrite[i]);
  Wire.endTransmission(); //Stop transmitting
}

short CJY901::ReadWord(unsigned char ucAddr)
{
	short sResult;
	readRegisters(ucDevAddr, ucAddr, 2, (char *)&sResult);
	return sResult;
}
void CJY901::WriteWord(unsigned char ucAddr,short sData)
{	
	writeRegister(ucDevAddr, ucAddr, 2, (char *)&sData);
}
void CJY901::ReadData(unsigned char ucAddr,unsigned char ucLength,char chrData[])
{
	readRegisters(ucDevAddr, ucAddr, ucLength, chrData);
}

void CJY901::GetTime()
{
	readRegisters(ucDevAddr, 0x30, 8, (char*)&stcTime);	
}
void CJY901::GetAcc()
{
	readRegisters(ucDevAddr, AX, 6, (char *)&stcAcc);
}
void CJY901::GetGyro()
{
	readRegisters(ucDevAddr, GX, 6, (char *)&stcGyro);
}

void CJY901::GetAngle()
{
	readRegisters(ucDevAddr, Roll, 6, (char *)&stcAngle);
}
void CJY901::GetMag()
{
	readRegisters(ucDevAddr, HX, 6, (char *)&stcMag);
}
void CJY901::GetPress()
{
	readRegisters(ucDevAddr, PressureL, 8, (char *)&stcPress);
}
void CJY901::GetDStatus()
{
	readRegisters(ucDevAddr, D0Status, 8, (char *)&stcDStatus);
}
void CJY901::GetLonLat()
{
	readRegisters(ucDevAddr, LonL, 8, (char *)&stcLonLat);
}
void CJY901::GetGPSV()
{
	readRegisters(ucDevAddr, GPSHeight, 8, (char *)&stcGPSV);
}
CJY901 JY901 = CJY901();

And the JY901.h

#ifndef JY901_h
#define JY901_h

#define SAVE 			0x00
#define CALSW 		0x01
#define RSW 			0x02
#define RRATE			0x03
#define BAUD 			0x04
#define AXOFFSET	0x05
#define AYOFFSET	0x06
#define AZOFFSET	0x07
#define GXOFFSET	0x08
#define GYOFFSET	0x09
#define GZOFFSET	0x0a
#define HXOFFSET	0x0b
#define HYOFFSET	0x0c
#define HZOFFSET	0x0d
#define D0MODE		0x0e
#define D1MODE		0x0f
#define D2MODE		0x10
#define D3MODE		0x11
#define D0PWMH		0x12
#define D1PWMH		0x13
#define D2PWMH		0x14
#define D3PWMH		0x15
#define D0PWMT		0x16
#define D1PWMT		0x17
#define D2PWMT		0x18
#define D3PWMT		0x19
#define IICADDR		0x1a
#define LEDOFF 		0x1b
#define GPSBAUD		0x1c

#define YYMM				0x30
#define DDHH				0x31
#define MMSS				0x32
#define MS					0x33
#define AX					0x34
#define AY					0x35
#define AZ					0x36
#define GX					0x37
#define GY					0x38
#define GZ					0x39
#define HX					0x3a
#define HY					0x3b
#define HZ					0x3c			
#define Roll				0x3d
#define Pitch				0x3e
#define Yaw					0x3f
#define TEMP				0x40
#define D0Status		0x41
#define D1Status		0x42
#define D2Status		0x43
#define D3Status		0x44
#define PressureL		0x45
#define PressureH		0x46
#define HeightL			0x47
#define HeightH			0x48
#define LonL				0x49
#define LonH				0x4a
#define LatL				0x4b
#define LatH				0x4c
#define GPSHeight   0x4d
#define GPSYAW      0x4e
#define GPSVL				0x4f
#define GPSVH				0x50
      
#define DIO_MODE_AIN 0
#define DIO_MODE_DIN 1
#define DIO_MODE_DOH 2
#define DIO_MODE_DOL 3
#define DIO_MODE_DOPWM 4
#define DIO_MODE_GPS 5		

struct STime
{
	unsigned char ucYear;
	unsigned char ucMonth;
	unsigned char ucDay;
	unsigned char ucHour;
	unsigned char ucMinute;
	unsigned char ucSecond;
	unsigned short usMiliSecond;
};
struct SAcc
{
	short a[3];
	short T;
};
struct SGyro
{
	short w[3];
	short T;
};
struct SAngle
{
	short Angle[3];
	short T;
};
struct SMag
{
	short h[3];
	short T;
};

struct SDStatus
{
	short sDStatus[4];
};

struct SPress
{
	long lPressure;
	long lAltitude;
};

struct SLonLat
{
	long lLon;
	long lLat;
};

struct SGPSV
{
	short sGPSHeight;
	short sGPSYaw;
	long lGPSVelocity;
};
class CJY901 
{
  public: 
	struct STime		stcTime;
	struct SAcc 		stcAcc;
	struct SGyro 		stcGyro;
	struct SAngle 		stcAngle;
	struct SMag 		stcMag;
	struct SDStatus 	stcDStatus;
	struct SPress 		stcPress;
	struct SLonLat 		stcLonLat;
	struct SGPSV 		stcGPSV;
	
    CJY901 (); 
	void StartIIC();
	void StartIIC(unsigned char ucAddr);
    void CopeSerialData(unsigned char ucData);
	short ReadWord(unsigned char ucAddr);
	void WriteWord(unsigned char ucAddr,short sData);
	void ReadData(unsigned char ucAddr,unsigned char ucLength,char chrData[]);
	void GetTime();
	void GetAcc();
	void GetGyro();
	void GetAngle();
	void GetMag();
	void GetPress();
	void GetDStatus();
	void GetLonLat();
	void GetGPSV();
	
  private: 
	unsigned char ucDevAddr; 
	void readRegisters(unsigned char deviceAddr,unsigned char addressToRead, unsigned char bytesToRead, char * dest);
	void writeRegister(unsigned char deviceAddr,unsigned char addressToWrite,unsigned char bytesToRead, char *dataToWrite);
};
extern CJY901 JY901;
#include <Wire.h>
#endif

In the .h file, replace the words BAUD and TEMP by something else. E.g. BAUDX and TEMPX.

I could not find where the conflict is but with those changes it at least compiles. Make a note of these changes because one day you have code that actually uses them.

Thanks sterrrtje,
I just corrected the TEMP and BAUD also formated the code and now no errors and the code uploaded successfully. But am getting no readings. The serial shows only zeros:

GPSHeight:0.00m GPSYaw:0.00Deg GPSV:0.00km/h

Time:200-0-0 0:0:0.00
Acc:0.00 0.00 0.00
Gyro:0.00 0.00 0.00
Angle:0.00 0.00 0.00
Mag:0 0 0
Pressure:0 0.00
DStatus:0 0 0 0
Longitude:0Deg0.00m Lattitude:0Deg0.00m
GPSHeight:0.00m GPSYaw:0.00Deg GPSV:0.00km/h

How do you communicate with the CJY901? I2C? Serial? Your sketch seems to indicate Serial.

If that is the case, on the Uno WiFi Rev2, pins 0 and 1 are, to my knowledge, Serial1, not Serial.

Replace everything related to Serial in the last part of the ino file by Serial1 as shown below

// was SerialEvent
void serialEvent1()
{
  // was Serial.available()
  while (Serial1.available())
  {
    // was Serial.read()
    JY901.CopeSerialData(Serial1.read()); //Call JY901 data cope function
  }
}

You will also have to add a Serial1.begin() in setup

void setup()
{
  Serial.begin(115200);
  Serial1.begin(115200);
}

Give it a try.

Note:
I did make those modifications and it does compile :wink:

Hi yes, the communication is via serial. I just read about the serial differences between the boards. Even found a chap with the same problem as me trying to use the same library with Arduino Leonardo ( I saw your comments there as well), but it looks like he didn't resolve the problem.
I`ll try your suggestion in a moment.

Still nothing. The data on the serial monitor is even worst. it switches between showing zeros to the following - random signs and then the next message again:

Pressure:0 0.00
DStaW��0 0 0 0
Longitude:0Deg0.00m Lattitude'"���.00m
GPSHeight:0.00m GPSYaw:0.00Deg GPSV:0.00km/hC�H�Time:200-0-0�����r��j
Acc:0	��r���r��j
Gyro:0	��r���r��j
Angle:0.00�r���r��j
Mag:0 0 0
Pressure:0 0.00
DStat].'���j
Longitude:0Deg0.00m LattituV��"���.00m
GPSHeight:0.00m GPSYaw:0.00Deg GPSV:0.00km/h

Time:200-0-0 0:0:0.00
Acc:0.00 0.0�r��j
Gyro:0.00 0.00 0.00
������0.00 0.00 0.00
Mag:0 0 0
Pressure:0 0.00
D*W����0 0 0 0
Longitude:0Deg0.00m Lattitude:0Deg0.00m
GPSHeight:0.00m GPSYaw:0.00Deg GPSV:0.00km/h

Time:200-0-0 0:0:0.00
Acc:0.00 0.00 0.00
Gyro:0.00 0.00 0.00
Angle:0.00 0.00 0.00
Mag:0 0 0
Pressure:0 0.00
DStatus:0 0 0 0
Longitude:0Deg0.00m Lattitude:0Deg0.00m
GPSHeight:0.00m GPSYaw:0.00Deg GPSV:0.00km/h

This is how the code looks like after the suggested edit:

#include <Wire.h>
#include <JY901.h>
/*
Test on Uno R3.
JY901   UnoR3
TX <---> 0(Rx)
*/
void setup() {
  Serial.begin(115200);
  Serial1.begin(115200);
}

void loop() {
  //print received data. Data was received in serialEvent;
  Serial.print("Time:20");
  Serial.print(JY901.stcTime.ucYear);
  Serial.print("-");
  Serial.print(JY901.stcTime.ucMonth);
  Serial.print("-");
  Serial.print(JY901.stcTime.ucDay);
  Serial.print(" ");
  Serial.print(JY901.stcTime.ucHour);
  Serial.print(":");
  Serial.print(JY901.stcTime.ucMinute);
  Serial.print(":");
  Serial.println((float)JY901.stcTime.ucSecond + (float)JY901.stcTime.usMiliSecond / 1000);

  Serial.print("Acc:");
  Serial.print((float)JY901.stcAcc.a[0] / 32768 * 16);
  Serial.print(" ");
  Serial.print((float)JY901.stcAcc.a[1] / 32768 * 16);
  Serial.print(" ");
  Serial.println((float)JY901.stcAcc.a[2] / 32768 * 16);

  Serial.print("Gyro:");
  Serial.print((float)JY901.stcGyro.w[0] / 32768 * 2000);
  Serial.print(" ");
  Serial.print((float)JY901.stcGyro.w[1] / 32768 * 2000);
  Serial.print(" ");
  Serial.println((float)JY901.stcGyro.w[2] / 32768 * 2000);

  Serial.print("Angle:");
  Serial.print((float)JY901.stcAngle.Angle[0] / 32768 * 180);
  Serial.print(" ");
  Serial.print((float)JY901.stcAngle.Angle[1] / 32768 * 180);
  Serial.print(" ");
  Serial.println((float)JY901.stcAngle.Angle[2] / 32768 * 180);

  Serial.print("Mag:");
  Serial.print(JY901.stcMag.h[0]);
  Serial.print(" ");
  Serial.print(JY901.stcMag.h[1]);
  Serial.print(" ");
  Serial.println(JY901.stcMag.h[2]);

  Serial.print("Pressure:");
  Serial.print(JY901.stcPress.lPressure);
  Serial.print(" ");
  Serial.println((float)JY901.stcPress.lAltitude / 100);

  Serial.print("DStatus:");
  Serial.print(JY901.stcDStatus.sDStatus[0]);
  Serial.print(" ");
  Serial.print(JY901.stcDStatus.sDStatus[1]);
  Serial.print(" ");
  Serial.print(JY901.stcDStatus.sDStatus[2]);
  Serial.print(" ");
  Serial.println(JY901.stcDStatus.sDStatus[3]);

  Serial.print("Longitude:");
  Serial.print(JY901.stcLonLat.lLon / 10000000);
  Serial.print("Deg");
  Serial.print((double)(JY901.stcLonLat.lLon % 10000000) / 1e5);
  Serial.print("m Lattitude:");
  Serial.print(JY901.stcLonLat.lLat / 10000000);
  Serial.print("Deg");
  Serial.print((double)(JY901.stcLonLat.lLat % 10000000) / 1e5);
  Serial.println("m");

  Serial.print("GPSHeight:");
  Serial.print((float)JY901.stcGPSV.sGPSHeight / 10);
  Serial.print("m GPSYaw:");
  Serial.print((float)JY901.stcGPSV.sGPSYaw / 10);
  Serial.print("Deg GPSV:");
  Serial.print((float)JY901.stcGPSV.lGPSVelocity / 1000);
  Serial.println("km/h");

  Serial.println("");
  delay(1000);
}

// was SerialEvent
void serialEvent1() {
  // was Serial.available()
  while (Serial1.available()) {
    // was Serial.read()
    JY901.CopeSerialData(Serial1.read());  //Call JY901 data cope function
  }
}

HI managed to make it work on Arduino Wifi Rev2 and this is the code including a calibration in the beginning.

Now I am trying to stream live data to excel with excels live streamer but I cant make it print any data at all.
Does someone have any ideas?

#include <witmotion_uart.h>

// Module will be used with Serial1.
#define JY901_PORT Serial1

// Make sensor's class instance
JY901_UART JY901(JY901_PORT);

void setup() {
  Serial1.begin(115200, SERIAL_8N1);  // Use the RX1 and TX1 pins on the Mega2560

  // Special unlock/enable thing (not documented anywhere!)
  byte data0[] = { 0xFF, 0xF0, 0xF0, 0xF0, 0xF0 };
  Serial1.write(data0, 5);

  delay(2);

  // Unlock configuration
  byte data1[] = { 0xFF, 0xAA, 0x69, 0x88, 0xB5 };
  Serial1.write(data1, 5);

  delay(2);

  // Enable calibration mode
  byte data2[] = { 0xFF, 0xAA, 0x01, 0x01, 0x00 };
  Serial1.write(data2, 5);

  delay(5000);  // Wait for calibration to finish

  // Save configuration
  byte data3[] = { 0xFF, 0xAA, 0x00, 0x00, 0x00 };
  Serial1.write(data3, 5);

  Serial.begin(115200);
  // Init Serial port and class instance
  JY901_PORT.begin(115200);
  JY901.begin();
}

void loop() {
  static uint32_t prevReportTime;

  // Parse incoming reports from the JY901 module
  JY901.readReport();

  if (millis() - prevReportTime >= 1333UL) {
    prevReportTime = millis();

    // Content -> Angle
    wmAngles_t wmAngles = JY901.getAngles();
    Serial.println("Angle");
    Serial.print("\tX: ");
    Serial.println(wmAngles.roll);  // .roll() eq .x()  for wmAngles struct
    Serial.print("\tY: ");
    Serial.println(wmAngles.y);  // .y() eq .pitch() for wmAngles struct
    Serial.print("\tZ: ");
    Serial.println(wmAngles.z);  // .y() eq .yaw()   for wmAngles struct
  }
}

Just to keep you updated with the progress guys.
I successfully connected a Waveshare 1.5in SPI-4 wire RGB OLED SSD1351 display to show the received data from the WitMotion HWT905 and also print the same data to an Excell sheet with Microsoft Data Streamer.
I had to switch again to another board cos of the better support. So the library bellow was created for Arduino Uno Rev3.
But my gut feeling is I`ll have to go to a bigger board because the Uno will run out of memory as I have two more sensors to connect and an ESP-01 module to send the data to the cloud.

This is the working code so far....Please if you see something daft let me know.

#include <Wire.h>
#include <JY901.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>
// Screen dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128

// You can use any (4 or) 5 pins
#define SCLK_PIN 13
#define MOSI_PIN 11
#define DC_PIN 7
#define CS_PIN 10
#define RST_PIN 8

// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

// Option 1: use any pins but a little slower
Adafruit_SSD1351 display = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, CS_PIN, DC_PIN, MOSI_PIN, SCLK_PIN, RST_PIN);

void setup() {
  Serial.begin(115200);
  display.begin();
  Wire.begin();
}
void displayangles() {
  Serial.print((float)JY901.stcAngle.Angle[0] / 32768 * 180);
  Serial.print(",");
  Serial.print((float)JY901.stcAngle.Angle[1] / 32768 * 180);
  Serial.print(",");
  Serial.println((float)JY901.stcAngle.Angle[2] / 32768 * 180);
  Serial.print(",");
  //Clear the display
  display.fillScreen(BLACK);
  //Set the color - always use white
  display.setTextColor(WHITE);
  //Set the font size
  display.setTextSize(1);
  //Set the cursor coordinates
  display.setCursor(0, 0);
  display.print("Bobbys PLace");
  display.setCursor(0, 10);
  display.print("X:  ");
  display.print((float)JY901.stcAngle.Angle[0] / 32768 * 180);
  display.print(" d");
  display.setCursor(0, 20);
  display.print("Y:  ");
  display.print((float)JY901.stcAngle.Angle[1] / 32768 * 180);
  display.print(" d");
  display.setCursor(0, 30);
  display.print("Z:  ");
  display.println((float)JY901.stcAngle.Angle[2] / 32768 * 180);
  display.print(" d");
}

void loop() {
  Serial.print((float)JY901.stcAngle.Angle[0] / 32768 * 180);
  Serial.print(",");
  Serial.print((float)JY901.stcAngle.Angle[1] / 32768 * 180);
  Serial.print(",");
  Serial.println((float)JY901.stcAngle.Angle[2] / 32768 * 180);
  Serial.print(",");
  delay(500);

  displayangles();
  delay(1000);
}
void serialEvent() {
  while (Serial.available()) {
    JY901.CopeSerialData(Serial.read());  //Call JY901 data cope function
  }
}

Which memory? Flash? RAM?

This is what the above code use so far:

Sketch uses 14280 bytes (44%) of program storage space. Maximum is 32256 bytes.
Global variables use 854 bytes (41%) of dynamic memory, leaving 1194 bytes for local variables. Maximum is 2048 bytes.

Right now I am trying to implement the Adafruit NAU7802 24-Bit ADC in the above sketch so I can read the data from a load cell on the OLED display and stream it to excel along with the Giro/Accelerometer.
The sample library alone for the Adafruit NAU7802 uses the following space:

Sketch uses 9340 bytes (28%) of program storage space. Maximum is 32256 bytes.
Global variables use 760 bytes (37%) of dynamic memory, leaving 1288 bytes for local variables. Maximum is 2048 bytes.

Merge them and you will see what happens; it's not a matter of summing it up. On the flash side, the needed functions for e.g. the Serial class will only show once i the compiled code. And the Serial class has two 64 byte buffers per UART; that will not be duplicated.

You can save some RAM by making use of the F() macro.

So that's it, all merged and uploaded. Now it prints the data from the Giro and Load cell on the OLED and in Excel.
I am trying to figure out how I can calibrate the load cell with the original Adafruit NAU7802 library. They have got a very nice scale project with the same module but use their Python library and in that library, the sensor calibration and Tare call via a button are described very well in the code......

NAU7802 Pet Food Scale_Python

So this is my code so far with all working as it should. ... at least I hope so :slight_smile:

#include <Adafruit_NAU7802.h>
#include <Wire.h>
#include <JY901.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#include <SPI.h>
// Screen dimensions
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128

// You can use any (4 or) 5 pins
#define SCLK_PIN 13
#define MOSI_PIN 11
#define DC_PIN 7
#define CS_PIN 10
#define RST_PIN 8

// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

// Option 1: use any pins but a little slower
Adafruit_SSD1351 display = Adafruit_SSD1351(SCREEN_WIDTH, SCREEN_HEIGHT, CS_PIN, DC_PIN, MOSI_PIN, SCLK_PIN, RST_PIN);

Adafruit_NAU7802 nau;

void setup() {
  Serial.begin(115200);
  display.begin();
  Wire.begin();

  //Load Cell Code
  Serial.println("NAU7802");
  if (!nau.begin()) {
    Serial.println("Failed to find NAU7802");
  }
  Serial.println("Found NAU7802");

  nau.setLDO(NAU7802_3V0);
  Serial.print("LDO voltage set to ");
  switch (nau.getLDO()) {
    case NAU7802_4V5: Serial.println("4.5V"); break;
    case NAU7802_4V2: Serial.println("4.2V"); break;
    case NAU7802_3V9: Serial.println("3.9V"); break;
    case NAU7802_3V6: Serial.println("3.6V"); break;
    case NAU7802_3V3: Serial.println("3.3V"); break;
    case NAU7802_3V0: Serial.println("3.0V"); break;
    case NAU7802_2V7: Serial.println("2.7V"); break;
    case NAU7802_2V4: Serial.println("2.4V"); break;
    case NAU7802_EXTERNAL: Serial.println("External"); break;
  }

  nau.setGain(NAU7802_GAIN_128);
  Serial.print("Gain set to ");
  switch (nau.getGain()) {
    case NAU7802_GAIN_1: Serial.println("1x"); break;
    case NAU7802_GAIN_2: Serial.println("2x"); break;
    case NAU7802_GAIN_4: Serial.println("4x"); break;
    case NAU7802_GAIN_8: Serial.println("8x"); break;
    case NAU7802_GAIN_16: Serial.println("16x"); break;
    case NAU7802_GAIN_32: Serial.println("32x"); break;
    case NAU7802_GAIN_64: Serial.println("64x"); break;
    case NAU7802_GAIN_128: Serial.println("128x"); break;
  }

  nau.setRate(NAU7802_RATE_10SPS);
  Serial.print("Conversion rate set to ");
  switch (nau.getRate()) {
    case NAU7802_RATE_10SPS: Serial.println("10 SPS"); break;
    case NAU7802_RATE_20SPS: Serial.println("20 SPS"); break;
    case NAU7802_RATE_40SPS: Serial.println("40 SPS"); break;
    case NAU7802_RATE_80SPS: Serial.println("80 SPS"); break;
    case NAU7802_RATE_320SPS: Serial.println("320 SPS"); break;
  }

  // Take 10 readings to flush out readings
  for (uint8_t i = 0; i < 10; i++) {
    while (!nau.available()) delay(1);
    nau.read();
  }

  while (!nau.calibrate(NAU7802_CALMOD_INTERNAL)) {
    Serial.println("Failed to calibrate internal offset, retrying!");
    delay(1000);
  }
  Serial.println("Calibrated internal offset");

  while (!nau.calibrate(NAU7802_CALMOD_OFFSET)) {
    Serial.println("Failed to calibrate system offset, retrying!");
    delay(1000);
  }
  Serial.println("Calibrated system offset");
}
void displayangles() {
  int32_t val = nau.read();
  Serial.println(val);
  Serial.print(",");
  Serial.print((float)JY901.stcAngle.Angle[0] / 32768 * 180);
  Serial.print(",");
  Serial.print((float)JY901.stcAngle.Angle[1] / 32768 * 180);
  Serial.print(",");
  Serial.println((float)JY901.stcAngle.Angle[2] / 32768 * 180);
  Serial.print(",");
  //Clear the display
  display.fillScreen(BLACK);
  //Set the color - always use white
  display.setTextColor(WHITE);
  //Set the font size
  display.setTextSize(1);
  //Set the cursor coordinates
  display.setCursor(0, 0);
  display.print("Bobbys PLace");
  display.setCursor(0, 10);
  display.print("X:  ");
  display.print((float)JY901.stcAngle.Angle[0] / 32768 * 180);
  display.print(" d");
  display.setCursor(0, 20);
  display.print("Y:  ");
  display.print((float)JY901.stcAngle.Angle[1] / 32768 * 180);
  display.print(" d");
  display.setCursor(0, 30);
  display.print("Z:  ");
  display.println((float)JY901.stcAngle.Angle[2] / 32768 * 180);
  display.print(" d");
  display.setCursor(0, 45);
  display.print("W:  ");
  display.println(val);
  display.print(" kg");
}

void loop() {
  //Load cell Code
  while (!nau.available()) {
    delay(1);
  }
  int32_t val = nau.read();
  Serial.println(val);
  Serial.print(",");
  Serial.print((float)JY901.stcAngle.Angle[0] / 32768 * 180);
  Serial.print(",");
  Serial.print((float)JY901.stcAngle.Angle[1] / 32768 * 180);
  Serial.print(",");
  Serial.println((float)JY901.stcAngle.Angle[2] / 32768 * 180);
  Serial.print(",");
  delay(500);

  displayangles();
  delay(1000);
}
void serialEvent() {
  while (Serial.available()) {
    JY901.CopeSerialData(Serial.read());  //Call JY901 data cope function
  }
}

Used memory space so far:

Sketch uses 20600 bytes (63%) of program storage space. Maximum is 32256 bytes.
Global variables use 1248 bytes (60%) of dynamic memory, leaving 800 bytes for local variables. Maximum is 2048 bytes.