By Ryan Webb

2019-11-08 14:29:25 8 Comments

Newbie question for library designers, how to determine #define values (in this case MPU6050.h)? I can't wrap my head where these values came from. (0x68, 0x00, etc)

#define MPU6050_ADDRESS_AD0_LOW     0x68 // address pin low (GND), default for InvenSense evaluation board
#define MPU6050_ADDRESS_AD0_HIGH    0x69 // address pin high (VCC)

#define MPU6050_RA_XG_OFFS_TC       0x00 //[7] PWR_MODE, [6:1] XG_OFFS_TC, [0] OTP_BNK_VLD
#define MPU6050_RA_YG_OFFS_TC       0x01 //[7] PWR_MODE, [6:1] YG_OFFS_TC, [0] OTP_BNK_VLD
#define MPU6050_RA_ZG_OFFS_TC       0x02 //[7] PWR_MODE, [6:1] ZG_OFFS_TC, [0] OTP_BNK_VLD
#define MPU6050_RA_X_FINE_GAIN      0x03 //[7:0] X_FINE_GAIN
#define MPU6050_RA_Y_FINE_GAIN      0x04 //[7:0] Y_FINE_GAIN
#define MPU6050_RA_Z_FINE_GAIN      0x05 //[7:0] Z_FINE_GAIN
#define MPU6050_RA_XA_OFFS_H        0x06 //[15:0] XA_OFFS
#define MPU6050_RA_XA_OFFS_L_TC     0x07
#define MPU6050_RA_YA_OFFS_H        0x08 //[15:0] YA_OFFS
#define MPU6050_RA_YA_OFFS_L_TC     0x09
#define MPU6050_RA_ZA_OFFS_H        0x0A //[15:0] ZA_OFFS


@JHBonarius 2019-11-08 14:42:32

Most code for embedded controllers have a lot of these defines. Each define either represents a register base address of an offset from that base. Then you could also have bit-masks that are used to access specific bits inside on an address. E.g.


You seem to be using the MPU-6050 3-axis accelerometer. If you look in the datasheet for that device, they mention the "MPU-6000/MPU-6050 Register Map and Register Descriptions". Looking in that document you can find the register map, which looks like this:

enter image description here

See the connection?

These defines help you write readable interfacing code with your component.

@Ryan Webb 2019-11-08 14:45:12

Thank you so much for taking the time to google it. I was about to answer my own question but I saw your answer already. I also found it here based on the comments previously given by the community. Stay awesome dear sir!‌​…

Related Questions

Sponsored Content

19 Answered Questions

[SOLVED] How to find out if an item is present in a std::vector?

  • 2009-02-20 21:58:41
  • Joan Venge
  • 933730 View
  • 621 Score
  • 19 Answer
  • Tags:   c++ vector std

22 Answered Questions

[SOLVED] How to initialize all members of an array to the same value?

1 Answered Questions

[SOLVED] Tessel 2 - not logging buffer

3 Answered Questions

[SOLVED] How to use Qt QSerialPort to send hex 0x00

1 Answered Questions

1 Answered Questions

NFC P2P as3911 <--> phone

1 Answered Questions

Sponsored Content