Showing
9 changed files
with
98 additions
and
0 deletions
recorder.py
0 → 100644
1 | +import smbus #import SMBus module of I2C | ||
2 | +from time import sleep #import | ||
3 | +import time | ||
4 | +import requests | ||
5 | +import json | ||
6 | + | ||
7 | +#some MPU6050 Registers and their Address | ||
8 | +PWR_MGMT_1 = 0x6B | ||
9 | +SMPLRT_DIV = 0x19 | ||
10 | +CONFIG = 0x1A | ||
11 | +GYRO_CONFIG = 0x1B | ||
12 | +INT_ENABLE = 0x38 | ||
13 | +ACCEL_XOUT_H = 0x3B | ||
14 | +ACCEL_YOUT_H = 0x3D | ||
15 | +ACCEL_ZOUT_H = 0x3F | ||
16 | +GYRO_XOUT_H = 0x43 | ||
17 | +GYRO_YOUT_H = 0x45 | ||
18 | +GYRO_ZOUT_H = 0x47 | ||
19 | + | ||
20 | + | ||
21 | +def MPU_Init(): | ||
22 | + #write to sample rate register | ||
23 | + bus.write_byte_data(Device_Address, SMPLRT_DIV, 7) | ||
24 | + | ||
25 | + #Write to power management register | ||
26 | + bus.write_byte_data(Device_Address, PWR_MGMT_1, 1) | ||
27 | + | ||
28 | + #Write to Configuration register | ||
29 | + bus.write_byte_data(Device_Address, CONFIG, 0) | ||
30 | + | ||
31 | + #Write to Gyro configuration register | ||
32 | + bus.write_byte_data(Device_Address, GYRO_CONFIG, 24) | ||
33 | + | ||
34 | + #Write to interrupt enable register | ||
35 | + bus.write_byte_data(Device_Address, INT_ENABLE, 1) | ||
36 | + | ||
37 | +def read_raw_data(addr): | ||
38 | + #Accelero and Gyro value are 16-bit | ||
39 | + high = bus.read_byte_data(Device_Address, addr) | ||
40 | + low = bus.read_byte_data(Device_Address, addr+1) | ||
41 | + | ||
42 | + #concatenate higher and lower value | ||
43 | + value = ((high << 8) | low) | ||
44 | + | ||
45 | + #to get signed value from mpu6050 | ||
46 | + if(value > 32768): | ||
47 | + value = value - 65536 | ||
48 | + return value | ||
49 | + | ||
50 | + | ||
51 | + | ||
52 | +def upload(datas): | ||
53 | + print(type(datas)) | ||
54 | + params={'datas':datas} | ||
55 | + url='http://192.168.0.25:80/upload' | ||
56 | + r=requests.post(url,data =json.dumps(params)) | ||
57 | + print('upload succes') | ||
58 | + | ||
59 | + | ||
60 | +bus = smbus.SMBus(1) # or bus = smbus.SMBus(0) for older version boards | ||
61 | +Device_Address = 0x68 # MPU6050 device address | ||
62 | + | ||
63 | +MPU_Init() | ||
64 | + | ||
65 | +print (" Reading Data of Gyroscope and Accelerometer") | ||
66 | +start_time=time.time() | ||
67 | +mid_time=time.time() | ||
68 | +data=[] | ||
69 | +while True: | ||
70 | + #Read Accelerometer raw value | ||
71 | + acc_x = read_raw_data(ACCEL_XOUT_H) | ||
72 | + acc_y = read_raw_data(ACCEL_YOUT_H) | ||
73 | + acc_z = read_raw_data(ACCEL_ZOUT_H) | ||
74 | + | ||
75 | + Ax = acc_x/16384.0 | ||
76 | + Ay = acc_y/16384.0 | ||
77 | + Az = acc_z/16384.0 | ||
78 | + | ||
79 | + value=abs(acc_x+acc_y+acc_z)/10 | ||
80 | + data.append(value) | ||
81 | + | ||
82 | + if(time.time()>start_time+10): | ||
83 | + break | ||
84 | + if(time.time()-mid_time>1): | ||
85 | + print(time.time()-start_time) | ||
86 | + mid_time=time.time() | ||
87 | + | ||
88 | +upload.upload(data) |
renderer.py
0 → 100644
No preview for this file type
No preview for this file type
면담확인서 및 주간보고서/11월 1주차 주간보고서.docx
0 → 100644
No preview for this file type
면담확인서 및 주간보고서/11월 2주차 면담보고서.docx
0 → 100644
No preview for this file type
면담확인서 및 주간보고서/11월 3주차 면담보고서.docx
0 → 100644
No preview for this file type
면담확인서 및 주간보고서/11월 4주차 면담보고서.docx
0 → 100644
No preview for this file type
면담확인서 및 주간보고서/12월 1주차 주간보고서.docx
0 → 100644
No preview for this file type
-
Please register or login to post a comment