[SOLVED]Cubecell 9250 Row, Pitch, Yaw

Is there a way to get the Roll Pitch and Yaw output of the Cubecell with the Gyro? Evertime I think I have it figured out, I get nothing.

Is MPU9250 can fit your need?

I am using the mpu9250. I just need it to show orientation or yaw pitch and roll. I cannot get the code to display it

perhaps the values magX, magY, magZ fits your needs

I need to track the orientation of an object and set an alert if it travels more than 3 degrees. This is usually done by combining the outputs with formulas from the 9dofs output. But when I add the library for the the math portion I get an error compiling for the cubecell. I am going to try using the BNO055 as it will do the calculations on the board and should output the Yaw pitch and roll orientations to the cubecell .

Do you have already work out the yaw pitch and roll on other platform?

If yes, please provide some more information and let me have a try.

Trying to use Sparkfun https://github.com/sparkfun/MPU-9250_Breakout
The example for Orientation

with the last commit to github you can now do this:

      mpu9250.computeEulerAngles();
      Serial.println("pitch: " + String(mpu9250.pitch()));
      Serial.println("roll: " + String(mpu9250.roll()));
      Serial.println("yaw: " + String(mpu9250.yaw()));
1 Like

I will give it try later today and let you know how it works out…Thanks for taking the time to do this.

After a really long day at work, I tried to get one of the examples to run with Roll Pitch and Yaw but was unable to. Can you update one the examples in the librarys or post it here?

I will try to update an example later this day

1 Like

I see you updated one of the examples. I figured out what I was doing wrong and your example really helped…thanks.

glad you figured it out.

Now to try the interrupt example with the RPY values. Should be fun.

1 Like

how can i merge the mpu9250 basic with the basic code to connect to TTN through arduino IDE?

have a look at the LoRaWAN MPU9250 example?

If i load just the .ino file i get absurd readings in the configurator but no initialisation to TTN that way. So whats the process here? I got somehow merge the lorawan.ino routine and merge inside the 9250.ino?
Your firmware includes both of these, right?
Heres my code as i merged it, dunno if it right though.

#include "LoRaWan_APP.h"
#include "Arduino.h"
#include <MPU9250.h>

MPU9250 mySensor;
float aX, aY, aZ, aSqrt, gX, gY, gZ, mDirection, mX, mY, mZ;

/*
 * set LoraWan_RGB to Active,the RGB active in loraWan
 * RGB red means sending;
 * RGB purple means joined done;
 * RGB blue means RxWindow1;
 * RGB yellow means RxWindow2;
 * RGB green means received done;
 */

/* OTAA para*/
uint8_t devEui[] = { 0xD0, 0x6D0, 0x44, 0x0B, 0x, 0x92, 0x12, 0xA4 };
uint8_t appEui[] = { 0x, 0x, 0x, 0x7E, 0x, 0x55, 0xF6, 0xE8 };
uint8_t appKey[] = { 0xF*, 0xE, 0xF6, 0x5, 0x8*, 0x**, 0x5, 0xB*, 0x**, 0x4*, 0x7, 0x2, 0xC, 0x2, 0x**, 0x** };

/* ABP para*/
uint8_t nwkSKey[] = { 0x15, 0xb1, 0xd0, 0xef, 0xa4, 0x63, 0xdf, 0xbe, 0x3d, 0x11, 0x18, 0x1e, 0x1e, 0xc7, 0xda,0x85 };
uint8_t appSKey[] = { 0xd7, 0x2c, 0x78, 0x75, 0x8c, 0xdc, 0xca, 0xbf, 0x55, 0xee, 0x4a, 0x77, 0x8d, 0x16, 0xef,0x67 };
uint32_t devAddr =  ( uint32_t )0x007e6ae1;

/*LoraWan channelsmask, default channels 0-7*/ 
uint16_t userChannelsMask[6]={ 0x00FF,0x0000,0x0000,0x0000,0x0000,0x0000 };

/*LoraWan region, select in arduino IDE tools*/
LoRaMacRegion_t loraWanRegion = ACTIVE_REGION;

/*LoraWan Class, Class A and Class C are supported*/
DeviceClass_t  loraWanClass = LORAWAN_CLASS;

/*the application data transmission duty cycle.  value in [ms].*/
uint32_t appTxDutyCycle = 15000;

/*OTAA or ABP*/
bool overTheAirActivation = LORAWAN_NETMODE;

/*ADR enable*/
bool loraWanAdr = LORAWAN_ADR;

/* set LORAWAN_Net_Reserve ON, the node could save the network info to flash, when node reset not need to join again */
bool keepNet = LORAWAN_NET_RESERVE;

/* Indicates if the node is sending confirmed or unconfirmed messages */
bool isTxConfirmed = LORAWAN_UPLINKMODE;

/* Application port */
uint8_t appPort = 2;
/*!
* Number of trials to transmit the frame, if the LoRaMAC layer did not
* receive an acknowledgment. The MAC performs a datarate adaptation,
* according to the LoRaWAN Specification V1.0.2, chapter 18.4, according
* to the following table:
*
* Transmission nb | Data Rate
* ----------------|-----------
* 1 (first)       | DR
* 2               | DR
* 3               | max(DR-1,0)
* 4               | max(DR-1,0)
* 5               | max(DR-2,0)
* 6               | max(DR-2,0)
* 7               | max(DR-3,0)
* 8               | max(DR-3,0)
*
* Note, that if NbTrials is set to 1 or 2, the MAC will not decrease
* the datarate, in case the LoRaMAC layer did not receive an acknowledgment
*/
uint8_t confirmedNbTrials = 4;

/* Prepares the payload of the frame */
static void prepareTxFrame( uint8_t port )
{
	/*appData size is LORAWAN_APP_DATA_MAX_SIZE which is defined in "commissioning.h".
	*appDataSize max value is LORAWAN_APP_DATA_MAX_SIZE.
	*if enabled AT, don't modify LORAWAN_APP_DATA_MAX_SIZE, it may cause system hanging or failure.
	*if disabled AT, LORAWAN_APP_DATA_MAX_SIZE can be modified, the max value is reference to lorawan region and SF.
	*for example, if use REGION_CN470, 
	*the max value for different DR can be found in MaxPayloadOfDatarateCN470 refer to DataratesCN470 and BandwidthsCN470 in "RegionCN470.h".
	*/
    appDataSize = 4;
    appData[0] = 0x00;
    appData[1] = 0x01;
    appData[2] = 0x02;
    appData[3] = 0x03;
}


void setup() {
	boardInitMcu();
 pinMode(Vext,OUTPUT);
  digitalWrite(Vext,LOW);
	Serial.begin(115200);
#if(AT_SUPPORT)
	enableAt();
#endif
	deviceState = DEVICE_STATE_INIT;
	LoRaWAN.ifskipjoin();
  //while(!Serial);
  Serial.println("started");

//#ifdef _ESP32_HAL_I2C_H_ // For ESP32
  Wire.begin();
  mySensor.setWire(&Wire);
//#endif

  mySensor.beginAccel();
  mySensor.beginGyro();
  mySensor.beginMag();

  // You can set your own offset for mag values
  // mySensor.magXOffset = -50;
  // mySensor.magYOffset = -55;
  // mySensor.magZOffset = -10;
}

void loop()
{
	switch( deviceState )
	{
		case DEVICE_STATE_INIT:
		{
#if(AT_SUPPORT)
			getDevParam();
#endif
			printDevParam();
			LoRaWAN.init(loraWanClass,loraWanRegion);
			deviceState = DEVICE_STATE_JOIN;
			break;
		}
		case DEVICE_STATE_JOIN:
		{
			LoRaWAN.join();
			break;
		}
		case DEVICE_STATE_SEND:
		{
			prepareTxFrame( appPort );
			LoRaWAN.send();
			deviceState = DEVICE_STATE_CYCLE;
			break;
		}
		case DEVICE_STATE_CYCLE:
		{
			// Schedule next packet transmission
			txDutyCycleTime = appTxDutyCycle + randr( 0, APP_TX_DUTYCYCLE_RND );
			LoRaWAN.cycle(txDutyCycleTime);
			deviceState = DEVICE_STATE_SLEEP;
			break;
		}
		case DEVICE_STATE_SLEEP:
		{
			LoRaWAN.sleep();
			break;
		}
		default:
		{
			deviceState = DEVICE_STATE_INIT;
			break;
		}
	}
 {
  uint8_t sensorId;
  if (mySensor.readId(&sensorId) == 0) {
    Serial.println("sensorId: " + String(sensorId));
  } else {
    Serial.println("Cannot read sensorId");
  }

  if (mySensor.accelUpdate() == 0) {
    aX = mySensor.accelX();
    aY = mySensor.accelY();
    aZ = mySensor.accelZ();
    aSqrt = mySensor.accelSqrt();
    Serial.println("accelX: " + String(aX));
    Serial.println("accelY: " + String(aY));
    Serial.println("accelZ: " + String(aZ));
    Serial.println("accelSqrt: " + String(aSqrt));
  } else {
    Serial.println("Cannod read accel values");
  }

  if (mySensor.gyroUpdate() == 0) {
    gX = mySensor.gyroX();
    gY = mySensor.gyroY();
    gZ = mySensor.gyroZ();
    Serial.println("gyroX: " + String(gX));
    Serial.println("gyroY: " + String(gY));
    Serial.println("gyroZ: " + String(gZ));
  } else {
    Serial.println("Cannot read gyro values");
  }

  if (mySensor.magUpdate() == 0) {
    mX = mySensor.magX();
    mY = mySensor.magY();
    mZ = mySensor.magZ();
    mDirection = mySensor.magHorizDirection();
    Serial.println("magX: " + String(mX));
    Serial.println("maxY: " + String(mY));
    Serial.println("magZ: " + String(mZ));
    Serial.println("horizontal direction: " + String(mDirection));
  } else {
    Serial.println("Cannot read mag values");
  }

  Serial.println("at " + String(millis()) + "ms");
  Serial.println(""); // Add an empty line
  delay(500);
}
}

Have you edited something inside this code? Cos i cant tell if you replied

i have not changed the text only the layout for your code to code for easier reading

this is what your code is sending

you need to put all your sensor reading code in the function prepareTxFrame and fill the appData variable with your measured values.

look at an other sensor example for lorawan and use that for a start