Skip to content

Commit cae299c

Browse files
committed
Added all the files
1 parent 05d50cb commit cae299c

30 files changed

+3648
-0
lines changed
+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#include <Wire.h> //library allows communication with I2C / TWI devices
2+
#include <math.h> //library includes mathematical functions
3+
4+
const int MPU=0x68; //I2C address of the MPU-6050
5+
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ; //16-bit integers
6+
int AcXcal,AcYcal,AcZcal,GyXcal,GyYcal,GyZcal,tcal; //calibration variables
7+
double t,tx,tf,pitch,roll;
8+
9+
void setup()
10+
{
11+
Wire.begin(); //initiate wire library and I2C
12+
Wire.beginTransmission(MPU); //begin transmission to I2C slave device
13+
Wire.write(0x6B); // PWR_MGMT_1 register
14+
Wire.write(0); // set to zero (wakes up the MPU-6050)
15+
Wire.endTransmission(true); //ends transmission to I2C slave device
16+
Serial.begin(9600); //serial communication at 9600 bauds
17+
}
18+
19+
void loop()
20+
{
21+
Wire.beginTransmission(MPU); //begin transmission to I2C slave device
22+
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
23+
Wire.endTransmission(false); //restarts transmission to I2C slave device
24+
Wire.requestFrom(MPU,14,true); //request 14 registers in total
25+
26+
//Acceleration data correction
27+
AcXcal = -950;
28+
AcYcal = -300;
29+
AcZcal = 0;
30+
31+
//Temperature correction
32+
tcal = -1600;
33+
34+
//Gyro correction
35+
GyXcal = 480;
36+
GyYcal = 170;
37+
GyZcal = 210;
38+
39+
40+
//read accelerometer data
41+
AcX=Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) 0x3C (ACCEL_XOUT_L)
42+
AcY=Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) 0x3E (ACCEL_YOUT_L)
43+
AcZ=Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) 0x40 (ACCEL_ZOUT_L)
44+
45+
//read temperature data
46+
Tmp=Wire.read()<<8|Wire.read(); // 0x41 (TEMP_OUT_H) 0x42 (TEMP_OUT_L)
47+
48+
//read gyroscope data
49+
GyX=Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) 0x44 (GYRO_XOUT_L)
50+
GyY=Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) 0x46 (GYRO_YOUT_L)
51+
GyZ=Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) 0x48 (GYRO_ZOUT_L)
52+
53+
//temperature calculation
54+
tx = Tmp + tcal;
55+
t = tx/340 + 36.53; //equation for temperature in degrees C from datasheet
56+
tf = (t * 9/5) + 32; //fahrenheit
57+
58+
//get pitch/roll
59+
getAngle(AcX,AcY,AcZ);
60+
61+
//printing values to serial port
62+
Serial.print("Angle: ");
63+
Serial.print("Pitch = "); Serial.print(pitch);
64+
Serial.print(" Roll = "); Serial.println(roll);
65+
66+
Serial.print("Accelerometer: ");
67+
Serial.print("X = "); Serial.print(AcX + AcXcal);
68+
Serial.print(" Y = "); Serial.print(AcY + AcYcal);
69+
Serial.print(" Z = "); Serial.println(AcZ + AcZcal);
70+
71+
Serial.print("Temperature in celsius = "); Serial.print(t);
72+
Serial.print(" fahrenheit = "); Serial.println(tf);
73+
74+
Serial.print("Gyroscope: ");
75+
Serial.print("X = "); Serial.print(GyX + GyXcal);
76+
Serial.print(" Y = "); Serial.print(GyY + GyYcal);
77+
Serial.print(" Z = "); Serial.println(GyZ + GyZcal);
78+
79+
delay(1000);
80+
}
81+
82+
//function to convert accelerometer values into pitch and roll
83+
void getAngle(int Ax,int Ay,int Az)
84+
{
85+
double x = Ax;
86+
double y = Ay;
87+
double z = Az;
88+
89+
pitch = atan(x/sqrt((y*y) + (z*z))); //pitch calculation
90+
roll = atan(y/sqrt((x*x) + (z*z))); //roll calculation
91+
92+
//converting radians into degrees
93+
pitch = pitch * (180.0/3.14);
94+
roll = roll * (180.0/3.14) ;
95+
}

push.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
git status
2+
git pull origin master
3+
git add .
4+
git commit -m "$1"
5+
git push

server/.gitignore

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# TypeScript v1 declaration files
45+
typings/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# Next.js build output
79+
.next
80+
81+
# Nuxt.js build / generate output
82+
.nuxt
83+
dist
84+
85+
# Gatsby files
86+
.cache/
87+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88+
# https://nextjs.org/blog/next-9-1#public-directory-support
89+
# public
90+
91+
# vuepress build output
92+
.vuepress/dist
93+
94+
# Serverless directories
95+
.serverless/
96+
97+
# FuseBox cache
98+
.fusebox/
99+
100+
# DynamoDB Local files
101+
.dynamodb/
102+
103+
# TernJS port file
104+
.tern-port

server/.idea/.gitignore

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/.idea/arduino_ctrl.iml

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/.idea/aws.xml

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/.idea/codeStyles/codeStyleConfig.xml

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/.idea/compiler.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/.idea/jsLibraryMappings.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)