mpu6050 - vlizBE/dcafs GitHub Wiki
-
This guides assumes:
- the hardware connections have been made
- the I2C bus used is 3, alter this accordingly
- i2c is on a sbc connected to via ssh
- working pc is running windows
-
Required tools:
- putty or any other ssh client
- winscp
- Figure out the address used with
i2c:detect,3
, this should atleast return:- Free - 0x68
- or
- Free - 0x69
- Free - 0x68
- Add it to dcafs with the command
i2c:adddevice,mpu,bus,address,scriptname
- So this becomes:
i2c:adddevice,mpu,3,0x68,mpu6050
- This will add the file mpu6050.xml in a i2cscripts subfolder
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <commandset script="mpu6050"> <!-- An empty command to start with --> <command id="cmdname" info="what this does"/> </commandset>
- And also add the following section to the settings.xml:
<i2c> <bus controller="3"> <device address="0x69" id="mpu" script="mpu6050"/> </bus> </i2c>
- This will add the file mpu6050.xml in a i2cscripts subfolder
- So this becomes:
- By default, dcafs has been started as root, so the script mpu6050.xml will be owned by root. Change this
so anyone can alter it. This will be needed later unless you don't mind logging in as root in ssh.
- When the cli is inside the dcafs folder:
sudo chmod a+rw i2cscripts/mpu6050.xml
- When the cli is inside the dcafs folder:
That's it, keep this session open.
- Open winscp.
- Open mpu6050 with your preferred text editor.
- First we'll add a command to read the gyro, the xml will become like this
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <commandset script="mpu6050"> <!-- Read data: 16bit spread over 6 registers starting at 0x43 --> <command id="readgyro" info="Read gyro x,y and z" bits="16"> <read reg="0x43" return="6"/> </command> </commandset>
- In the dcafs session, use
i2c:reload
All files (1) read ok
- Check this with
i2c:list
mpu -> @3:0x68 using script mpu6050 with label void -Stored scripts-
mpu6050
readgyro -> Read gyro x,y and z (16bits)
Read 6 bytes from reg 0x43 - Test the new command with
i2c:id,command
soi2c:mpu,readgyro